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)
22 class AbstractInterface {
26 enum IfaceWidthType { Expression = 1, Boolean, Natural, Inherited}; //! Inherited is only for Group interface
27 enum IfacePurpose { Data = 1, Control, Clock, Reset, Wishbone };
28 enum IfaceDirection { Input = 1, Output = 2, InOut = 3 };
29 enum IfaceVHDLContext { Entity = 1, Component = 2, Architecture = 3 }; // NB : 3 is when creating an instance of the block that owns this iface
30 enum IfaceVHDLFlags { NoComma = 1 };
32 static int getIntDirection(QString str);
34 AbstractInterface(AbstractBlock* _owner);
35 AbstractInterface(AbstractBlock* _owner, const QString& _name, const QString& _type, const QString& _width, int _direction, int _purpose);
36 AbstractInterface(AbstractInterface* other);
37 virtual ~AbstractInterface();
40 inline QString getName() { return name;}
41 inline int getType() { return type; }
42 QString getTypeString();
43 inline QString getWidth() { return width;}
44 inline int getPurpose() { return purpose;}
45 QString getPurposeString();
46 inline int getDirection() { return direction;}
47 QString getDirectionString();
48 inline AbstractBlock *getOwner() { return owner;}
49 inline AbstractInterface* getAssociatedIface() { return associatedIface; }
51 double getDoubleWidth() throw(QException);
53 //virtual QList<AbstractInterface*> getConnectedTo() = 0;
55 /* NB: only GroupInterface and FunctionalInterface have a connectedFrom, so
56 defining getConnectedFrom as pure virtual is normal, usefull even though it is ugly :-)
58 virtual AbstractInterface* getConnectedFrom() = 0;
61 inline void setOwner(AbstractBlock* _owner) { owner = _owner; }
62 inline void setName(const QString& _name) { name = _name; }
63 inline void setWidth(const QString& _width) { width = _width; }
64 inline void setType(int _type) { type = _type;}
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();
74 //virtual bool isConnectedTo() = 0;
75 //virtual bool isConnectedFrom() = 0;
76 //virtual bool canConnectTo(AbstractInterface* iface) = 0; // returns yes if this can be connected to iface, no if not
77 //virtual bool canConnectFrom(AbstractInterface* iface) = 0; // returns yes if this can be connected from iface, no if not
80 virtual AbstractInterface *clone() = 0;
82 //virtual bool addConnectedTo(AbstractInterface *inter) = 0;
83 //virtual void removeConnectedTo(AbstractInterface *inter) = 0;
84 //virtual bool setConnectedFrom(AbstractInterface* inter) = 0;
85 //virtual void clearConnectedTo() = 0;
86 //virtual void clearConnections() = 0;
87 //virtual void connectionsValidation(QStack<AbstractInterface*> *interfacetoValidate, QList<AbstractInterface*> *validatedInterfaces) throw(Exception) = 0;
88 int typeFromString(const QString &_type);
90 QString toVHDL(int context, int flags) throw(Exception);
101 * \brief associatedIface the control (resp. data) interface that is bounded to this data (resp. control) interface
102 * If a reference block is designed to be fully integrated in Blast, nearly every data interface is bounded
103 * to a control interface that signals if the value presented on the interface is valid or not. associatedIface
104 * references this control interface if this is a data interface, and a data interface is this is a control interface.
105 * Note that the association is done by the call of setAssociatedIface() that must be done only for a control interface.
106 * (NB: a test is done in the method to prevent the other case).
108 AbstractInterface* associatedIface;
112 #endif // __ABSTRACTINTERFACE_H__