1 #ifndef __BLOCKIMPLEMENTATION_H__
\r
2 #define __BLOCKIMPLEMENTATION_H__
\r
10 class ReferenceBlock;
\r
11 class FunctionalBlock;
\r
12 class AbstractInterface;
\r
14 #include "ArithmeticEvaluator.h"
\r
15 class ArithmeticEvaluator;
\r
17 #include "Exception.h"
\r
21 using namespace std;
\r
24 class BlockImplementation {
\r
28 BlockImplementation(const QString& _xmlFile);
\r
29 BlockImplementation(const QString& _xmlFile, const QString& _referenceXml, const QString& _referenceMd5);
\r
32 inline QString getXmlFile() { return xmlFile; }
\r
33 inline QString getReferenceXml() { return referenceXml; }
\r
34 inline QString getReferenceMd5() { return referenceMd5; }
\r
35 inline QString getDelta() { return delta; }
\r
36 inline QHash<QString,QString> getConsumptionPattern() { return consumptionPattern; }
\r
37 inline QHash<QString,QString> getProductionPattern() { return productionPattern; }
\r
38 inline QString getProductionCounter() { return productionCounter; }
\r
40 inline void setDelta(QString _delta) { delta = _delta; }
\r
41 inline void setConsumptionPattern(QHash<QString,QString> pattern) { consumptionPattern = pattern; }
\r
42 inline void setProductionPattern(QHash<QString,QString> pattern) { productionPattern = pattern; }
\r
43 inline void setProductionCounter(QString pattern) { productionCounter = pattern; }
\r
45 QString eval(QString line, QTextStream& out);
\r
46 QString evalComplex(QString line, int num);
\r
47 QString evalString(QString s);
\r
48 QList<AbstractInterface*>* evalStringComplex(QString s);
\r
49 QString evalValue(QString s);
\r
50 QString calculateWidth(QString s);
\r
52 inline void setReference(ReferenceBlock* _reference) { reference = _reference; }
\r
54 void loadPatterns(QDomElement &root) throw(Exception);
\r
55 bool checkPatterns();
\r
56 void generateVHDL(FunctionalBlock* _block, const QString& path) throw(Exception); // main entry to generate the VHDL code
\r
61 QString referenceXml;
\r
62 QString referenceMd5;
\r
63 QString nameEnt, line;
\r
64 QMap<QString, int> paramMap;
\r
65 ArithmeticEvaluator* evaluator;
\r
66 ReferenceBlock* reference;
\r
67 FunctionalBlock* block; // the current functional block for which this implementation is used.
\r
69 QHash<QString,QString> consumptionPattern; // key = reference interface name, value = pattern expression
\r
70 QHash<QString,QString> productionPattern; // key = reference interface name, value = pattern expression
\r
71 QString productionCounter;
\r
73 void generateComments(QTextStream& out, QDomElement &elt, QString coreFile) throw(Exception); // generates comments from <comments> element
\r
74 void generateLibraries(QTextStream& out, QDomElement &elt) throw(Exception); // generates libraries from <libraries> element
\r
75 void generateEntity(QTextStream& out, bool hasController=false) throw(Exception); // generate the entity using reference
\r
76 void generateArchitecture(QTextStream& out, QDomElement &elt ) throw(Exception); // generate the architecture using <architecture> element
\r
77 void generateController(QTextStream& out) throw(Exception); // generate the wishbone controller of the block
\r
79 QString getIfaceUserName(AbstractInterface* refIface); // get the name of an interface given by the user, from the reference interface
\r
81 friend QDataStream &operator<<(QDataStream &out, const BlockImplementation &impl);
\r
82 friend QDataStream &operator>>(QDataStream &in, BlockImplementation &impl);
\r
85 #endif // __BLOCKIMPLEMENTATION_H__
\r