direction = Input;
purpose = Data;
type = Boolean;
+ associatedIface = NULL;
}
direction = _direction;
purpose = _purpose;
type = typeFromString(_type);
+ associatedIface = NULL;
}
AbstractInterface::AbstractInterface(AbstractInterface* other) {
width = other->width;
direction = other->direction;
purpose = other->purpose;
+ associatedIface = NULL;
}
AbstractInterface::~AbstractInterface() {
}
}
+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;
inline int getDirection() { return direction;}
QString getDirectionString();
inline AbstractBlock *getOwner() { return owner;}
+ inline AbstractInterface* getAssociatedIface() { return associatedIface; }
double getDoubleWidth() throw(QException);
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();
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;
};
* 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;
};
BlockParameter* p;\r
AbstractInterface* inter;\r
\r
+ // create parameters from reference block\r
QList<BlockParameter*> lstParam = reference->getParameters();\r
for(i=0;i<lstParam.size();i++) {\r
p = lstParam.at(i)->clone();\r
addParameter(p);\r
}\r
\r
- QList<AbstractInterface *> lstInter = reference->getInterfaces();\r
- for(i=0;i<lstInter.size();i++) {\r
+ // create interfaces from reference block\r
+ QList<AbstractInterface *> lstRef = reference->getInterfaces();\r
+ // store relation between functional and reference\r
+ QHash<AbstractInterface *, AbstractInterface *> hashIface;\r
+ for(i=0;i<lstRef.size();i++) {\r
try {\r
- inter = new FunctionalInterface(this, (ReferenceInterface*)lstInter.at(i));\r
+ inter = new FunctionalInterface(this, AI_TO_REF(lstRef.at(i)));\r
}\r
catch(Exception e) {\r
cerr << "Abnormal case: " << qPrintable(e.getDefaultMessage()) << endl << "Aborting execution." << endl;\r
exit(1);\r
}\r
+ hashIface.insert(lstRef.at(i),inter);\r
\r
addInterface(inter);\r
}\r
-\r
+ \r
+ AbstractInterface* funCtlIface = NULL;\r
+ AbstractInterface* funDataIface = NULL;\r
+ \r
+ for(i=0;i<lstRef.size();i++) { \r
+ AbstractInterface* refIface = lstRef.at(i); \r
+ if (refIface->getPurpose() == AbstractInterface::Control) {\r
+ funCtlIface = hashIface.value(refIface);\r
+ funDataIface = hashIface.value(refIface->getAssociatedIface());\r
+ if (! funCtlIface->setAssociatedIface(funDataIface)) {\r
+ cerr << "Abnormal case when associating a control interface to data" << endl << "Aborting execution." << endl;\r
+ exit(1);\r
+ } \r
+ }\r
+ }\r
}\r
\r
\r
width = reference->getWidth();\r
direction = reference->getDirection();\r
purpose = reference->getPurpose(); \r
- connectedFrom = NULL;\r
+ connectedFrom = NULL; \r
}\r
\r
bool FunctionalInterface::isFunctionalInterface() {\r
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;i<listNodeInputs.size();i++) {
QDomNode node = listNodeInputs.at(i);
inter = new ReferenceInterface(this,nameStr,typeStr,widthStr,AbstractInterface::Input, purpose, mult);
inputs.append(inter);
}
-
+ // getting each control
+ QDomNodeList listNodeInCtl = eltInputs.elementsByTagName("control");
+ for(int i=0;i<listNodeInCtl.size();i++) {
+ QDomNode node = listNodeInCtl.at(i);
+ QDomElement eltInput = node.toElement();
+ nameStr = eltInput.attribute("iface","none");
+ AbstractInterface* dataIface = getIfaceFromName(nameStr);
+ if (dataIface == NULL) throw (Exception(BLOCKFILE_CORRUPTED));
+ nameStr = dataIface->getName()+"_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;i<listNodeOutputs.size();i++) {
inter = new ReferenceInterface(this,nameStr,typeStr,widthStr,AbstractInterface::Output, purpose, mult);
outputs.append(inter);
}
+ // getting each control
+ QDomNodeList listNodeOutCtl = eltOutputs.elementsByTagName("control");
+ for(int i=0;i<listNodeOutCtl.size();i++) {
+ QDomNode node = listNodeOutCtl.at(i);
+ QDomElement eltOutput = node.toElement();
+ nameStr = eltOutput.attribute("iface","none");
+ AbstractInterface* dataIface = getIfaceFromName(nameStr);
+ if (dataIface == NULL) throw (Exception(BLOCKFILE_CORRUPTED));
+ nameStr = dataIface->getName()+"_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");
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;
}
else if (txt == "reset") {
return Reset;
}
- if (txt == "wb") {
+ else if (txt == "wb") {
return Wishbone;
- }
+ }
return Data;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 3.2.1, 2017-05-04T21:30:29. -->
+<!-- Written by QtCreator 3.2.1, 2017-05-05T14:29:41. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
- <value type="QByteArray">{c8006d66-d34f-42be-ad10-d0207752286d}</value>
+ <value type="QByteArray">{1d077e47-e3a1-47fd-8b12-4de650e39df5}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{2c9bf876-3476-44eb-8065-1f0844704dda}</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{451ee8a3-56ff-4aba-8a8e-3da882cc142e}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
- <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/sdomas/Projet/Blast/code/blast</value>
+ <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/localhome/sdomas/Projet/Blast/code/blast</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<valuelist type="QVariantList" key="GenericProjectManager.GenericMakeStep.BuildTargets">