1 #include "ReferenceInterface.h"
2 #include "AbstractBlock.h"
3 #include "BlockParameter.h"
5 ReferenceInterface::ReferenceInterface(AbstractBlock* _owner) throw(Exception) : AbstractInterface(_owner) {
6 if (_owner->isReferenceBlock()) throw(Exception(BLOCK_INVALID_TYPE));
10 ReferenceInterface::ReferenceInterface(AbstractBlock* _owner,
15 const QString& _width,
18 throw (Exception) : AbstractInterface(_owner, _name, _direction, _purpose, _type, _width) {
20 if (_owner->isReferenceBlock()) throw(Exception(BLOCK_INVALID_TYPE));
22 multiplicity = _multiplicity;
24 if (purpose == Control) {
25 // override some attributes with forced values
30 if (direction == InOut) {
35 bool ReferenceInterface::isReferenceInterface() {
39 void ReferenceInterface::setMultiplicity(int _multiplicity) {
40 if (direction == InOut) {
44 multiplicity = _multiplicity;
48 int ReferenceInterface::translatePurpose(const QString& txt) {
52 else if (txt == "reset") {
55 else if (txt == "wb") {
61 int ReferenceInterface::translateMultiplicity(const QString& txt) {
68 mult = txt.toInt(&ok);
76 int ReferenceInterface::getClockDomain() throw(Exception) {
78 throw(Exception(IFACE_INVALID_TYPE,this));
81 /* NOTE on clock associated to each interface:
83 Each interface must be associated to a clock so that blast can determine
84 if there are no problems with clocks domains. This clock must correspond to
85 the name of a clock interface owned by the same block or to a user parameter
86 for which the value indicate the clock frequency. This latter case is used only
87 for input interfaces of blocks that will be directly linked to the outside of top group
88 (NB: directly only means that there are no others functional blocks between the
89 mentionnned block and the outside, but it can be within subgroups) and with these interfaces
90 that receives a data signal synchronized on an outside clock that is not provided to the design.
91 For example, on the APF27 board, there is a link between imx and spartan 3 and signals are at 133MHz.
92 But there is no clock provided to the FPGA.
94 Reference blocks are created with:
95 - input clocks are associated to themselves.
96 - output clocks are associated to one of the clock.
97 - reset are associated to one of the clock (since they are generated
98 by clkrstgen, they are really synchronized with a clock)
99 - all other signals are associated to one of the clock or to a parameter
100 The name of the associated clock is given in the xml description file. If not
101 indicated it is by default the name of the input clock. In case of there are
102 several input clocks, the xml is incoherent if other signal do not indicate the name of
103 the associated clock.
105 Functional block are created by cloning a reference thus they follow the same rules as
108 A group is created with interfaces that have an inherited clock name thus, setting a name
109 is meaningless and an iterative process must be used to retrieve the clock domain from
110 the interface that is connected from the group interface (cf. GroupBlock::getClockDomain())
112 The following method checks if these rules are applied correctly.
115 bool ReferenceInterface::checkSetClockIface(QString _name) {
118 - this is a clock input: name must be the same as the iface name
119 - this is an output clock or reset: name must be an existing clock name.
120 - other cases: name must ba a parameter name or an exisiting clock name
122 NB: if it's a parameter it must be prepend with a $.
124 if ((purpose == Clock) && (direction == Input)) {
126 clkIfaceName = _name;
127 clkIfaceType = ClockName;
131 else if ((purpose == Reset) || ((purpose == Clock) && (direction == Output))) {
132 QList<AbstractInterface*> clocks = owner->getInterfaces(Input, Clock);
133 foreach(AbstractInterface* iface, clocks) {
134 if (iface->getName() == _name) {
135 clkIfaceName = _name;
136 clkIfaceType = ClockName;
142 if (_name.at(0) == '$') {
144 QList<BlockParameter* > params = owner->getUserParameters();
145 foreach(BlockParameter* p, params) {
146 if (p->getName() == _name) {
147 clkIfaceName = _name;
148 clkIfaceType = ParameterName;
154 QList<AbstractInterface*> clocks = owner->getInterfaces(Input, Clock);
155 foreach(AbstractInterface* iface, clocks) {
156 if (iface->getName() == _name) {
157 clkIfaceName = _name;
158 clkIfaceType = ClockName;
165 clkIfaceType = NoName;