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

Private GIT Repository
begun integration of control ifaces
[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, const QString&_type,
11                                        const QString& _width,
12                                        int _direction,
13                                        int _purpose,
14                                        int _multiplicity)
15 throw (Exception) : AbstractInterface(_owner, _name, _type, _width, _direction, _purpose) {
16
17   if (_owner->isReferenceBlock()) throw(Exception(BLOCK_INVALID_TYPE));
18
19   multiplicity = _multiplicity;
20   if (direction == InOut) {
21     multiplicity = 1;
22   }
23 }
24
25 bool ReferenceInterface::isReferenceInterface() {
26   return true;
27 }
28
29 void ReferenceInterface::setMultiplicity(int _multiplicity) {
30   if (direction == InOut) {
31     multiplicity = 1;
32   }
33   else {
34     multiplicity = _multiplicity;
35   }
36 }
37
38 int ReferenceInterface::translatePurpose(const QString& txt) {
39   if (txt == "clock") {
40     return Clock;
41   }
42   else if (txt == "reset") {
43     return Reset;
44   }
45   if (txt == "wb") {
46     return Wishbone;
47   }
48   return Data;
49 }
50
51 int ReferenceInterface::translateMultiplicity(const QString& txt) {
52   bool ok;
53   int mult;
54   if (txt == "*") {
55     mult = -1;
56   }
57   else {
58     mult = txt.toInt(&ok);
59     if (!ok) {
60       mult = 1;
61     }
62   }
63   return mult;
64 }