From: stephane Domas Date: Mon, 7 May 2018 16:18:31 +0000 (+0200) Subject: clkconvert OP compute done X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/commitdiff_plain/4327c2b8817b627249d98d889835726217c81a4e clkconvert OP compute done --- diff --git a/AbstractBlock.cpp b/AbstractBlock.cpp index 0f3f801..218ea61 100644 --- a/AbstractBlock.cpp +++ b/AbstractBlock.cpp @@ -278,73 +278,6 @@ QList AbstractBlock::getWishboneParameters() { return lst; } -void AbstractBlock::connectClock(QString clkName, int idGen) throw(Exception) { - - GroupBlock* parentBlock = AB_TO_GRP(parent); - ConnectedInterface* fromClk = NULL; - ConnectedInterface* toClk = AI_TO_CON(getIfaceFromName(clkName)); - - if (parentBlock->isTop()) { - QString genName = "clkrstgen_" + QString::number(idGen); - AbstractBlock* clkrstgen = parentBlock->getFunctionalBlockByName(genName); - if (clkrstgen == NULL) { - throw(Exception(IFACE_TOP_NOCLKRSTGEN,this)); - } - else { - fromClk = AI_TO_CON(clkrstgen->getIfaceFromName("clk")); - } - cout << "connecting clock for " << qPrintable(name) << " to " << qPrintable(genName) << endl; - } - else { - // searching for ext_clk_idGen - QString name = "ext_clk_"+QString::number(idGen); - fromClk = AI_TO_CON(parentBlock->getIfaceFromName(name)); - cout << "connecting clk for child " << qPrintable(name) << " of " << qPrintable(parentBlock->getName()) << endl; - } - - if (fromClk == NULL) { - throw(Exception(IFACE_GROUP_NOCLKRST,parentBlock)); - } - else { - fromClk->connectTo(toClk); - cout << "connection done between " << qPrintable(toClk->getConnectedFrom()->getOwner()->getName()) << "/" << qPrintable(toClk->getConnectedFrom()->getName()); - cout << " and " << qPrintable(toClk->getOwner()->getName()) << "/" << qPrintable(toClk->getName()) << endl; - } -} - -void AbstractBlock::connectReset(QString rstName, int idGen) throw(Exception) { - - GroupBlock* parentBlock = AB_TO_GRP(parent); - ConnectedInterface* fromRst = NULL; - ConnectedInterface* toRst = AI_TO_CON(getIfaceFromName(rstName)); - - if (parentBlock->isTop()) { - QString genName = "clkrstgen_" + QString::number(idGen); - AbstractBlock* clkrstgen = parentBlock->getFunctionalBlockByName(genName); - if (clkrstgen == NULL) { - throw(Exception(IFACE_TOP_NOCLKRSTGEN,this)); - } - else { - fromRst = AI_TO_CON(clkrstgen->getIfaceFromName("reset")); - } - cout << "connecting reset for " << qPrintable(name) << " to " << qPrintable(genName) << endl; - } - else { - QString name = "ext_reset_"+QString::number(idGen); - fromRst = AI_TO_CON(parentBlock->getIfaceFromName(name)); - cout << "connecting reset for child " << qPrintable(name) << " of " << qPrintable(parentBlock->getName()) << endl; - } - - if (fromRst == NULL) { - throw(Exception(IFACE_GROUP_NOCLKRST,parentBlock)); - } - else { - fromRst->connectTo(toRst); - cout << "connection done between " << qPrintable(toRst->getConnectedFrom()->getOwner()->getName()) << "/" << qPrintable(toRst->getConnectedFrom()->getName()); - cout << " and " << qPrintable(toRst->getOwner()->getName()) << "/" << qPrintable(toRst->getName()) << endl; - } -} - void AbstractBlock::generateEntity(QTextStream& out, bool hasController) throw(Exception) { out << "entity " << name << " is" << endl; diff --git a/AbstractBlock.h b/AbstractBlock.h index fad9b53..efbd474 100644 --- a/AbstractBlock.h +++ b/AbstractBlock.h @@ -86,9 +86,7 @@ public: * \brief connectClkReset connects the clock and reset inputs to a clkrstgen block or the the group ifaces * \param idBlockClk is the id of the clock interface (there may be severals) * \param idGen is the id of the clkrstgen block - */ - void connectClock(QString clkName, int idGen = 0) throw(Exception); - void connectReset(QString rstName, int idGen = 0) throw(Exception); + */ virtual QList getExternalResources() = 0; // returns the list of all external files needed for VHDL generation virtual void generateVHDL(const QString& path) throw(Exception) = 0; // main entry to generate the VHDL code void generateComponent(QTextStream& out, bool hasController=false) throw(Exception); // generate the component using reference diff --git a/BoxItem.cpp b/BoxItem.cpp index ae15002..783716c 100644 --- a/BoxItem.cpp +++ b/BoxItem.cpp @@ -906,6 +906,12 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) { if(!ok) throw(Exception(PROJECTFILE_CORRUPTED)); int dimY = dimensionStr.at(1).toInt(&ok); if(!ok) throw(Exception(PROJECTFILE_CORRUPTED)); + + QString visStr = funcElement.attribute("visible","none"); + bool showItem = true; + if (visStr == "false") { + showItem = false; + } ReferenceBlock *referenceMd5 = NULL; ReferenceBlock *referenceXml = NULL; @@ -927,7 +933,7 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) { } GroupBlock* parentGroupBlock = AB_TO_GRP(((GroupItem *)parentItem())->getRefBlock()); - FunctionalBlock* functionalBlock = params->getGraph()->createFunctionalBlock(parentGroupBlock, reference); + FunctionalBlock* functionalBlock = params->getGraph()->createFunctionalBlock(parentGroupBlock, reference, false); /* NB: addFunctionalBlock creates all interfaces from the reference, which is annoying when reading bif_iface tags. Thus interface are all removed. */ @@ -958,7 +964,7 @@ void BoxItem::loadFunctional(QDomElement funcElement) throw(Exception) { } // recreate all (non-control) interfaces because of some may have a multiplicity>1 with several examplars - functionalBlock->removeAllInterfaces(); + //functionalBlock->removeAllInterfaces(); QDomNodeList interfaceNodes = funcElement.elementsByTagName("bif_iface"); // setting interfaces (user name, and for multiplicity>1 may be create some new ones) for(int i=0; isetOrientation(orientation); interfaceItem->setPositionRatio(position); } + setVisible(showItem); updateGeometry(Resize); } @@ -1032,6 +1039,9 @@ void BoxItem::save(QXmlStreamWriter &writer) { writer.writeAttribute("position",attrPos); QString attrDim = QString::number(getWidth()).append(",").append(QString::number(getHeight())); writer.writeAttribute("dimension",attrDim); + if (!isVisible()) { + writer.writeAttribute("visible","false"); + } writer.writeStartElement("bif_parameters"); foreach(BlockParameter *param,refBlock->getParameters()){ diff --git a/ConnectionItem.cpp b/ConnectionItem.cpp index c3a7ada..61af6c8 100644 --- a/ConnectionItem.cpp +++ b/ConnectionItem.cpp @@ -9,24 +9,30 @@ //int ConnectionItem::counter = 0; -ConnectionItem::ConnectionItem(InterfaceItem* _iface1, - InterfaceItem* _iface2, +ConnectionItem::ConnectionItem(InterfaceItem* _fromInterfaceItem, + InterfaceItem* _toInterfaceItem, Dispatcher* _dispatcher, Parameters* _params) : QGraphicsItem() { dispatcher = _dispatcher; params = _params; + fromInterfaceItem = _fromInterfaceItem; + toInterfaceItem = _toInterfaceItem; + + /* NOTE: originally, the following was testing the correct order + * to connect the 2 interfaces. Presently, the order is predetermined + * when testing the AbstractInterface objets that must be connected. ConnectedInterface* ref1 = _iface1->refInter; ConnectedInterface* ref2 = _iface2->refInter; - /* ref. note in .h + ref. note in .h case 1 : ref1 is group interface, and ref2 block interface of a block within the group case 2 : the opposite of case 1 case 3 : ref1 and ref2 are block interface of blocks that are both within the same parent group. - case 4 : ref1 is source interface and ref2 interface of top group + case 4 : ref1 is stimuli interface and ref2 interface of top group case 5 : the opposite of case 4 - */ + if (ref1->getOwner() == ref2->getOwner()->getParent()) { if (ref1->getDirection() == AbstractInterface::Input) { @@ -74,13 +80,15 @@ ConnectionItem::ConnectionItem(InterfaceItem* _iface1, } } else if ((ref1->getOwner()->isStimuliBlock()) && (ref2->getOwner()->isTopGroupBlock())) { - fromInterfaceItem = _iface1; + fromInterfaceItem = _iface1; toInterfaceItem = _iface2; } else if ((ref2->getOwner()->isStimuliBlock()) && (ref1->getOwner()->isTopGroupBlock())) { - fromInterfaceItem = _iface2; + fromInterfaceItem = _iface2; toInterfaceItem = _iface1; } + + */ // adding this to interface items fromInterfaceItem->addConnectionItem(this); toInterfaceItem->addConnectionItem(this); diff --git a/ConnectionItem.h b/ConnectionItem.h index 5548715..13bf8a7 100644 --- a/ConnectionItem.h +++ b/ConnectionItem.h @@ -38,8 +38,8 @@ class ConnectionItem : public QGraphicsItem { public: - ConnectionItem(InterfaceItem* _iface1, - InterfaceItem* _iface2, + ConnectionItem(InterfaceItem* _fromInterfaceItem, + InterfaceItem* _toInterfaceItem, Dispatcher* _dispatcher, Parameters* _params); ConnectionItem (const ConnectionItem & copy); diff --git a/Dispatcher.cpp b/Dispatcher.cpp index b162559..e1857c3 100644 --- a/Dispatcher.cpp +++ b/Dispatcher.cpp @@ -120,11 +120,20 @@ bool Dispatcher::createConnection(Context context, InterfaceItem *iface1, Interf } if ((ok1 == true) || (ok2 == true)) { - iface1->getOwner()->getScene()->createConnectionItem(iface1,iface2, visible); + cout << "trying to create a connection from " << qPrintable(ref1->getOwner()->getName()) << "/" << qPrintable(ref1->getName()); + cout << " to " << qPrintable(ref2->getOwner()->getName()) << "/" << qPrintable(ref2->getName()); + + if (ok1) { + iface1->getOwner()->getScene()->createConnectionItem(iface1,iface2, visible); + } + else { + iface2->getOwner()->getScene()->createConnectionItem(iface2,iface1, visible); + } + + cout << " ... done." << endl; unselectAllItems(context); - params->unsaveModif = true; - cout << "created a connection from " << qPrintable(ref1->getName()) << " to " << qPrintable(ref2->getName()) << endl; + params->unsaveModif = true; return true; } return false; @@ -623,13 +632,12 @@ void Dispatcher::duplicateInterfaceItem(Context context, InterfaceItem *item) { } -BoxItem* Dispatcher::addBlock(Context context, int idCategory, int idBlock, int idScene, QHash clkRstToGen) { +void Dispatcher::addBlock(Context context, int idCategory, int idBlock, int idScene, QHash clkRstToGen) { static QString fctName = "Dispatcher::addBlock()"; #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; #endif - bool newStimuli = false; - BoxItem* item = NULL; + bool newStimuli = false; /* For now, this method is only used while designing and not loading */ if (context == Design) { @@ -644,7 +652,18 @@ BoxItem* Dispatcher::addBlock(Context context, int idCategory, int idBlock, int } if (newStimuli) { FunctionalBlock* newOne = params->getGraph()->createStimuliBlock(ref, true); - scene->createStimuliItem(newOne); + StimuliItem* item = scene->createStimuliItem(newOne); + QHashIterator iter(clkRstToGen); + while (iter.hasNext()) { + iter.next(); + AbstractInterface* iface = newOne->getIfaceFromName(iter.key()); + if (iface->getPurpose() == AbstractInterface::Clock) { + connectStimuliItemClock(context,item,iface->getName(),iter.value()); + } + else if (iface->getPurpose() == AbstractInterface::Reset) { + connectStimuliItemReset(context,item,iface->getName(),iter.value()); + } + } } else { @@ -652,27 +671,24 @@ BoxItem* Dispatcher::addBlock(Context context, int idCategory, int idBlock, int FunctionalBlock* newOne = params->getGraph()->createFunctionalBlock(group, ref, true); // creating the box item - item = scene->createBoxItem(newOne); - if (params->autoConnMainClk) { - // for now just use the first one - QHashIterator iter(clkRstToGen); - while (iter.hasNext()) { - iter.next(); - AbstractInterface* iface = newOne->getIfaceFromName(iter.key()); - if (iface->getPurpose() == AbstractInterface::Clock) { - newOne->connectClock(iface->getName(), iter.value()); - } - else if (iface->getPurpose() == AbstractInterface::Reset) { - newOne->connectReset(iface->getName(), iter.value()); - } + BoxItem* item = scene->createBoxItem(newOne); + + QHashIterator iter(clkRstToGen); + while (iter.hasNext()) { + iter.next(); + AbstractInterface* iface = newOne->getIfaceFromName(iter.key()); + if (iface->getPurpose() == AbstractInterface::Clock) { + connectBoxItemClock(context,item,iface->getName(),iter.value()); + } + else if (iface->getPurpose() == AbstractInterface::Reset) { + connectBoxItemReset(context,item,iface->getName(),iter.value()); } } + params->blockToItem.insert(newOne,item); } params->unsaveModif = true; } - - return item; } void Dispatcher::addClkRstGenBlock(Context context, double frequency) { @@ -1259,6 +1275,122 @@ void Dispatcher::removeConnection(Context context, ConnectionItem *connItem) { } } +void Dispatcher::connectBoxItemClock(Context context, BoxItem *item, QString clkName, int idGen) throw(Exception) { + + InterfaceItem* fromIfaceItemClk = NULL; + InterfaceItem* toIfaceItemClk = item->searchInterfaceItemByName(clkName); + GroupItem* parentGroup = item->getScene()->getGroupItem(); + BoxItem* clkrstItem = NULL; + + if (parentGroup->getRefBlock()->isTopGroupBlock()) { + QString genName = "clkrstgen_" + QString::number(idGen); + clkrstItem = item->getScene()->searchBoxItemByName(genName); + if (clkrstItem == NULL) { + throw(Exception(IFACE_TOP_NOCLKRSTGEN)); + } + else { + fromIfaceItemClk = clkrstItem->searchInterfaceItemByName("clk"); + } + cout << "connecting clock of " << qPrintable(item->getRefBlock()->getName()) << " to clk of " << qPrintable(genName) << endl; + } + else { + // searching for ext_clk_idGen + QString name = "ext_clk_"+QString::number(idGen); + fromIfaceItemClk = parentGroup->searchInterfaceItemByName(name); + cout << "connecting clock of " << qPrintable(item->getRefBlock()->getName()) << " to " << qPrintable(name) << " of parent group " << qPrintable(parentGroup->getRefBlock()->getName()) << endl; + } + + if (fromIfaceItemClk == NULL) { + throw(Exception(IFACE_GROUP_NOCLKRST)); + } + else { + createConnection(context, fromIfaceItemClk, toIfaceItemClk, false); + cout << "connection done." << endl; + } +} + +void Dispatcher::connectBoxItemReset(Context context, BoxItem *item, QString rstName, int idGen) throw(Exception) { + InterfaceItem* fromIfaceItemRst = NULL; + InterfaceItem* toIfaceItemRst = item->searchInterfaceItemByName(rstName); + GroupItem* parentGroup = item->getScene()->getGroupItem(); + BoxItem* clkrstItem = NULL; + + if (parentGroup->getRefBlock()->isTopGroupBlock()) { + QString genName = "clkrstgen_" + QString::number(idGen); + clkrstItem = item->getScene()->searchBoxItemByName(genName); + if (clkrstItem == NULL) { + throw(Exception(IFACE_TOP_NOCLKRSTGEN)); + } + else { + fromIfaceItemRst = clkrstItem->searchInterfaceItemByName("reset"); + } + cout << "connecting reset of " << qPrintable(item->getRefBlock()->getName()) << " to reset of " << qPrintable(genName) << endl; + } + else { + // searching for ext_rst_idGen + QString name = "ext_rst_"+QString::number(idGen); + fromIfaceItemRst = parentGroup->searchInterfaceItemByName(name); + cout << "connecting reset of " << qPrintable(item->getRefBlock()->getName()) << " to " << qPrintable(name) << " of parent group " << qPrintable(parentGroup->getRefBlock()->getName()) << endl; + } + + if (fromIfaceItemRst == NULL) { + throw(Exception(IFACE_GROUP_NOCLKRST)); + } + else { + createConnection(context, fromIfaceItemRst, toIfaceItemRst, false); + cout << "connection done." << endl; + } +} + +void Dispatcher::connectStimuliItemClock(Context context, StimuliItem *item, QString clkName, int idGen) throw(Exception) { + InterfaceItem* fromIfaceItemClk = NULL; + InterfaceItem* toIfaceItemClk = item->searchInterfaceItemByName(clkName); + BoxItem* clkrstItem = NULL; + + QString genName = "clkrstgen_" + QString::number(idGen); + clkrstItem = item->getScene()->searchBoxItemByName(genName); + if (clkrstItem == NULL) { + throw(Exception(IFACE_TOP_NOCLKRSTGEN)); + } + else { + fromIfaceItemClk = clkrstItem->searchInterfaceItemByName("clk"); + } + cout << "connecting clock of " << qPrintable(item->getRefBlock()->getName()) << " to clock of " << qPrintable(genName) << endl; + + if (fromIfaceItemClk == NULL) { + throw(Exception(IFACE_GROUP_NOCLKRST)); + } + else { + createConnection(context, fromIfaceItemClk, toIfaceItemClk, false); + cout << "connection done." << endl; + } +} + +void Dispatcher::connectStimuliItemReset(Context context, StimuliItem *item, QString rstName, int idGen) throw(Exception) { + InterfaceItem* fromIfaceItemRst = NULL; + InterfaceItem* toIfaceItemRst = item->searchInterfaceItemByName(rstName); + BoxItem* clkrstItem = NULL; + + QString genName = "clkrstgen_" + QString::number(idGen); + clkrstItem = item->getScene()->searchBoxItemByName(genName); + if (clkrstItem == NULL) { + throw(Exception(IFACE_TOP_NOCLKRSTGEN)); + } + else { + fromIfaceItemRst = clkrstItem->searchInterfaceItemByName("reset"); + } + cout << "connecting reset of " << qPrintable(item->getRefBlock()->getName()) << " to reset of " << qPrintable(genName) << endl; + + if (fromIfaceItemRst == NULL) { + throw(Exception(IFACE_GROUP_NOCLKRST)); + } + else { + createConnection(context, fromIfaceItemRst, toIfaceItemRst, false); + cout << "connection done." << endl; + } +} + + void Dispatcher::showBlocksLibrary(){ cout << "showing block library" << endl; mainWindow->getLibrary()->show(); diff --git a/Dispatcher.h b/Dispatcher.h index 46db9b5..425c158 100644 --- a/Dispatcher.h +++ b/Dispatcher.h @@ -94,7 +94,7 @@ public: /************************** * block ops *************************/ - BoxItem* addBlock(Context context, int idCategory, int idBlock, int idScene, QHash clkRstToGen ); + void addBlock(Context context, int idCategory, int idBlock, int idScene, QHash clkRstToGen ); void addClkRstGenBlock(Context context, double frequency); void removeBoxItem(Context context, BoxItem* item); void duplicateBoxItem(Context context, BoxItem* item); @@ -146,6 +146,10 @@ public: bool createConnection(Context context, InterfaceItem *iface1, InterfaceItem *iface2, bool visible = true); void removeAllBlockConnections(Context context, AbstractBoxItem *item); void removeConnection(Context context, ConnectionItem *conn); + void connectBoxItemClock(Context context, BoxItem* item, QString clkName, int idGen = 0) throw(Exception); + void connectBoxItemReset(Context context, BoxItem* item, QString rstName, int idGen = 0) throw(Exception); + void connectStimuliItemClock(Context context, StimuliItem* item, QString clkName, int idGen = 0) throw(Exception); + void connectStimuliItemReset(Context context, StimuliItem* item, QString rstName, int idGen = 0) throw(Exception); // analysis ops diff --git a/FunctionalBlock.cpp b/FunctionalBlock.cpp index 925a0f9..0eb4036 100644 --- a/FunctionalBlock.cpp +++ b/FunctionalBlock.cpp @@ -30,10 +30,17 @@ FunctionalBlock::FunctionalBlock(Graph *_graph, GroupBlock *_parent, ReferenceBl delta = -1; evaluator = NULL; + BlockParameter* p; + // create parameters from reference block + QList lstParam = reference->getParameters(); + for(int i=0;iclone(); + addParameter(p); + } + if (createIfaces) { populate(); } - } FunctionalBlock::~FunctionalBlock() { @@ -71,17 +78,9 @@ bool FunctionalBlock::isStimuliBlock() { } void FunctionalBlock::populate() { - int i; - BlockParameter* p; - AbstractInterface* inter; - - // create parameters from reference block - QList lstParam = reference->getParameters(); - for(i=0;iclone(); - addParameter(p); - } + int i; + AbstractInterface* inter; ConnectedInterface* toClk = NULL; ConnectedInterface* toRst = NULL; // create interfaces from reference block diff --git a/FunctionalInterface.cpp b/FunctionalInterface.cpp index 7d1217a..55f65ec 100644 --- a/FunctionalInterface.cpp +++ b/FunctionalInterface.cpp @@ -90,7 +90,7 @@ bool FunctionalInterface::canConnectTo(AbstractInterface *iface) { - iface type must be functional or group interface - iface->connectedFrom must be NULL - valid cases: + valid "normal" cases: 1 - iface is owned by a block (group or func) that is within the same group as the block that own this 1.1 - this is output and iface is input 1.2 - both are inout @@ -99,11 +99,21 @@ bool FunctionalInterface::canConnectTo(AbstractInterface *iface) { 2.2 - both are inout 3 - this is owned by a source block and iface is owned by the top group + special case : clk/reset from clkrstgen can connect to stimuli clk/reset + */ if (direction == Input) return false; if (iface->isReferenceInterface()) return false; ConnectedInterface* connIface = AI_TO_CON(iface); if (connIface->getConnectedFrom() != NULL) return false; + // special case + if ((getOwner()->getName().startsWith("clkrstgen")) && (iface->getOwner()->isStimuliBlock())) { + if ((direction == Output) && (iface->getDirection() == Input)) { + if ((purpose == AbstractInterface::Clock) && (iface->getPurpose() == AbstractInterface::Clock)) return true; + else if ((purpose == AbstractInterface::Reset) && (iface->getPurpose() == AbstractInterface::Reset)) return true; + } + } + // first case: interface of blocks within the same group if (getOwner()->getParent() == iface->getOwner()->getParent()) { @@ -138,11 +148,21 @@ bool FunctionalInterface::canConnectFrom(AbstractInterface *iface) { 2 - iface is owned by the parent group of the block that owns this 2.1 - this is an input, iface is an input of the group 2.2 - both are inout + + special case : clk/reset of stimuli can connect from clk/reset of clkrstgen */ if (direction == Output) return false; if (iface->isReferenceInterface()) return false; if (connectedFrom != NULL) return false; + // special case + if ((iface->getOwner()->getName().startsWith("clkrstgen")) && (getOwner()->isStimuliBlock())) { + if ((direction == Input) && (iface->getDirection() == Output)) { + if ((purpose == AbstractInterface::Clock) && (iface->getPurpose() == AbstractInterface::Clock)) return true; + else if ((purpose == AbstractInterface::Reset) && (iface->getPurpose() == AbstractInterface::Reset)) return true; + } + } + if (getOwner()->getParent() == iface->getOwner()->getParent()) { if ((direction == Input) && (iface->getDirection() == Output) && (purpose == iface->getPurpose())) return true; diff --git a/GroupItem.cpp b/GroupItem.cpp index f275f8e..283e6b4 100644 --- a/GroupItem.cpp +++ b/GroupItem.cpp @@ -814,7 +814,12 @@ void GroupItem::load(QDomElement groupElement) throw(Exception) { GroupInterface *groupIface = new GroupInterface(groupBlock,name,direction,purpose); groupBlock->addInterface(groupIface); - InterfaceItem *interfaceItem = new InterfaceItem(position,orientation,groupIface,this,params); + bool show = false; + if ((groupBlock->isTopGroupBlock()) && (purpose == AbstractInterface::Clock)) { + show = true; + } + + InterfaceItem *interfaceItem = new InterfaceItem(position,orientation,groupIface,this,params,show); interfaceItem->setId(id); addInterfaceItem(interfaceItem, false); @@ -823,7 +828,7 @@ void GroupItem::load(QDomElement groupElement) throw(Exception) { groupCtlIface->setAssociatedIface(groupIface); groupBlock->addInterface(groupCtlIface); } - cout << "interface add to " << groupBlock->getName().toStdString() << endl; + cout << "interface " << qPrintable(name) << " added to " << groupBlock->getName().toStdString() << endl; } } diff --git a/GroupScene.cpp b/GroupScene.cpp index 70c88e2..13b6e11 100644 --- a/GroupScene.cpp +++ b/GroupScene.cpp @@ -9,6 +9,7 @@ #include "ConnectionItem.h" #include "InterfaceItem.h" #include "AbstractBlock.h" +#include "Graph.h" GroupScene::GroupScene(GroupScene *_parentScene, GroupWidget *_window, Dispatcher* _dispatcher, Parameters* _params, bool _topScene, QObject *parent) : QGraphicsScene(parent) { dispatcher = _dispatcher; @@ -156,6 +157,15 @@ void GroupScene::removeBoxItem(BoxItem* item) { groupItem->updateShape(); } +BoxItem* GroupScene::searchBoxItemByName(QString name) { + foreach(BoxItem* item, boxItems) { + if (item->getRefBlock()->getName() == name) { + return item; + } + } + return NULL; +} + StimuliItem *GroupScene::createStimuliItem(AbstractBlock *block) { StimuliItem* item = new StimuliItem(block,dispatcher,params); @@ -268,6 +278,16 @@ void GroupScene::save(QXmlStreamWriter &writer) { else { writer.writeAttribute("upper_scene",QString::number(parentScene->getId())); } + if (isTopScene()) { + QString clkList = ""; + QList lst = params->getGraph()->getClocks(); + foreach(double d, lst) { + clkList += QString::number(d)+","; + } + clkList.chop(1); + writer.writeAttribute("clkList",clkList); + + } groupItem->save(writer); if (isTopScene()) { diff --git a/GroupScene.h b/GroupScene.h index d5a485e..10a5a90 100644 --- a/GroupScene.h +++ b/GroupScene.h @@ -79,6 +79,7 @@ public: BoxItem* createBoxItem(AbstractBlock* block, BoxItem::Position position = BoxItem::Free, int lock = AbstractBoxItem::NoLock, BoxItem::SpanType span = BoxItem::NoSpan); //! create a new BoxItem and place it at the center of the scene void addBoxItem(BoxItem* item); //! add an already configured BoxItem in the scene. void removeBoxItem(BoxItem* item); + BoxItem* searchBoxItemByName(QString name); // ConnectionItem related void createConnectionItem(InterfaceItem* iface1, InterfaceItem* iface2, bool visible = true); diff --git a/Makefile-isim b/Makefile-isim deleted file mode 100644 index 15319a1..0000000 --- a/Makefile-isim +++ /dev/null @@ -1,33 +0,0 @@ -OPT := params-isim.txt - -include $(OPT) - -ISIM_DIR := isim - -ISIM_LIB := work - -all : project compile - -project : $(PROJECT_NAME).prj - -compile : $(PROJECT_NAME).prj $(VHDL_SRC) - tb_name=$$( echo $(TB_SRC) | sed 's,.*/,,' | sed 's,[.].*,,'); \ - fuse $(ISIM_LIB).$$tb_name $(ISIM_LIB).glbl -prj $(PROJECT_NAME).prj -L unisim -L secureip -timeprecision_vhdl ps -o $(SIMU_EXE) - -view : - $(SIMU_EXE) -gui -wdb $(SIMU_EXE).wdb - -$(PROJECT_NAME).prj : - if [ -f $@ ]; then rm $@; fi - echo "### VHDL sources" - for fich in $(VHDL_SRC); do echo vhdl $(ISIM_LIB) $$fich >> $@; done - echo "### verilog sources" - for fich in $(VL_SRC); do echo verilog $(ISIM_LIB) $$fich >> $@; done - echo "### test bench sources" - for fich in $(TB_SRC); do echo vhdl $(ISIM_LIB) $$fich >> $@; done - -clean : - rm -f *~ - rm -f $(PROJECT_NAME).prj - cd $(SRC_DIR); rm -f *~ - cd $(TB_DIR); rm -f *~ diff --git a/Parameters.cpp b/Parameters.cpp index ec0041f..23b798f 100644 --- a/Parameters.cpp +++ b/Parameters.cpp @@ -78,6 +78,7 @@ Graph* Parameters::initGraph(bool createTopGroupIfaces) { void Parameters::destroyGraph() { delete graph; + graph = new Graph(); } ReferenceBlock* Parameters::getReferenceBlock(int idCategory, int idBlock) { @@ -275,6 +276,14 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) { if(!ok) throw(Exception(PROJECTFILE_CORRUPTED)); if (idUpperScene == -1) { + QString clkList = currentSceneNode.attribute("clklist","none"); + if (clkList == "none") throw(Exception(PROJECTFILE_CORRUPTED)); + QStringList clks = clkList.split(","); + for(int j=0;jaddClock(freq); + } topGroup = dispatcher->createTopScene(Dispatcher::Load); topScene->setId(idScene); groupItem = topScene->getGroupItem(); @@ -460,12 +469,16 @@ GroupWidget *Parameters::loadProject(QDomElement root) throw(Exception) { int to = currentConnectionNode.attribute("to","none").toInt(&ok); if(!ok) throw(Exception(PROJECTFILE_CORRUPTED)); - + bool showConn = true; + QString visStr = currentConnectionNode.attribute("visible","none"); + if (visStr == "false") { + showConn = false; + } InterfaceItem *iface1 = searchInterfaceItemById(from,topScene); InterfaceItem *iface2 = searchInterfaceItemById(to,topScene); if(iface1 != NULL && iface2 != NULL){ - dispatcher->createConnection(Dispatcher::Load, iface1,iface2); + dispatcher->createConnection(Dispatcher::Load, iface1,iface2,showConn); } else { cout << "interfaces not found, connect canceled!" << endl; } @@ -1173,7 +1186,9 @@ void Parameters::save(QString confFile) { writer.writeAttribute("from",QString::number(item->getFromInterfaceItem()->getId())); writer.writeAttribute("to", QString::number(item->getToInterfaceItem()->getId())); - + if (!item->isVisible()) { + writer.writeAttribute("visible","false"); + } writer.writeEndElement(); } diff --git a/SpecialBlock.cpp b/SpecialBlock.cpp index 9576dc9..be9452e 100644 --- a/SpecialBlock.cpp +++ b/SpecialBlock.cpp @@ -68,7 +68,7 @@ void SpecialBlock::computeOutputPatternSource(int nbExec) throw(Exception) { // assign pattern to interface connIface->setOutputPattern(pattern); // store it in QMap - outputPattern.insert(connIface,pattern); + outputPattern.insert(connIface,pattern); } setOutputPatternComputed(true); } @@ -105,36 +105,61 @@ void SpecialBlock::computeOutputPatternClockConvert(int nbExec) throw(Exception) AbstractInterface* clkIn = getIfaceFromName("clk_in"); AbstractInterface* clkOut = getIfaceFromName("clk_out"); cout << "freq clk_in = " << clkIn->getClockFrequency() << endl; - cout << "freq clk_out = " << clkOut->getClockFrequency() << endl; - - // in case of inputPattern not created, do it - if (lengthIP <= 0) { - - cout << "Strange case: input pattern is not created while it is time to compute output pattern !" << endl; - // collect the input patterns for each input - try { - createInputPattern(); + cout << "freq clk_out = " << clkOut->getClockFrequency() << endl; + double periodIn = 1000.0/clkIn->getClockFrequency(); + double periodOut = 1000.0/clkOut->getClockFrequency(); + cout << "period clk_in = " << periodIn << endl; + cout << "period clk_out = " << periodOut << endl; + // starts with 1 data in FIFO + int latency = 1+(int)((periodIn+5.0*periodOut)/periodOut); + QList pattern; + for(int i=0;i 0) { + pattern.append(1); + } + else { + pattern.append(0); + inFifo ++; + } + idIn ++; + idOut ++; + } + else if (tIn < tOut) { + inFifo++; + idIn ++; } - catch(Exception e) { - throw(e); + else { + if (inFifo > 0) { + pattern.append(1); + inFifo--; + } + else { + pattern.append(0); + } + idOut++; } - cout << "input pattern array initialized with min. len " << lengthIP << endl; } + foreach(char c, pattern) cout << (int)c; + cout << endl; // initialize the output pattern - lengthOP = 0; + lengthOP = pattern.size(); foreach(AbstractInterface* iface, getControlOutputs()) { - FunctionalInterface* connIface = AI_TO_FUN(iface); - lengthOP = lengthIP+productionPattern.value(connIface)->size(); - QList* pattern = new QList(); - for(int i=0;iappend(0); - connIface->setOutputPattern(pattern); - outputPattern.insert(connIface,pattern); + FunctionalInterface* connIface = AI_TO_FUN(iface); + QList* pat = new QList(pattern); + connIface->setOutputPattern(pat); + outputPattern.insert(connIface,pat); } - cout << "output pattern array initialized" << endl; - - int clock = 0; - + cout << "output pattern computed" << endl; } diff --git a/StimuliItem.cpp b/StimuliItem.cpp index dff5247..4bc4f31 100644 --- a/StimuliItem.cpp +++ b/StimuliItem.cpp @@ -614,7 +614,7 @@ void StimuliItem::load(QDomElement funcElement) throw(Exception) { reference = referenceMd5; } - FunctionalBlock* functionalBlock = params->getGraph()->createStimuliBlock(reference); + FunctionalBlock* functionalBlock = params->getGraph()->createStimuliBlock(reference, false); /* NB: createSourceBlock creates all interfaces from the reference, which is annoying when reading bif_iface tags. Thus interface are all removed. */ @@ -644,7 +644,7 @@ void StimuliItem::load(QDomElement funcElement) throw(Exception) { } // recreate all (non-control) interfaces because of some may have a multiplicity>1 with several examplars - functionalBlock->removeAllInterfaces(); + //functionalBlock->removeAllInterfaces(); QDomNodeList interfaceNodes = funcElement.elementsByTagName("source_iface"); // setting interfaces (user name, and for multiplicity>1 may be create some new ones) for(int i=0; i - + EnvironmentId diff --git a/projectfile.xsd b/projectfile.xsd index 02ba8fd..336d2ac 100644 --- a/projectfile.xsd +++ b/projectfile.xsd @@ -47,6 +47,7 @@ + @@ -96,6 +97,7 @@ + @@ -147,6 +149,15 @@ + + + + + + + + + @@ -295,6 +306,7 @@ +