1 #ifndef __ABSTRACTBLOCK_H__
\r
2 #define __ABSTRACTBLOCK_H__
\r
9 #include "AbstractInterface.h"
\r
10 class AbstractInterface;
\r
11 class BlockParameter;
\r
13 #define AB_TO_REF(ptr) ((ReferenceBlock*)ptr)
\r
14 #define AB_TO_FUN(ptr) ((FunctionalBlock*)ptr)
\r
15 #define AB_TO_GRP(ptr) ((GroupBlock*)ptr)
\r
17 using namespace std;
\r
20 class AbstractBlock {
\r
24 enum BlockVHDLContext {AnyContext = 0, Entity = 1, Component = 2, Architecture = 3 }; // NB : 3 is when creating an instance of the block that owns this iface
\r
27 //AbstractBlock(const QString& _name);
\r
28 virtual ~AbstractBlock();
\r
31 inline QString getName() { return name; }
\r
32 inline int nbParameters() { return params.size(); }
\r
33 inline QList<BlockParameter *> getParameters() { return params; }
\r
34 inline QList<AbstractInterface*> getInputs() { return inputs; }
\r
35 inline QList<AbstractInterface*> getOutputs() { return outputs; }
\r
36 inline QList<AbstractInterface*> getBidirs() { return bidirs; }
\r
37 QList<BlockParameter *> getUserParameters();
\r
38 QList<BlockParameter *> getGenericParameters();
\r
39 QList<BlockParameter *> getPortParameters();
\r
40 QList<BlockParameter *> getWishboneParameters();
\r
41 inline AbstractBlock* getParent() { return parent; }
\r
42 inline bool getPatternComputed() { return patternComputed; }
\r
43 inline int getTraversalLevel() { return traversalLevel; }
\r
46 void setName(const QString& str);
\r
47 virtual void setParent(AbstractBlock* _parent);
\r
48 inline void setPatternComputed(bool state) { patternComputed = state; }
\r
49 inline void resetTraversalLevel() { traversalLevel = -1; }
\r
50 inline void setTraversalLevel(int level) { traversalLevel = level; }
\r
53 virtual bool isReferenceBlock();
\r
54 virtual bool isFunctionalBlock();
\r
55 virtual bool isGroupBlock();
\r
56 virtual bool isSourceBlock(); //! a source block is outside the top group and simulates a peripheral (NB: this is also a generator)
\r
57 virtual bool isTopGroupBlock();
\r
58 bool isGeneratorBlock(); //! a generator block has no data inputs and thus executes infinitely
\r
59 bool isWBConfigurable();
\r
62 void connectClkReset() throw(Exception);
\r
64 virtual void generateVHDL(const QString& path) throw(Exception) = 0; // main entry to generate the VHDL code
\r
65 void generateComponent(QTextStream& out, bool hasController=false) throw(Exception); // generate the component using reference
\r
66 void generateEntity(QTextStream& out, bool hasController=false) throw(Exception); // generate the entity using reference
\r
68 virtual void parametersValidation(QList<AbstractBlock*>* checkedBlocks, QList<AbstractBlock*>* blocksToConfigure) = 0; // ugly but usefull
\r
70 void addParameter(BlockParameter *param);
\r
71 void addInterface(AbstractInterface *inter);
\r
72 void removeInterface(AbstractInterface *inter);
\r
73 void removeAllInterfaces();
\r
74 void defineBlockParam(BlockParameter *param);
\r
76 QList<AbstractInterface *> getInterfaces(int direction = AbstractInterface::AnyDirection, int purpose = AbstractInterface::AnyPurpose);
\r
77 QList<AbstractInterface *> getDataInputs(); //! return all inputs of type data
\r
78 QList<AbstractInterface *> getDataOutputs(); //! return all inputs of type data
\r
79 QList<AbstractInterface *> getControlInputs(); //! return all inputs of type control
\r
80 QList<AbstractInterface *> getControlOutputs(); //! return all outputs of type control
\r
81 AbstractInterface* getIfaceFromName(QString name);
\r
82 BlockParameter* getParameterFromName(QString name);
\r
85 virtual void checkInputPatternCompatibility() throw(Exception) = 0;
\r
86 virtual void computeOutputPattern(int nbExec = -1) throw(Exception) = 0;
\r
87 virtual void computeAdmittanceDelays() throw(Exception) = 0;
\r
95 QList<BlockParameter *> params;
\r
98 QList<AbstractInterface*> inputs;
\r
99 QList<AbstractInterface*> outputs;
\r
100 QList<AbstractInterface*> bidirs;
\r
105 bool patternComputed;
\r
106 int traversalLevel; // the level (0, 1, ...) during the traversal of the graph
\r
108 // NB: only GroupBlock and FunctionalBlock have a real parent, except sources that have no parents
\r
109 AbstractBlock* parent;
\r
111 virtual void generateComments(QTextStream& out, QDomElement &elt, QString coreFile) throw(Exception) = 0; // generates comments from <comments> element
\r
112 virtual void generateLibraries(QTextStream& out, QDomElement &elt) throw(Exception) = 0; // generates libraries from <libraries> element
\r
113 virtual void generateArchitecture(QTextStream& out, QDomElement &elt ) throw(Exception) = 0; // generate the architecture using <architecture> element
\r
114 virtual void generateController(QTextStream& out) throw(Exception) = 0; // generate the wishbone controller of the block
\r
115 virtual void generateEntityOrComponentBody(QTextStream& out, int indentLevel, bool hasController=false) throw(Exception) = 0; // generate the entity/compo body using reference
\r
119 #endif // __ABSTRACTBLOCK_H__
\r