From: stephane Domas Date: Fri, 5 May 2017 12:30:12 +0000 (+0200) Subject: added creation of control ifaces X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/commitdiff_plain/dd3fe103df79a5a4c2962e2f05fec9a9ed58580d?ds=sidebyside added creation of control ifaces --- diff --git a/AbstractInterface.cpp b/AbstractInterface.cpp index e651f58..dde5930 100644 --- a/AbstractInterface.cpp +++ b/AbstractInterface.cpp @@ -10,6 +10,7 @@ AbstractInterface::AbstractInterface(AbstractBlock* _owner) { direction = Input; purpose = Data; type = Boolean; + associatedIface = NULL; } @@ -21,6 +22,7 @@ AbstractInterface::AbstractInterface(AbstractBlock* _owner, const QString& _name direction = _direction; purpose = _purpose; type = typeFromString(_type); + associatedIface = NULL; } AbstractInterface::AbstractInterface(AbstractInterface* other) { @@ -30,6 +32,7 @@ AbstractInterface::AbstractInterface(AbstractInterface* other) { width = other->width; direction = other->direction; purpose = other->purpose; + associatedIface = NULL; } AbstractInterface::~AbstractInterface() { @@ -126,6 +129,14 @@ void AbstractInterface::setDirection(int _direction) { } } +bool AbstractInterface::setAssociatedIface(AbstractInterface* iface) { + if (purpose != Control) return false; + if (iface->purpose != Data) return false; + associatedIface = iface; + iface->associatedIface = this; + return true; +} + int AbstractInterface::getIntDirection(QString str) { if(str == "input") return Input; diff --git a/AbstractInterface.h b/AbstractInterface.h index 5c0b83a..29be729 100644 --- a/AbstractInterface.h +++ b/AbstractInterface.h @@ -46,6 +46,7 @@ public : inline int getDirection() { return direction;} QString getDirectionString(); inline AbstractBlock *getOwner() { return owner;} + inline AbstractInterface* getAssociatedIface() { return associatedIface; } double getDoubleWidth() throw(QException); @@ -63,7 +64,8 @@ public : inline void setType(int _type) { type = _type;} inline void setType(const QString& _type) { type = typeFromString(_type);} void setPurpose(int _purpose); - void setDirection(int _direction); + void setDirection(int _direction); + bool setAssociatedIface(AbstractInterface* iface); // testers virtual bool isReferenceInterface(); @@ -95,6 +97,15 @@ protected: int direction; AbstractBlock* owner; + /*! + * \brief associatedIface the control (resp. data) interface that is bounded to this data (resp. control) interface + * If a reference block is designed to be fully integrated in Blast, nearly every data interface is bounded + * to a control interface that signals if the value presented on the interface is valid or not. associatedIface + * references this control interface if this is a data interface, and a data interface is this is a control interface. + * Note that the association is done by the call of setAssociatedIface() that must be done only for a control interface. + * (NB: a test is done in the method to prevent the other case). + */ + AbstractInterface* associatedIface; }; diff --git a/ConnectedInterface.h b/ConnectedInterface.h index 3a1fb4f..fc89e22 100644 --- a/ConnectedInterface.h +++ b/ConnectedInterface.h @@ -64,16 +64,7 @@ protected: * there may be a single interface owned by another block (functional or group) that is connected to * this interface. connecteFrom references such an interface if it exists. */ - ConnectedInterface* connectedFrom; - /*! - * \brief associatedIface the control (resp. data) interface that is bounded to this data (resp. control) interface - * If a reference block is designed to be fully integrated in Blast, nearly every data interface is bounded - * to a control interface that signals if the value presented on the interface is valid or not. associatedIface - * references this control interface if this is a data interface, and a data interface is this is a control interface. - * Note that the association is done by the call of setAssociatedIface() that must be done only for a control interface. - * (NB: a test is done in the method to prevent the other case). - */ - ConnectedInterface* associatedIface; + ConnectedInterface* connectedFrom; }; diff --git a/FunctionalBlock.cpp b/FunctionalBlock.cpp index f547084..cb8ceba 100644 --- a/FunctionalBlock.cpp +++ b/FunctionalBlock.cpp @@ -46,25 +46,44 @@ void FunctionalBlock::populate() { BlockParameter* p; AbstractInterface* inter; + // create parameters from reference block QList lstParam = reference->getParameters(); for(i=0;iclone(); addParameter(p); } - QList lstInter = reference->getInterfaces(); - for(i=0;i lstRef = reference->getInterfaces(); + // store relation between functional and reference + QHash hashIface; + for(i=0;igetPurpose() == AbstractInterface::Control) { + funCtlIface = hashIface.value(refIface); + funDataIface = hashIface.value(refIface->getAssociatedIface()); + if (! funCtlIface->setAssociatedIface(funDataIface)) { + cerr << "Abnormal case when associating a control interface to data" << endl << "Aborting execution." << endl; + exit(1); + } + } + } } diff --git a/FunctionalInterface.cpp b/FunctionalInterface.cpp index 1b8ff07..d34cc8d 100644 --- a/FunctionalInterface.cpp +++ b/FunctionalInterface.cpp @@ -20,7 +20,7 @@ FunctionalInterface::FunctionalInterface(AbstractBlock* _owner, ReferenceInterfa width = reference->getWidth(); direction = reference->getDirection(); purpose = reference->getPurpose(); - connectedFrom = NULL; + connectedFrom = NULL; } bool FunctionalInterface::isFunctionalInterface() { diff --git a/ReferenceBlock.cpp b/ReferenceBlock.cpp index 722fc12..e09b118 100644 --- a/ReferenceBlock.cpp +++ b/ReferenceBlock.cpp @@ -224,6 +224,7 @@ void ReferenceBlock::loadInterfaces(QDomElement &elt) throw(Exception) { if ((elt.isNull()) || (elt.tagName() != "interfaces")) throw (Exception(BLOCKFILE_CORRUPTED)); QDomElement eltInputs = elt.firstChildElement("inputs"); + // getting each input QDomNodeList listNodeInputs = eltInputs.elementsByTagName("input"); for(int i=0;igetName()+"_ctl"; + inter = new ReferenceInterface(this,nameStr,"boolean","1",AbstractInterface::Input, AbstractInterface::Control, 1); + if (!inter->setAssociatedIface(dataIface)) { + throw (Exception(BLOCKFILE_CORRUPTED)); + } + inputs.append(inter); + } QDomElement eltOutputs = eltInputs.nextSiblingElement("outputs"); QDomNodeList listNodeOutputs = eltOutputs.elementsByTagName("output"); for(int i=0;igetName()+"_ctl"; + inter = new ReferenceInterface(this,nameStr,"boolean","1",AbstractInterface::Output, AbstractInterface::Control, 1); + if (!inter->setAssociatedIface(dataIface)) { + throw (Exception(BLOCKFILE_CORRUPTED)); + } + outputs.append(inter); + } QDomElement eltBidirs = eltInputs.nextSiblingElement("bidirs"); QDomNodeList listNodeBidirs = eltBidirs.elementsByTagName("bidir"); diff --git a/ReferenceInterface.cpp b/ReferenceInterface.cpp index faa51e8..a0f50ca 100644 --- a/ReferenceInterface.cpp +++ b/ReferenceInterface.cpp @@ -17,6 +17,13 @@ throw (Exception) : AbstractInterface(_owner, _name, _type, _width, _direction, if (_owner->isReferenceBlock()) throw(Exception(BLOCK_INVALID_TYPE)); multiplicity = _multiplicity; + + if (purpose == Control) { + // override some attributes with forced values + type = Boolean; + width = "1"; + multiplicity = 1; + } if (direction == InOut) { multiplicity = 1; } @@ -42,9 +49,9 @@ int ReferenceInterface::translatePurpose(const QString& txt) { else if (txt == "reset") { return Reset; } - if (txt == "wb") { + else if (txt == "wb") { return Wishbone; - } + } return Data; } diff --git a/blast.creator.user b/blast.creator.user index 95c4b8a..570664a 100755 --- a/blast.creator.user +++ b/blast.creator.user @@ -1,10 +1,10 @@ - + EnvironmentId - {c8006d66-d34f-42be-ad10-d0207752286d} + {1d077e47-e3a1-47fd-8b12-4de650e39df5} ProjectExplorer.Project.ActiveTarget @@ -60,12 +60,12 @@ Desktop Desktop - {2c9bf876-3476-44eb-8065-1f0844704dda} + {451ee8a3-56ff-4aba-8a8e-3da882cc142e} 0 0 0 - /home/sdomas/Projet/Blast/code/blast + /localhome/sdomas/Projet/Blast/code/blast diff --git a/lib/references/references.bmf b/lib/references/references.bmf index a5ec5ae..594beb0 100644 Binary files a/lib/references/references.bmf and b/lib/references/references.bmf differ