1 #ifndef __ABSTRACTINTERFACE_H__
2 #define __ABSTRACTINTERFACE_H__
11 #include "Exception.h"
14 #define AI_TO_REF(ptr) ((ReferenceInterface*)ptr)
15 #define AI_TO_FUN(ptr) ((FunctionalInterface*)ptr)
16 #define AI_TO_GRP(ptr) ((GroupInterface*)ptr)
17 #define AI_TO_CON(ptr) ((ConnectedInterface*)ptr)
23 class AbstractInterface {
27 enum IfaceWidthType { Expression = 1, Boolean, Natural, Inherited}; //! Inherited is only for Group interface
28 enum IfaceWidthDir { LittleEndian = 1, BigEndian}; //! LittleEndian = X downto 0, BigEndian = 0 to X
29 enum IfacePurpose { AnyPurpose = 0, Data = 1, Control, Clock, Reset, Wishbone };
30 enum IfaceDirection { AnyDirection = 0, Input = 1, Output = 2, InOut = 3 };
31 enum IfaceVHDLContext {AnyContext = 0, Entity = 1, Component = 2, Architecture = 3 }; // NB : 3 is when creating an instance of the block that owns this iface
32 enum IfaceVHDLFlags { NoComma = 1 };
34 static int getIntDirection(QString str);
35 static int getIntPurpose(QString str);
37 AbstractInterface(AbstractBlock* _owner);
38 AbstractInterface(AbstractBlock* _owner, const QString& _name, int _direction, int _purpose, const QString& _type, const QString& _width, int _endianess = LittleEndian);
39 AbstractInterface(AbstractInterface* other);
40 virtual ~AbstractInterface();
43 inline QString getName() { return name;}
44 inline int getType() { return type; }
45 QString getTypeString();
46 inline int getEndianess() { return endianess; }
47 QString getEndianessString();
48 inline QString getWidth() { return width;}
49 inline int getPurpose() { return purpose;}
50 QString getPurposeString();
51 inline int getDirection() { return direction;}
52 QString getDirectionString();
53 inline AbstractBlock *getOwner() { return owner;}
54 inline AbstractInterface* getAssociatedIface() { return associatedIface; }
56 double getDoubleWidth() throw(QException);
60 inline void setOwner(AbstractBlock* _owner) { owner = _owner; }
61 void setName(const QString& _name);
62 inline void setWidth(const QString& _width) { width = _width; }
63 inline void setType(int _type) { type = _type;}
64 inline void setEndianess(int _endianess) { endianess = _endianess;}
65 inline void setType(const QString& _type) { type = typeFromString(_type);}
66 void setPurpose(int _purpose);
67 void setDirection(int _direction);
68 bool setAssociatedIface(AbstractInterface* iface);
71 virtual bool isReferenceInterface();
72 virtual bool isFunctionalInterface();
73 virtual bool isGroupInterface();
76 virtual AbstractInterface *clone() = 0;
78 int typeFromString(const QString &_type);
80 QString toVHDL(int context, int flags) throw(Exception);
93 * \brief associatedIface the control (resp. data) interface that is bounded to this data (resp. control) interface
94 * If a reference block is designed to be fully integrated in Blast, nearly every data interface is bounded
95 * to a control interface that signals if the value presented on the interface is valid or not. associatedIface
96 * references this control interface if this is a data interface, and a data interface is this is a control interface.
97 * Note that the association is done by the call of setAssociatedIface() that must be done only for a control interface.
98 * (NB: a test is done in the method to prevent the other case).
100 AbstractInterface* associatedIface;
106 #endif // __ABSTRACTINTERFACE_H__