1 #include "SpecialBlock.h"
\r
2 #include "FunctionalInterface.h"
\r
4 SpecialBlock::SpecialBlock(Graph *_graph, int _type, GroupBlock* _parent, ReferenceBlock* _reference, bool createIfaces) throw(Exception) : FunctionalBlock(_graph, _parent, _reference, createIfaces) {
\r
8 SpecialBlock::~SpecialBlock() {
\r
11 bool SpecialBlock::isSpecialBlock() {
\r
15 void SpecialBlock::checkInputPatternCompatibility() throw(Exception) {
\r
17 switch(specialType) {
\r
19 checkInputPatternCompatibilitySource();
\r
22 checkInputPatternCompatibilitySink();
\r
25 checkInputPatternCompatibilityClockConvert();
\r
31 catch(Exception e) {
\r
36 void SpecialBlock::computeOutputPattern(int nbExec) throw(Exception) {
\r
38 switch(specialType) {
\r
40 computeOutputPatternSource(nbExec);
\r
43 computeOutputPatternSink(nbExec);
\r
46 computeOutputPatternClockConvert(nbExec);
\r
52 catch(Exception e) {
\r
57 void SpecialBlock::checkInputPatternCompatibilitySource() throw(Exception) {
\r
59 void SpecialBlock::computeOutputPatternSource(int nbExec) throw(Exception) {
\r
61 cout << "computing output pattern of special block " << qPrintable(name) << " for " << nbExec << " executions" << endl;
\r
62 foreach(AbstractInterface* iface, getControlOutputs()) {
\r
63 FunctionalInterface* connIface = AI_TO_FUN(iface);
\r
64 // create output pattern
\r
65 QList<char>* pp = productionPattern.value(connIface);
\r
66 QList<char>* pattern = new QList<char>(*pp);
\r
67 for(int i=1;i<nbExec;i++) pattern->append(*pp);
\r
68 // assign pattern to interface
\r
69 connIface->setOutputPattern(pattern);
\r
71 outputPattern.insert(connIface,pattern);
\r
73 setOutputPatternComputed(true);
\r
76 void SpecialBlock::checkInputPatternCompatibilitySink() throw(Exception) {
\r
78 void SpecialBlock::computeOutputPatternSink(int nbExec) throw(Exception) {
\r
81 void SpecialBlock::checkInputPatternCompatibilityClockConvert() throw(Exception) {
\r
82 static QString fctName = "SpecialBlock::checkInputPatternCompatibilityClockConvert()";
\r
83 #ifdef DEBUG_FCTNAME
\r
84 cout << "call to " << qPrintable(fctName) << endl;
\r
86 // just create input pattern
\r
88 createInputPattern();
\r
90 catch(Exception e) {
\r
95 void SpecialBlock::computeOutputPatternClockConvert(int nbExec) throw(Exception) {
\r
96 static QString fctName = "SpecialBlock::computeOutputPatternClockConvert()";
\r
97 #ifdef DEBUG_FCTNAME
\r
98 cout << "call to " << qPrintable(fctName) << endl;
\r
100 cout << "computing output pattern of special block " << qPrintable(name) << endl;
\r
102 /* CAUTION: it is assumed that all clock domain converters are using
\r
103 * a clk_in and clk_out signals for input and output clocks.
\r
105 AbstractInterface* clkIn = getIfaceFromName("clk_in");
\r
106 AbstractInterface* clkOut = getIfaceFromName("clk_out");
\r
107 cout << "freq clk_in = " << clkIn->getClockFrequency() << endl;
\r
108 cout << "freq clk_out = " << clkOut->getClockFrequency() << endl;
\r
110 // in case of inputPattern not created, do it
\r
111 if (lengthIP <= 0) {
\r
113 cout << "Strange case: input pattern is not created while it is time to compute output pattern !" << endl;
\r
114 // collect the input patterns for each input
\r
116 createInputPattern();
\r
118 catch(Exception e) {
\r
121 cout << "input pattern array initialized with min. len " << lengthIP << endl;
\r
124 // initialize the output pattern
\r
126 foreach(AbstractInterface* iface, getControlOutputs()) {
\r
127 FunctionalInterface* connIface = AI_TO_FUN(iface);
\r
128 lengthOP = lengthIP+productionPattern.value(connIface)->size();
\r
129 QList<char>* pattern = new QList<char>();
\r
130 for(int i=0;i<lengthOP;i++) pattern->append(0);
\r
131 connIface->setOutputPattern(pattern);
\r
132 outputPattern.insert(connIface,pattern);
\r
134 cout << "output pattern array initialized" << endl;
\r