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 IfacePurpose { AnyPurpose = 0, Data = 1, Control, Clock, Reset, Wishbone };
29 enum IfaceDirection { AnyDirection = 0, Input = 1, Output = 2, InOut = 3 };
30 enum IfaceVHDLContext {AnyContext = 0, Entity = 1, Component = 2, Architecture = 3 }; // NB : 3 is when creating an instance of the block that owns this iface
31 enum IfaceVHDLFlags { NoComma = 1 };
33 static int getIntDirection(QString str);
34 static int getIntPurpose(QString str);
36 AbstractInterface(AbstractBlock* _owner);
37 AbstractInterface(AbstractBlock* _owner, const QString& _name, const QString& _type, const QString& _width, int _direction, int _purpose);
38 AbstractInterface(AbstractInterface* other);
39 virtual ~AbstractInterface();
42 inline QString getName() { return name;}
43 inline int getType() { return type; }
44 QString getTypeString();
45 inline QString getWidth() { return width;}
46 inline int getPurpose() { return purpose;}
47 QString getPurposeString();
48 inline int getDirection() { return direction;}
49 QString getDirectionString();
50 inline AbstractBlock *getOwner() { return owner;}
51 inline AbstractInterface* getAssociatedIface() { return associatedIface; }
53 double getDoubleWidth() throw(QException);
57 inline void setOwner(AbstractBlock* _owner) { owner = _owner; }
58 inline void setName(const QString& _name) { name = _name; }
59 inline void setWidth(const QString& _width) { width = _width; }
60 inline void setType(int _type) { type = _type;}
61 inline void setType(const QString& _type) { type = typeFromString(_type);}
62 void setPurpose(int _purpose);
63 void setDirection(int _direction);
64 bool setAssociatedIface(AbstractInterface* iface);
67 virtual bool isReferenceInterface();
68 virtual bool isFunctionalInterface();
69 virtual bool isGroupInterface();
72 virtual AbstractInterface *clone() = 0;
74 int typeFromString(const QString &_type);
76 QString toVHDL(int context, int flags) throw(Exception);
87 * \brief associatedIface the control (resp. data) interface that is bounded to this data (resp. control) interface
88 * If a reference block is designed to be fully integrated in Blast, nearly every data interface is bounded
89 * to a control interface that signals if the value presented on the interface is valid or not. associatedIface
90 * references this control interface if this is a data interface, and a data interface is this is a control interface.
91 * Note that the association is done by the call of setAssociatedIface() that must be done only for a control interface.
92 * (NB: a test is done in the method to prevent the other case).
94 AbstractInterface* associatedIface;
100 #endif // __ABSTRACTINTERFACE_H__