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, 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;}
50 double getDoubleWidth() throw(QException);
52 //virtual QList<AbstractInterface*> getConnectedTo() = 0;
54 /* NB: only GroupInterface and FunctionalInterface have a connectedFrom, so
55 defining getConnectedFrom as pure virtual is normal, usefull even though it is ugly :-)
57 virtual AbstractInterface* getConnectedFrom() = 0;
60 inline void setOwner(AbstractBlock* _owner) { owner = _owner; }
61 inline void setName(const QString& _name) { name = _name; }
62 inline void setWidth(const QString& _width) { width = _width; }
63 inline void setType(int _type) { type = _type;}
64 inline void setType(const QString& _type) { type = typeFromString(_type);}
65 void setPurpose(int _purpose);
66 void setDirection(int _direction);
69 virtual bool isReferenceInterface();
70 virtual bool isFunctionalInterface();
71 virtual bool isGroupInterface();
72 //virtual bool isConnectedTo() = 0;
73 //virtual bool isConnectedFrom() = 0;
74 //virtual bool canConnectTo(AbstractInterface* iface) = 0; // returns yes if this can be connected to iface, no if not
75 //virtual bool canConnectFrom(AbstractInterface* iface) = 0; // returns yes if this can be connected from iface, no if not
78 virtual AbstractInterface *clone() = 0;
80 //virtual bool addConnectedTo(AbstractInterface *inter) = 0;
81 //virtual void removeConnectedTo(AbstractInterface *inter) = 0;
82 //virtual bool setConnectedFrom(AbstractInterface* inter) = 0;
83 //virtual void clearConnectedTo() = 0;
84 //virtual void clearConnections() = 0;
85 //virtual void connectionsValidation(QStack<AbstractInterface*> *interfacetoValidate, QList<AbstractInterface*> *validatedInterfaces) throw(Exception) = 0;
86 int typeFromString(const QString &_type);
88 QString toVHDL(int context, int flags) throw(Exception);
101 #endif // __ABSTRACTINTERFACE_H__