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};
27 enum IfacePurpose { Data = 1, Clock = 2, Reset = 3, Wishbone = 4 };
28 enum IfaceDirection { Input = 1, Output = 2, InOut = 3 };
29 enum IfaceLevel { Basic = 1, Top = 2 };
30 enum IfaceVHDLContext { 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 getIntLevel(QString str);
36 AbstractInterface(AbstractBlock* _owner);
37 AbstractInterface(AbstractBlock* _owner, const QString& _name, const QString& _type, const QString& _width, int _direction, int _purpose, int _level);
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 int getLevel() { return level;}
51 QString getLevelString();
52 inline AbstractBlock *getOwner() { return owner;}
54 double getDoubleWidth() throw(QException);
56 //virtual QList<AbstractInterface*> getConnectedTo() = 0;
58 /* NB: only GroupInterface and FunctionalInterface have a connectedFrom, so
59 defining getConnectedFrom as pure virtual is normal, usefull even though it is ugly :-)
61 virtual AbstractInterface* getConnectedFrom() = 0;
64 inline void setOwner(AbstractBlock* _owner) { owner = _owner; }
65 inline void setName(const QString& _name) { name = _name; }
66 inline void setWidth(const QString& _width) { width = _width; }
67 inline void setType(int _type) { type = _type;}
68 inline void setType(const QString& _type) { type = typeFromString(_type);}
69 void setPurpose(int _purpose);
70 void setDirection(int _direction);
71 void setLevel(int _level);
74 virtual bool isReferenceInterface();
75 virtual bool isFunctionalInterface();
76 virtual bool isGroupInterface();
77 //virtual bool isConnectedTo() = 0;
78 //virtual bool isConnectedFrom() = 0;
79 //virtual bool canConnectTo(AbstractInterface* iface) = 0; // returns yes if this can be connected to iface, no if not
80 //virtual bool canConnectFrom(AbstractInterface* iface) = 0; // returns yes if this can be connected from iface, no if not
83 virtual AbstractInterface *clone() = 0;
85 //virtual bool addConnectedTo(AbstractInterface *inter) = 0;
86 //virtual void removeConnectedTo(AbstractInterface *inter) = 0;
87 //virtual bool setConnectedFrom(AbstractInterface* inter) = 0;
88 //virtual void clearConnectedTo() = 0;
89 //virtual void clearConnections() = 0;
90 //virtual void connectionsValidation(QStack<AbstractInterface*> *interfacetoValidate, QList<AbstractInterface*> *validatedInterfaces) throw(Exception) = 0;
91 int typeFromString(const QString &_type);
93 QString toVHDL(int context, int flags) throw(Exception);
103 AbstractBlock* owner;
107 #endif // __ABSTRACTINTERFACE_H__