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
25 //AbstractBlock(const QString& _name);
\r
26 virtual ~AbstractBlock();
\r
29 inline QString getName() { return name; }
\r
30 inline int nbParameters() { return params.size(); }
\r
31 inline QList<BlockParameter *> getParameters() { return params; }
\r
32 inline QList<AbstractInterface*> getInputs() { return inputs; }
\r
33 inline QList<AbstractInterface*> getOutputs() { return outputs; }
\r
34 inline QList<AbstractInterface*> getBidirs() { return bidirs; }
\r
35 QList<BlockParameter *> getUserParameters();
\r
36 QList<BlockParameter *> getGenericParameters();
\r
37 QList<BlockParameter *> getPortParameters();
\r
38 QList<BlockParameter *> getWishboneParameters();
\r
39 inline AbstractBlock* getParent() { return parent; }
\r
40 inline bool getPatternComputed() { return patternComputed; }
\r
41 inline int getTraversalLevel() { return traversalLevel; }
\r
44 void setName(const QString& str);
\r
45 virtual void setParent(AbstractBlock* _parent);
\r
46 inline void setPatternComputed(bool state) { patternComputed = state; }
\r
47 inline void resetTraversalLevel() { traversalLevel = -1; }
\r
48 inline void setTraversalLevel(int level) { traversalLevel = level; }
\r
51 virtual bool isReferenceBlock();
\r
52 virtual bool isFunctionalBlock();
\r
53 virtual bool isGroupBlock();
\r
54 virtual bool isSourceBlock(); //! a source block is outside the top group and simulates a peripheral (NB: this is also a generator)
\r
55 virtual bool isTopGroupBlock();
\r
56 bool isGeneratorBlock(); //! a generator block has no data inputs and thus executes infinitely
\r
57 bool isWBConfigurable();
\r
60 void connectClkReset() throw(Exception);
\r
62 virtual void generateVHDL(const QString& path) throw(Exception) = 0; // main entry to generate the VHDL code
\r
65 virtual void parametersValidation(QList<AbstractBlock*>* checkedBlocks, QList<AbstractBlock*>* blocksToConfigure) = 0; // ugly but usefull
\r
67 void addParameter(BlockParameter *param);
\r
68 void addInterface(AbstractInterface *inter);
\r
69 void removeInterface(AbstractInterface *inter);
\r
70 void removeAllInterfaces();
\r
71 void defineBlockParam(BlockParameter *param);
\r
73 QList<AbstractInterface *> getInterfaces(int direction = AbstractInterface::AnyDirection, int purpose = AbstractInterface::AnyPurpose);
\r
74 QList<AbstractInterface *> getDataInputs(); //! return all inputs of type data
\r
75 QList<AbstractInterface *> getDataOutputs(); //! return all inputs of type data
\r
76 QList<AbstractInterface *> getControlInputs(); //! return all inputs of type control
\r
77 QList<AbstractInterface *> getControlOutputs(); //! return all outputs of type control
\r
78 AbstractInterface* getIfaceFromName(QString name);
\r
79 BlockParameter* getParameterFromName(QString name);
\r
82 virtual void checkInputPatternCompatibility() throw(Exception) = 0;
\r
83 virtual void computeOutputPattern(int nbExec = -1) throw(Exception) = 0;
\r
84 virtual void computeAdmittanceDelays() throw(Exception) = 0;
\r
92 QList<BlockParameter *> params;
\r
95 QList<AbstractInterface*> inputs;
\r
96 QList<AbstractInterface*> outputs;
\r
97 QList<AbstractInterface*> bidirs;
\r
102 bool patternComputed;
\r
103 int traversalLevel; // the level (0, 1, ...) during the traversal of the graph
\r
105 // NB: only GroupBlock and FunctionalBlock have a real parent, except sources that have no parents
\r
106 AbstractBlock* parent;
\r
108 virtual void generateComments(QTextStream& out, QDomElement &elt, QString coreFile) throw(Exception) = 0; // generates comments from <comments> element
\r
109 virtual void generateLibraries(QTextStream& out, QDomElement &elt) throw(Exception) = 0; // generates libraries from <libraries> element
\r
110 virtual void generateEntity(QTextStream& out, bool hasController=false) throw(Exception) = 0; // generate the entity using reference
\r
111 virtual void generateArchitecture(QTextStream& out, QDomElement &elt ) throw(Exception) = 0; // generate the architecture using <architecture> element
\r
112 virtual void generateController(QTextStream& out) throw(Exception) = 0; // generate the wishbone controller of the block
\r
116 #endif // __ABSTRACTBLOCK_H__
\r