1 #include "SpecialBlock.h"
\r
2 #include "FunctionalInterface.h"
\r
4 SpecialBlock::SpecialBlock(int _type, GroupBlock* _parent, ReferenceBlock* _reference, bool createIfaces) throw(Exception) : FunctionalBlock(_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 " << 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 " << 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-
\r
109 // in case of inputPattern not created, do it
\r
110 if (lengthIP <= 0) {
\r
112 cout << "Strange case: input pattern is not created while it is time to compute output pattern !" << endl;
\r
113 // collect the input patterns for each input
\r
115 createInputPattern();
\r
117 catch(Exception e) {
\r
120 cout << "input pattern array initialized with min. len " << lengthIP << endl;
\r
123 // initialize the output pattern
\r
125 foreach(AbstractInterface* iface, getControlOutputs()) {
\r
126 FunctionalInterface* connIface = AI_TO_FUN(iface);
\r
127 lengthOP = lengthIP+productionPattern.value(connIface)->size();
\r
128 QList<char>* pattern = new QList<char>();
\r
129 for(int i=0;i<lengthOP;i++) pattern->append(0);
\r
130 connIface->setOutputPattern(pattern);
\r
131 outputPattern.insert(connIface,pattern);
\r
133 cout << "output pattern array initialized" << endl;
\r