From: stephane Domas Date: Wed, 24 Jan 2018 20:11:31 +0000 (+0100) Subject: debugged clk/rst auto conn X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/commitdiff_plain/c25a6c891bde475aa51b4c4f5d42ecd7540910bb?ds=inline debugged clk/rst auto conn --- diff --git a/AbstractBlock.cpp b/AbstractBlock.cpp index cdde69f..13adcae 100644 --- a/AbstractBlock.cpp +++ b/AbstractBlock.cpp @@ -3,16 +3,20 @@ #include #include "AbstractInterface.h" #include "BlockParameter.h" +#include "GroupBlock.h" +#include "ConnectedInterface.h" AbstractBlock::AbstractBlock() { name = ""; parent = NULL; } +/* AbstractBlock::AbstractBlock(const QString& _name) { name = normalizeName(_name); parent = NULL; } +*/ AbstractBlock::~AbstractBlock() { @@ -242,4 +246,49 @@ QString AbstractBlock::normalizeName(const QString &name) { return s; } +void AbstractBlock::connectClkReset() throw(Exception) { + + GroupBlock* parentBlock = AB_TO_GRP(parent); + + cout << "connecting clk/rst for child " << qPrintable(name) << " of " << qPrintable(parentBlock->getName()) << endl; + + QList lstClk = getInterfaces(AbstractInterface::Input,AbstractInterface::Clock); + QList lstRst = getInterfaces(AbstractInterface::Input,AbstractInterface::Reset); + + if ((lstClk.isEmpty()) || (lstRst.isEmpty())) { + throw(Exception(IFACE_GROUP_NOCLKRST,this)); + } + + ConnectedInterface* toClk = AI_TO_CON(lstClk.at(0)); + ConnectedInterface* toRst = AI_TO_CON(lstRst.at(0)); + + ConnectedInterface* fromClk = NULL; + ConnectedInterface* fromRst = NULL; + + if (parentBlock->isTop()) { + AbstractBlock* clkrstgen = parentBlock->getFunctionalBlockByName("clkrstgen"); + if (clkrstgen == NULL) { + throw(Exception(IFACE_TOP_NOCLKRSTGEN,this)); + } + else { + fromClk = AI_TO_CON(clkrstgen->getIfaceFromName("clk")); + fromRst = AI_TO_CON(clkrstgen->getIfaceFromName("reset")); + } + } + else { + fromClk = AI_TO_CON(parentBlock->getIfaceFromName("clk")); + fromRst = AI_TO_CON(parentBlock->getIfaceFromName("reset")); + } + if ((fromClk == NULL) || (fromRst == NULL)) { + throw(Exception(IFACE_GROUP_NOCLKRST,parentBlock)); + } + else { + fromClk->connectTo(toClk); + fromRst->connectTo(toRst); + } + + +} + + diff --git a/AbstractBlock.h b/AbstractBlock.h index 042a598..616682d 100644 --- a/AbstractBlock.h +++ b/AbstractBlock.h @@ -21,7 +21,7 @@ class AbstractBlock { public: AbstractBlock(); - AbstractBlock(const QString& _name); + //AbstractBlock(const QString& _name); virtual ~AbstractBlock(); // getters @@ -30,7 +30,7 @@ public: inline QList getParameters() { return params; } inline QList getInputs() { return inputs; } inline QList getOutputs() { return outputs; } - inline QList getBidirs() { return bidirs; } + inline QList getBidirs() { return bidirs; } QList getUserParameters(); QList getGenericParameters(); QList getPortParameters(); @@ -57,6 +57,7 @@ public: // others static QString normalizeName(const QString& name); + void connectClkReset() throw(Exception); virtual void parametersValidation(QList* checkedBlocks, QList* blocksToConfigure) = 0; // ugly but usefull diff --git a/Exception.cpp b/Exception.cpp index 9592e4d..8c59d0d 100644 --- a/Exception.cpp +++ b/Exception.cpp @@ -34,6 +34,9 @@ QString Exception::getDefaultMessage() { case IFACE_NULL : ret = tr("A parameter of type AbstractInterface* has been provided with NULL value."); break; case IFACE_INVALID_TYPE : ret = tr("A parameter of type AbstractInterface* is used with an incorrect instance type."); break; case IFACE_MULTIPLICITY_REACHED : ret = tr("Impossible to create another instance of a GraphInterface: the maximum multiplicity is reached."); break; + case IFACE_BLOCK_NOCLKRST : ret = tr("Cannot find a clk or rst for a block."); break; + case IFACE_GROUP_NOCLKRST : ret = tr("Cannot find a clk or rst for a group."); break; + case IFACE_TOP_NOCLKRSTGEN : ret = tr("Cannot find the clkrstgen block in top group."); break; case BLOCKITEM_NULL : ret = tr("A parameter of type AbstractBlockItem* has been provided with NULL value."); break; case BLOCKITEM_INVALID_TYPE : ret = tr("A parameter of type AbstractBlockItem* is used with an incorrect instance type."); break; case WIDTHS_NOT_EQUALS : ret = tr("Two interfaces are connected but don't have the same widths."); break; diff --git a/Exception.h b/Exception.h index e45e7bb..608bc55 100644 --- a/Exception.h +++ b/Exception.h @@ -44,10 +44,14 @@ supp. infos : saved in UTF-8 [éè] #define BLOCK_NULL 1001 #define BLOCK_INVALID_TYPE 1002 + // exceptions for interfaces manipulations #define IFACE_NULL 2001 #define IFACE_INVALID_TYPE 2002 #define IFACE_MULTIPLICITY_REACHED 2003 +#define IFACE_BLOCK_NOCLKRST 2004 +#define IFACE_GROUP_NOCLKRST 2005 +#define IFACE_TOP_NOCLKRSTGEN 2006 // exceptions for block items manipulations #define BLOCKITEM_NULL 3001 diff --git a/FunctionalBlock.cpp b/FunctionalBlock.cpp index b494784..8ecd6a3 100644 --- a/FunctionalBlock.cpp +++ b/FunctionalBlock.cpp @@ -29,6 +29,7 @@ FunctionalBlock::FunctionalBlock(GroupBlock *_parent, ReferenceBlock *_reference lengthPP = -1; delta = -1; evaluator = NULL; + } FunctionalBlock::~FunctionalBlock() { @@ -77,6 +78,8 @@ void FunctionalBlock::populate() { addParameter(p); } + ConnectedInterface* toClk = NULL; + ConnectedInterface* toRst = NULL; // create interfaces from reference block QList lstRef = reference->getInterfaces(); // store relation between functional and reference @@ -90,8 +93,19 @@ void FunctionalBlock::populate() { exit(1); } hashIface.insert(lstRef.at(i),inter); - addInterface(inter); + /* WARNING FOR THE FUTURE : + in case of there are several clock interfaces ofr that block + it would be a godd idea to make the user choose which one + must be connected to defautl clk. + Presently, the first encountered is chosen + */ + if ((toClk == NULL) && (inter->getPurpose() == AbstractInterface::Clock)) { + toClk = AI_TO_CON(inter); + } + if ((toRst == NULL) && (inter->getPurpose() == AbstractInterface::Reset)) { + toRst = AI_TO_CON(inter); + } } AbstractInterface* funCtlIface = NULL; @@ -108,8 +122,19 @@ void FunctionalBlock::populate() { } } } -} + // connect clk and rst to group clk/rst or to clkrstgen + if ((name != "clkrstgen") && (parent != NULL)) { + try { + connectClkReset(); + } + catch(Exception e) { + AbstractBlock* source = (AbstractBlock *)(e.getSource()); + cerr << qPrintable(source->getName()) << ":" << qPrintable(e.getMessage()) << endl; + throw(e); + } + } +} QString FunctionalBlock::getReferenceXmlFile() { return ((ReferenceBlock *)reference)->getXmlFile(); diff --git a/GroupBlock.cpp b/GroupBlock.cpp index 6950b30..4746a74 100644 --- a/GroupBlock.cpp +++ b/GroupBlock.cpp @@ -31,20 +31,21 @@ GroupBlock::GroupBlock(GroupBlock *_parent) throw(Exception) : AbstractBlock() rst = new GroupInterface(this,"ext_reset", AbstractInterface::Input, AbstractInterface::Reset); addInterface(clk); addInterface(rst); - // creating clkrstgen block : done in Dispatcher since this has no access to library + // creating clkrstgen block and connecting it to this: done in Dispatcher since this has no access to library } parent = _parent; + if (_parent != NULL) { - // adding this to the child blocks of parent - _parent->addBlock(this); - // connect clk/rst ifaces to parent clk/rst or to clkrstgen if parent is top group - if (_parent->isTop()) { - + try { + connectClkReset(); } - else { - + catch(Exception e) { + AbstractBlock* source = (AbstractBlock *)(e.getSource()); + cerr << qPrintable(source->getName()) << ":" << qPrintable(e.getMessage()) << endl; + throw(e); } } + } GroupBlock::~GroupBlock() { diff --git a/GroupBlock.h b/GroupBlock.h index 0f0d206..172803d 100644 --- a/GroupBlock.h +++ b/GroupBlock.h @@ -34,7 +34,7 @@ public: inline void addBlock(AbstractBlock* block) { blocks.append(block); } void removeBlock(AbstractBlock* block); AbstractBlock* getFunctionalBlockByName(QString name); - + void removeAllBlocks(); void parametersValidation(QList *checkedBlocks, QList* blocksToConfigure); void addGenericParameter(QString name, QString type, QString value); diff --git a/ReferenceBlock.cpp b/ReferenceBlock.cpp index fbf7828..5137d73 100644 --- a/ReferenceBlock.cpp +++ b/ReferenceBlock.cpp @@ -94,7 +94,7 @@ void ReferenceBlock::loadInformations(QDomElement &elt) throw(Exception) { } else { QDomText txtName = nodeNameTxt.toText(); - name = txtName.data().trimmed(); + name = normalizeName(txtName.data().trimmed()); cout<< "block name : " << qPrintable(name) << endl; } @@ -633,3 +633,5 @@ void ReferenceBlock::computeAdmittanceDelays() throw(Exception) { // does strictly nothing throw(Exception(INVALID_REFBLOCK_USE)); } + + diff --git a/blast.creator.user b/blast.creator.user index 76fb271..f58f194 100755 --- a/blast.creator.user +++ b/blast.creator.user @@ -1,10 +1,10 @@ - + EnvironmentId - {3701e197-5b6c-48ea-9e98-a6cf6de18672} + {c8006d66-d34f-42be-ad10-d0207752286d} ProjectExplorer.Project.ActiveTarget @@ -19,7 +19,7 @@ Cpp - qt2 + CppGlobal @@ -31,7 +31,7 @@ 2 UTF-8 false - 2 + 4 false 80 true @@ -43,12 +43,12 @@ true true 0 - 4 - false + 8 + true 1 true true - false + true false @@ -61,7 +61,7 @@ Desktop Desktop - {ed04208c-8774-456b-99b9-4a02094ca7a4} + {2c9bf876-3476-44eb-8065-1f0844704dda} 0 0 0 @@ -128,7 +128,7 @@ false false - 0 + 1000 true @@ -169,9 +169,8 @@ - false %{buildDir} - Exécutable personnalisé + Custom Executable ProjectExplorer.CustomExecutableRunConfiguration 3768 diff --git a/lib/implementations/impls.bmf b/lib/implementations/impls.bmf index 2115cfc..8384e85 100644 Binary files a/lib/implementations/impls.bmf and b/lib/implementations/impls.bmf differ diff --git a/lib/references/references.bmf b/lib/references/references.bmf index 2c93c03..a34f592 100644 Binary files a/lib/references/references.bmf and b/lib/references/references.bmf differ