X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/561d4f45e60504cc9e041370dd908b002fe776a5..18fecf25efe710631fabecbb9f689c2997fdfe18:/AbstractInterface.h diff --git a/AbstractInterface.h b/AbstractInterface.h index 5c0b83a..a214831 100644 --- a/AbstractInterface.h +++ b/AbstractInterface.h @@ -14,6 +14,7 @@ class Exception; #define AI_TO_REF(ptr) ((ReferenceInterface*)ptr) #define AI_TO_FUN(ptr) ((FunctionalInterface*)ptr) #define AI_TO_GRP(ptr) ((GroupInterface*)ptr) +#define AI_TO_CON(ptr) ((ConnectedInterface*)ptr) using namespace std; using namespace Qt; @@ -23,16 +24,18 @@ class AbstractInterface { public : - enum IfaceWidthType { Expression = 1, Boolean, Natural}; - enum IfacePurpose { Data = 1, Control, Clock, Reset, Wishbone }; - enum IfaceDirection { Input = 1, Output = 2, InOut = 3 }; - enum IfaceVHDLContext { Entity = 1, Component = 2, Architecture = 3 }; // NB : 3 is when creating an instance of the block that owns this iface + enum IfaceWidthType { Expression = 1, Boolean, Natural, Inherited}; //! Inherited is only for Group interface + enum IfaceWidthDir { LittleEndian = 1, BigEndian}; //! LittleEndian = X downto 0, BigEndian = 0 to X + enum IfacePurpose { AnyPurpose = 0, Data = 1, Control, Clock, Reset, Wishbone }; + enum IfaceDirection { AnyDirection = 0, Input = 1, Output = 2, InOut = 3 }; + enum IfaceVHDLContext {AnyContext = 0, Entity = 1, Component = 2, Architecture = 3 }; // NB : 3 is when creating an instance of the block that owns this iface enum IfaceVHDLFlags { NoComma = 1 }; - static int getIntDirection(QString str); + static int getIntDirection(QString str); + static int getIntPurpose(QString str); AbstractInterface(AbstractBlock* _owner); - AbstractInterface(AbstractBlock* _owner, const QString& _name, const QString& _type, const QString& _width, int _direction, int _purpose); + AbstractInterface(AbstractBlock* _owner, const QString& _name, int _direction, int _purpose, const QString& _type, const QString& _width, int _endianess = LittleEndian); AbstractInterface(AbstractInterface* other); virtual ~AbstractInterface(); @@ -40,61 +43,63 @@ public : inline QString getName() { return name;} inline int getType() { return type; } QString getTypeString(); + inline int getEndianess() { return endianess; } + QString getEndianessString(); inline QString getWidth() { return width;} inline int getPurpose() { return purpose;} QString getPurposeString(); inline int getDirection() { return direction;} QString getDirectionString(); inline AbstractBlock *getOwner() { return owner;} + inline AbstractInterface* getAssociatedIface() { return associatedIface; } double getDoubleWidth() throw(QException); - - //virtual QList getConnectedTo() = 0; - - /* NB: only GroupInterface and FunctionalInterface have a connectedFrom, so - defining getConnectedFrom as pure virtual is normal, usefull even though it is ugly :-) - */ - virtual AbstractInterface* getConnectedFrom() = 0; + // setters inline void setOwner(AbstractBlock* _owner) { owner = _owner; } - inline void setName(const QString& _name) { name = _name; } + void setName(const QString& _name); inline void setWidth(const QString& _width) { width = _width; } inline void setType(int _type) { type = _type;} + inline void setEndianess(int _endianess) { endianess = _endianess;} inline void setType(const QString& _type) { type = typeFromString(_type);} void setPurpose(int _purpose); - void setDirection(int _direction); - + void setDirection(int _direction); + bool setAssociatedIface(AbstractInterface* iface); + // testers virtual bool isReferenceInterface(); virtual bool isFunctionalInterface(); virtual bool isGroupInterface(); - //virtual bool isConnectedTo() = 0; - //virtual bool isConnectedFrom() = 0; - //virtual bool canConnectTo(AbstractInterface* iface) = 0; // returns yes if this can be connected to iface, no if not - //virtual bool canConnectFrom(AbstractInterface* iface) = 0; // returns yes if this can be connected from iface, no if not // others virtual AbstractInterface *clone() = 0; - - //virtual bool addConnectedTo(AbstractInterface *inter) = 0; - //virtual void removeConnectedTo(AbstractInterface *inter) = 0; - //virtual bool setConnectedFrom(AbstractInterface* inter) = 0; - //virtual void clearConnectedTo() = 0; - //virtual void clearConnections() = 0; - //virtual void connectionsValidation(QStack *interfacetoValidate, QList *validatedInterfaces) throw(Exception) = 0; + int typeFromString(const QString &_type); QString toVHDL(int context, int flags) throw(Exception); protected: QString name; - int type; - QString width; int purpose; int direction; + int type; + QString width; + int endianess; + AbstractBlock* owner; + /*! + * \brief associatedIface the control (resp. data) interface that is bounded to this data (resp. control) interface + * If a reference block is designed to be fully integrated in Blast, nearly every data interface is bounded + * to a control interface that signals if the value presented on the interface is valid or not. associatedIface + * references this control interface if this is a data interface, and a data interface is this is a control interface. + * Note that the association is done by the call of setAssociatedIface() that must be done only for a control interface. + * (NB: a test is done in the method to prevent the other case). + */ + AbstractInterface* associatedIface; + + };