]> AND Private Git Repository - blast.git/blob - ReferenceInterface.cpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
finished VHDL gen. (but have to test further
[blast.git] / ReferenceInterface.cpp
1 #include "ReferenceInterface.h"
2 #include "AbstractBlock.h"
3
4 ReferenceInterface::ReferenceInterface(AbstractBlock* _owner)  throw(Exception) : AbstractInterface(_owner) {
5   if (_owner->isReferenceBlock()) throw(Exception(BLOCK_INVALID_TYPE));
6   multiplicity = 1;
7 }
8
9 ReferenceInterface::ReferenceInterface(AbstractBlock* _owner,
10                                        const QString& _name,
11                                        int _direction,
12                                        int _purpose,
13                                        const QString& _type,
14                                        const QString& _width,
15                                        int _endianess,
16                                        int _multiplicity)
17 throw (Exception) : AbstractInterface(_owner, _name, _direction, _purpose, _type, _width) {
18
19   if (_owner->isReferenceBlock()) throw(Exception(BLOCK_INVALID_TYPE));
20
21   multiplicity = _multiplicity;
22   
23   if (purpose == Control) {
24     // override some attributes with forced values
25     type = Boolean;
26     width = "1";
27     multiplicity = 1;
28   }  
29   if (direction == InOut) {
30     multiplicity = 1;
31   }
32 }
33
34 bool ReferenceInterface::isReferenceInterface() {
35   return true;
36 }
37
38 void ReferenceInterface::setMultiplicity(int _multiplicity) {
39   if (direction == InOut) {
40     multiplicity = 1;
41   }
42   else {
43     multiplicity = _multiplicity;
44   }
45 }
46
47 int ReferenceInterface::translatePurpose(const QString& txt) {
48   if (txt == "clock") {
49     return Clock;
50   }
51   else if (txt == "reset") {
52     return Reset;
53   }
54   else if (txt == "wb") {
55     return Wishbone;
56   }  
57   return Data;
58 }
59
60 int ReferenceInterface::translateMultiplicity(const QString& txt) {
61   bool ok;
62   int mult;
63   if (txt == "*") {
64     mult = -1;
65   }
66   else {
67     mult = txt.toInt(&ok);
68     if (!ok) {
69       mult = 1;
70     }
71   }
72   return mult;
73 }