1 #ifndef __ABSTRACTBLOCK_H__
\r
2 #define __ABSTRACTBLOCK_H__
\r
8 #include "AbstractInterface.h"
\r
9 class AbstractInterface;
\r
10 class BlockParameter;
\r
12 #define AB_TO_REF(ptr) ((ReferenceBlock*)ptr)
\r
13 #define AB_TO_FUN(ptr) ((FunctionalBlock*)ptr)
\r
14 #define AB_TO_GRP(ptr) ((GroupBlock*)ptr)
\r
16 using namespace std;
\r
19 class AbstractBlock {
\r
24 AbstractBlock(const QString& _name);
\r
25 virtual ~AbstractBlock();
\r
28 inline QString getName() { return name; }
\r
29 inline int nbParameters() { return params.size(); }
\r
30 inline QList<BlockParameter *> getParameters() { return params; }
\r
31 inline QList<AbstractInterface*> getInputs() { return inputs; }
\r
32 inline QList<AbstractInterface*> getOutputs() { return outputs; }
\r
33 inline QList<AbstractInterface*> getBidirs() { return bidirs; }
\r
34 QList<BlockParameter *> getUserParameters();
\r
35 QList<BlockParameter *> getGenericParameters();
\r
36 QList<BlockParameter *> getPortParameters();
\r
37 QList<BlockParameter *> getWishboneParameters();
\r
38 inline AbstractBlock* getParent() { return parent; }
\r
39 inline QList<int> getProductionCounter() { return productionCounter; }
\r
40 inline int getDelta() { return delta; }
\r
43 void setName(const QString& str);
\r
44 virtual void setParent(AbstractBlock* _parent);
\r
45 inline void setProductionCounter(QList<int> pattern) { productionCounter = pattern; }
\r
46 inline void setDelta(int _delta) { delta = _delta; }
\r
47 inline void setPatternComputed(bool state) { patternComputed = state; }
\r
50 virtual bool isReferenceBlock();
\r
51 virtual bool isFunctionalBlock();
\r
52 virtual bool isGroupBlock();
\r
53 virtual bool isSourceBlock(); //! a source block is outside the top group and simulates a peripheral (NB: this is also a generator)
\r
54 virtual bool isTopGroupBlock();
\r
55 bool isGeneratorBlock(); //! a generator block has no data inputs and thus executes infinitely
\r
56 bool isWBConfigurable();
\r
59 virtual void parametersValidation(QList<AbstractBlock*>* checkedBlocks, QList<AbstractBlock*>* blocksToConfigure) = 0; // ugly but usefull
\r
61 void addParameter(BlockParameter *param);
\r
62 void addInterface(AbstractInterface *inter);
\r
63 void removeInterface(AbstractInterface *inter);
\r
64 void removeAllInterfaces();
\r
65 void defineBlockParam(BlockParameter *param);
\r
67 QList<AbstractInterface *> getInterfaces(int direction = AbstractInterface::AnyDirection, int purpose = AbstractInterface::AnyPurpose);
\r
68 QList<AbstractInterface *> getDataInputs(); //! return all inputs of type data
\r
69 QList<AbstractInterface *> getDataOutputs(); //! return all inputs of type data
\r
70 QList<AbstractInterface *> getControlInputs(); //! return all inputs of type control
\r
71 QList<AbstractInterface *> getControlOutputs(); //! return all outputs of type control
\r
72 AbstractInterface* getIfaceFromName(QString name);
\r
73 BlockParameter* getParameterFromName(QString name);
\r
76 virtual bool computeOutputPattern(int nbExec = -1) = 0;
\r
84 QList<BlockParameter *> params;
\r
87 QList<AbstractInterface*> inputs;
\r
88 QList<AbstractInterface*> outputs;
\r
89 QList<AbstractInterface*> bidirs;
\r
94 QList<int> productionCounter; //! only usefull for output interfaces
\r
96 bool patternComputed;
\r
98 // NB: only GroupBlock and FunctionalBlock have a real parent, except sources that have no parents
\r
99 AbstractBlock* parent;
\r
102 #endif // __ABSTRACTBLOCK_H__
\r