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 IfaceWidthDir { LittleEndian = 1, BigEndian}; //! LittleEndian = X downto 0, BigEndian = 0 to X
29 enum IfacePurpose { AnyPurpose = 0, Data = 1, Control, Clock, Reset, Wishbone };
30 enum IfaceDirection { AnyDirection = 0, Input = 1, Output = 2, InOut = 3 };
31 enum IfaceVHDLContext {AnyContext = 0, Entity = 1, Component = 2, Instance = 3, Signal = 4 };
32 enum IfaceVHDLFlags { NoComma = 1 };
33 enum IfaceClockName { NoName = 0, ClockName, ParameterName, InheritedName };
35 static int getIntDirection(QString str);
36 static int getIntPurpose(QString str);
38 AbstractInterface(AbstractBlock* _owner);
39 AbstractInterface(AbstractBlock* _owner, const QString& _name, int _direction, int _purpose, const QString& _type, const QString& _width, int _endianess = LittleEndian);
40 AbstractInterface(AbstractInterface* other);
41 virtual ~AbstractInterface();
44 inline QString getName() { return name;}
45 inline int getType() { return type; }
46 QString getTypeString();
47 inline int getEndianess() { return endianess; }
48 QString getEndianessString();
49 inline QString getWidthString() { return width;}
50 virtual int getWidth(); // return -1 if size cannot be determine
51 inline int getPurpose() { return purpose;}
52 QString getPurposeString();
53 inline int getDirection() { return direction;}
54 QString getDirectionString();
55 inline AbstractBlock *getOwner() { return owner;}
56 inline AbstractInterface* getAssociatedIface() { return associatedIface; }
57 inline QString getClockIfaceString() { return clkIfaceName; }
58 inline int getClockIfaceType() { return clkIfaceType; }
59 AbstractInterface* getClockIface();
60 virtual int getClockDomain() throw(Exception) = 0; // determine on which clock domain is sync this interface
61 double getClockFrequency() throw(Exception);
65 inline void setOwner(AbstractBlock* _owner) { owner = _owner; }
66 void setName(const QString& _name);
67 inline void setWidth(const QString& _width) { width = _width; }
68 inline void setType(int _type) { type = _type;}
69 inline void setEndianess(int _endianess) { endianess = _endianess;}
70 inline void setType(const QString& _type) { type = typeFromString(_type);}
71 void setPurpose(int _purpose);
72 void setDirection(int _direction);
73 bool setAssociatedIface(AbstractInterface* iface);
74 inline void setClockIfaceType(int type) { clkIfaceType = type; }
75 inline void setClockIfaceName(QString name) { clkIfaceName = name; }
78 virtual bool isReferenceInterface();
79 virtual bool isFunctionalInterface();
80 virtual bool isGroupInterface();
83 virtual AbstractInterface *clone() = 0;
85 int typeFromString(const QString &_type);
87 QString toVHDL(IfaceVHDLContext context, int flags) throw(Exception);
99 * \brief associatedIface the control (resp. data) interface that is bounded to this data (resp. control) interface
100 * If a reference block is designed to be fully integrated in Blast, nearly every data interface is bounded
101 * to a control interface that signals if the value presented on the interface is valid or not. associatedIface
102 * references this control interface if this is a data interface, and a data interface is this is a control interface.
103 * Note that the association is done by the call of setAssociatedIface() that must be done only for a control interface.
104 * (NB: a test is done in the method to prevent the other case).
106 AbstractInterface* associatedIface;
108 * \brief clkIface represents the clock interface that is used in processes modifying this interface. It is only relevant for
109 * Data interfaces and clock outputs (that comes from a clkrstgen). Since Control interfaces are automatically associated to a
110 * Data interface, clkIface is "" for them. Wishbone interfaces
111 * In general, blocks have a single
112 * clock interface which is by default automatically connected to the main clock dispatched by the clkrstgen block in top group.
113 * Nevertheless, the designer has the possibility to connect the block taht owns this interface to another clkrstgen block. Moreover,
114 * some blocks may have several clocks, e.g. dual port RAMs, FIFOs.
116 QString clkIfaceName;
117 int clkIfaceType; // 0 for not affected, 1 for clock input name, 2 for user param name
123 #endif // __ABSTRACTINTERFACE_H__