From: stephane Domas Date: Fri, 4 May 2018 13:20:06 +0000 (+0200) Subject: started clkconvert output gen X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/commitdiff_plain/a13795fc34cd1e74f94695d35253c3d00abec9bc?ds=sidebyside started clkconvert output gen --- diff --git a/AbstractBlock.cpp b/AbstractBlock.cpp index b8ce5e5..0f3f801 100644 --- a/AbstractBlock.cpp +++ b/AbstractBlock.cpp @@ -8,10 +8,11 @@ #include "ConnectedInterface.h" -AbstractBlock::AbstractBlock() { +AbstractBlock::AbstractBlock(Graph *_graph) { name = ""; parent = NULL; specialType = NotSpecial; + graph = _graph; } /* diff --git a/AbstractBlock.h b/AbstractBlock.h index 8f09410..fad9b53 100644 --- a/AbstractBlock.h +++ b/AbstractBlock.h @@ -9,6 +9,7 @@ #include "AbstractInterface.h" class AbstractInterface; class BlockParameter; +class Graph; #define AB_TO_REF(ptr) ((ReferenceBlock*)ptr) #define AB_TO_FUN(ptr) ((FunctionalBlock*)ptr) @@ -26,7 +27,7 @@ public: enum SpecialType { NotSpecial = 0, Source = 1, Sink = 2, ClkConvert = 3 }; - AbstractBlock(); + AbstractBlock(Graph* _graph); //AbstractBlock(const QString& _name); virtual ~AbstractBlock(); @@ -35,6 +36,7 @@ public: inline int getSpecialType() { return specialType; } inline QString getVersion() { return version; } inline int nbParameters() { return params.size(); } + inline Graph* getGraph() { return graph; } inline QList getInputs() { return inputs; } inline QList getOutputs() { return outputs; } @@ -112,6 +114,7 @@ protected: QString name; int specialType; QString version; + Graph* graph; // parameters QList params; diff --git a/AbstractInterface.cpp b/AbstractInterface.cpp index d040598..3fdd87a 100644 --- a/AbstractInterface.cpp +++ b/AbstractInterface.cpp @@ -2,6 +2,7 @@ #include "BlockParameterPort.h" #include "AbstractBlock.h" #include "Parameters.h" +#include "Graph.h" AbstractInterface::AbstractInterface(AbstractBlock* _owner) { @@ -192,36 +193,6 @@ QString AbstractInterface::getDirectionString() { return str; } -double AbstractInterface::getDoubleWidth() throw(QException) { - - static QString fctName = "AbstractInterface::getDoubleWidth()"; - #ifdef DEBUG_FCTNAME - cout << "call to " << qPrintable(fctName) << endl; - #endif - - /* - cout << "start AbstractInterface::getDoubleWidth()" << endl; - bool ok; - double width = getWidth().toDouble(&ok); - - if(!ok){ - ArithmeticEvaluator *evaluator = new ArithmeticEvaluator; - cout << "evaluator created!" << endl; - evaluator->setExpression(getWidth()); - cout << "expression defined!" << endl; - foreach(BlockParameter *param, getOwner()->getParameters()){ - evaluator->setVariableValue(param->getName(), param->getIntValue()); - cout << "param : " << param->getName().toStdString() << " evaluated!" << endl; - } - width = evaluator->evaluate(); - cout << "expression evaluated succefully!" << endl; - } - cout << "real width : " << width << endl; - return width; - */ - - return 1.0; -} void AbstractInterface::setPurpose(int _purpose) { if ((_purpose>=Data) && (_purpose <= Wishbone)) { @@ -250,6 +221,32 @@ AbstractInterface* AbstractInterface::getClockIface() { return NULL; } + +double AbstractInterface::getClockFrequency() throw(Exception) { + + int idClock = -1; + + if (clkIfaceType == ParameterName) { + BlockParameter* param = owner->getParameterFromName(clkIface); + if (!param->isUserParameter()) throw(Exception(IFACE_INVALID_CLKFREQ,this)); + bool ok; + double freq = param->getDoubleValue(&ok); + if (!ok) throw(Exception(IFACE_INVALID_CLKFREQ,this)); + return freq; + } + else { + try { + idClock = getClockDomain(); + } + catch(Exception e) { + throw(e); + } + return owner->getGraph()->getClock(idClock); + } + return 0.0; +} + + bool AbstractInterface::setClockIface(QString name) { /* 2 cases : * - this is a Data interface diff --git a/AbstractInterface.h b/AbstractInterface.h index 1e208bf..832fe48 100644 --- a/AbstractInterface.h +++ b/AbstractInterface.h @@ -56,9 +56,9 @@ public : inline AbstractInterface* getAssociatedIface() { return associatedIface; } inline QString getClockIfaceString() { return clkIface; } inline int getClockIfaceType() { return clkIfaceType; } - AbstractInterface* getClockIface(); - - double getDoubleWidth() throw(QException); + AbstractInterface* getClockIface(); + virtual int getClockDomain() throw(Exception) = 0; // determine on which clock domain is sync this interface + double getClockFrequency() throw(Exception); // setters diff --git a/Exception.cpp b/Exception.cpp index 1003397..4bb5ff0 100644 --- a/Exception.cpp +++ b/Exception.cpp @@ -33,11 +33,12 @@ QString Exception::getDefaultMessage() { case VHDLFILE_NOACCESS : ret = tr("VHDL file cannot be read"); break; case VHDLFILE_CORRUPTED : ret = tr("VHDL file is corrupted"); break; 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_INVALID_TYPE : ret = tr("an interface is used for an unauthorized operation according its 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 IFACE_INVALID_CLKFREQ : ret = tr("Cannot determine the frequency of the clock that synchronizes an interface."); 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 0c2cd5e..9fc2b08 100644 --- a/Exception.h +++ b/Exception.h @@ -53,6 +53,7 @@ supp. infos : saved in UTF-8 [éè] #define IFACE_BLOCK_NOCLKRST 2004 #define IFACE_GROUP_NOCLKRST 2005 #define IFACE_TOP_NOCLKRSTGEN 2006 +#define IFACE_INVALID_CLKFREQ 2007 // exceptions for block items manipulations #define BLOCKITEM_NULL 3001 diff --git a/FunctionalBlock.cpp b/FunctionalBlock.cpp index 0fb38c3..925a0f9 100644 --- a/FunctionalBlock.cpp +++ b/FunctionalBlock.cpp @@ -8,7 +8,7 @@ #include "ArithmeticEvaluator.h" -FunctionalBlock::FunctionalBlock(GroupBlock *_parent, ReferenceBlock *_reference, bool createIfaces) throw(Exception) : AbstractBlock() { +FunctionalBlock::FunctionalBlock(Graph *_graph, GroupBlock *_parent, ReferenceBlock *_reference, bool createIfaces) throw(Exception) : AbstractBlock(_graph) { //if (! _reference->isReferenceBlock()) throw(Exception(BLOCK_INVALID_TYPE)); //if (! _group->isGroupBlock()) throw(Exception(BLOCK_INVALID_TYPE)); reference = _reference; diff --git a/FunctionalBlock.h b/FunctionalBlock.h index ced4ab6..e3b8167 100644 --- a/FunctionalBlock.h +++ b/FunctionalBlock.h @@ -26,7 +26,7 @@ using namespace Qt; class FunctionalBlock : public AbstractBlock { public: - FunctionalBlock(GroupBlock* _parent, ReferenceBlock* _reference, bool createIfaces = true) throw(Exception); + FunctionalBlock(Graph* _graph, GroupBlock* _parent, ReferenceBlock* _reference, bool createIfaces = true) throw(Exception); ~FunctionalBlock(); // getters inline ReferenceBlock* getReference() { return reference; } diff --git a/FunctionalInterface.cpp b/FunctionalInterface.cpp index c0b63af..7d1217a 100644 --- a/FunctionalInterface.cpp +++ b/FunctionalInterface.cpp @@ -5,7 +5,6 @@ #include "FunctionalBlock.h" #include "GroupBlock.h" - FunctionalInterface::FunctionalInterface(AbstractBlock* _owner, ReferenceInterface *_reference) throw(Exception) : ConnectedInterface(_owner) { if (_owner == NULL) throw(Exception(BLOCK_NULL)); @@ -157,6 +156,45 @@ bool FunctionalInterface::canConnectFrom(AbstractInterface *iface) { return false; } +int FunctionalInterface::getClockDomain() throw(Exception) { + + int idClock = -1; + + FunctionalInterface* iface = NULL; + if (clkIfaceType == ClockName) { + iface = AI_TO_FUN(getClockIface()); + } + else if ((direction == Input) && (purpose == Clock)) { + iface = this; + } + + if ( iface != NULL) { + + // if iface is a functional interface, it is connected to clkrstgen_X (in top group) or to ext_clk_X (in subgroup) + ConnectedInterface* connFrom = iface->getConnectedFrom(); + if (connFrom == NULL) throw(Exception(IFACE_INVALID_CLKFREQ,this)); + + if (connFrom->getOwner()->isFunctionalBlock()) { + QString name = connFrom->getOwner()->getName(); + cout << "conn from clkrstgen: searching for clkdomain in " << qPrintable(name) << endl; + name.remove(0,10); + bool ok; + idClock = name.toInt(&ok); + if (!ok) throw(Exception(IFACE_INVALID_CLKFREQ,this)); + } + else { + QString name = connFrom->getName(); + cout << "conn from group: searching for clkdomain in " << qPrintable(name) << endl; + name.remove(0,8); + bool ok; + idClock = name.toInt(&ok); + if (!ok) throw(Exception(IFACE_INVALID_CLKFREQ,this)); + } + } + + return idClock; +} + void FunctionalInterface::connectionsValidation(QStack *interfacetoValidate, QList *validatedInterfaces) throw(Exception) { diff --git a/FunctionalInterface.h b/FunctionalInterface.h index 43f31c3..3c70703 100644 --- a/FunctionalInterface.h +++ b/FunctionalInterface.h @@ -35,6 +35,7 @@ public : // getters inline ReferenceInterface* getReference() { return reference; } + int getClockDomain() throw(Exception); // determine at which freq. is synchronized iface //inline QList* getConsumptionPattern() { return consumptionPattern; } //inline QList* getProductionPattern() { return productionPattern; } diff --git a/Graph.cpp b/Graph.cpp index 8e55077..808dbda 100644 --- a/Graph.cpp +++ b/Graph.cpp @@ -14,7 +14,7 @@ Graph::~Graph() { } void Graph::createTopGroup(bool createTopGroupIfaces) { - topGroup = new GroupBlock(NULL, createTopGroupIfaces); + topGroup = new GroupBlock(this, NULL, createTopGroupIfaces); topGroup->setName("top group"); groups.append(topGroup); } @@ -24,7 +24,7 @@ QList Graph::getOutsideInterfaces() { } GroupBlock* Graph::createChildGroupBlock(GroupBlock* parent, bool createGroupIface) { - GroupBlock* b = new GroupBlock(parent, createGroupIface); + GroupBlock* b = new GroupBlock(this, parent, createGroupIface); groups.append(b); return b; } @@ -47,10 +47,12 @@ FunctionalBlock* Graph::createFunctionalBlock(GroupBlock* group, ReferenceBlock* FunctionalBlock* newBlock = NULL; if (ref->getSpecialType() != -1) { - newBlock = new SpecialBlock(ref->getSpecialType(), group,ref, createIfaces); + cout << "Graph: create special block from " << qPrintable(ref->getName()) << endl; + newBlock = new SpecialBlock(this, ref->getSpecialType(), group,ref, createIfaces); } else { - newBlock = new FunctionalBlock(group,ref, createIfaces); + cout << "Graph: create normal block from " << qPrintable(ref->getName()) << endl; + newBlock = new FunctionalBlock(this, group,ref, createIfaces); } group->addBlock(newBlock); @@ -91,7 +93,7 @@ FunctionalBlock* Graph::getFunctionalBlockByName(QString name, GroupBlock* paren FunctionalBlock* Graph::createStimuliBlock(ReferenceBlock* ref, bool createIfaces) { /* A stimuli block is always a special block with idSpecial = 1 */ - FunctionalBlock* newBlock = new SpecialBlock(AbstractBlock::Source, NULL,ref, createIfaces); + FunctionalBlock* newBlock = new SpecialBlock(this, AbstractBlock::Source, NULL,ref, createIfaces); stimulis.append(newBlock); return newBlock; } diff --git a/GroupBlock.cpp b/GroupBlock.cpp index d682a57..206d8cb 100644 --- a/GroupBlock.cpp +++ b/GroupBlock.cpp @@ -10,7 +10,7 @@ int GroupBlock::counter = 1; -GroupBlock::GroupBlock(GroupBlock *_parent, bool createIfaces) throw(Exception) : AbstractBlock() { +GroupBlock::GroupBlock(Graph *_graph, GroupBlock *_parent, bool createIfaces) throw(Exception) : AbstractBlock(_graph) { parent = _parent; GroupInterface* clk = NULL; diff --git a/GroupBlock.h b/GroupBlock.h index 63104de..8502a21 100644 --- a/GroupBlock.h +++ b/GroupBlock.h @@ -17,7 +17,7 @@ using namespace Qt; class GroupBlock : public AbstractBlock { public: - GroupBlock(GroupBlock* _parent, bool createIfaces = true) throw(Exception); + GroupBlock(Graph* _graph, GroupBlock* _parent, bool createIfaces = true) throw(Exception); virtual ~GroupBlock(); // getters diff --git a/GroupInterface.cpp b/GroupInterface.cpp index b42e7a0..bfeb1ff 100644 --- a/GroupInterface.cpp +++ b/GroupInterface.cpp @@ -129,6 +129,32 @@ bool GroupInterface::canConnectFrom(AbstractInterface *iface) { return false; } +int GroupInterface::getClockDomain() throw(Exception) { + + int idClock = -1; + + GroupInterface* iface = NULL; + if (clkIfaceType == ClockName) { + iface = AI_TO_GRP(getClockIface()); + } + else if ((direction == Input) && (purpose == Clock)) { + iface = this; + } + + if ( iface != NULL) { + + QString name = iface->getName(); + name.remove(0,8); + bool ok; + idClock = name.toInt(&ok); + if (!ok) throw(Exception(IFACE_INVALID_CLKFREQ,this)); + + } + + return idClock; +} + + void GroupInterface::connectionsValidation(QStack *interfacetoValidate, QList *validatedInterfaces) throw(Exception) { cout << "group interface connection validation" << endl; } diff --git a/GroupInterface.h b/GroupInterface.h index 2f7ac60..35f0916 100644 --- a/GroupInterface.h +++ b/GroupInterface.h @@ -38,7 +38,7 @@ public : // getters int getWidth(); - + int getClockDomain() throw(Exception); // determine at which freq. is synchronized iface // setters // testers diff --git a/Parameters.cpp b/Parameters.cpp index d7621d2..ec0041f 100644 --- a/Parameters.cpp +++ b/Parameters.cpp @@ -97,71 +97,6 @@ ReferenceBlock* Parameters::getHiddenReferenceBlock(QString blockName) { return ref; } -double Parameters::getFeedingClockFrequency(AbstractInterface *iface) { - - int idClock = 0; - - if (iface->isReferenceInterface()) return 0.0; - - if (iface->getClockIfaceType() == AbstractInterface::ParameterName) { - BlockParameter* param = iface->getOwner()->getParameterFromName(iface->getClockIfaceString()); - if (!param->isUserParameter()) return 0.0; - bool ok; - double freq = param->getDoubleValue(&ok); - if (!ok) { - cerr << "Abnormal case: cannot retrieve clock id from parameter " << qPrintable(param->getName()) << endl; - } - return freq; - } - else if ( (iface->getClockIfaceType() == AbstractInterface::ClockName) || ((iface->getDirection() == AbstractInterface::Input) && (iface->getPurpose() == AbstractInterface::Clock))) { - - // if iface is not clock, retrieve the clock related to it - if (iface->getClockIfaceType() == AbstractInterface::ClockName) { - iface = iface->getClockIface(); - } - // if iface is a group interface, then iface name is ext_clk_X, thus extract the X - if (iface->isGroupInterface()) { - QString name = iface->getName(); - name.remove(0,8); - bool ok; - idClock = name.toInt(&ok); - if (!ok) { - cerr << "Abnormal case: cannot retrieve clock id from iface name " << qPrintable(iface->getName()) << endl; - return 0.0; - } - } - // if iface is a functional interface, it is connected to clkrstgen_X (in top group) or to ext_clk_X (in subgroup) - else if (iface->isFunctionalInterface()) { - FunctionalInterface* funIface = AI_TO_FUN(iface); - ConnectedInterface* connFrom = funIface->getConnectedFrom(); - if (connFrom == NULL) { - cerr << "Abnormal case: input clock " << qPrintable(iface->getName()) << " is not connected" << endl; - return 0.0; - } - if (iface->getOwner()->isTopGroupBlock()) { - QString name = connFrom->getOwner()->getName(); - name.remove(0,10); - bool ok; - idClock = name.toInt(&ok); - if (!ok) { - cerr << "Abnormal case: cannot retrieve clock id for " << qPrintable(iface->getName()) << endl; - return 0.0; - } - } - else { - QString name = connFrom->getName(); - name.remove(0,8); - bool ok; - idClock = name.toInt(&ok); - if (!ok) { - cerr << "Abnormal case: cannot retrieve clock id for " << qPrintable(iface->getName()) << endl; - return 0.0; - } - } - } - } - return graph->getClock(idClock); -} void Parameters::createDelayBlock() { delayRef = new ReferenceBlock("no.xml"); diff --git a/Parameters.h b/Parameters.h index e14b3fe..8d2fc8c 100644 --- a/Parameters.h +++ b/Parameters.h @@ -145,8 +145,7 @@ public : void destroyGraph(); inline Graph* getGraph() { return graph; } ReferenceBlock* getReferenceBlock(int idCategory, int idBlock); // get the reference block from its category and index - ReferenceBlock* getHiddenReferenceBlock(QString blockName); // get a hidden block by name, i.e. in category 100 - double getFeedingClockFrequency(AbstractInterface* iface); // determine at which freq. is synchronized iface + ReferenceBlock* getHiddenReferenceBlock(QString blockName); // get a hidden block by name, i.e. in category 100 void clear(); diff --git a/ReferenceBlock.cpp b/ReferenceBlock.cpp index 9b3959c..553955b 100644 --- a/ReferenceBlock.cpp +++ b/ReferenceBlock.cpp @@ -8,7 +8,7 @@ #include "BlockParameterWishbone.h" #include "Parameters.h" -ReferenceBlock::ReferenceBlock(const QString _xmlFile) : AbstractBlock() { +ReferenceBlock::ReferenceBlock(const QString _xmlFile) : AbstractBlock(NULL) { xmlFile = _xmlFile; } @@ -759,3 +759,4 @@ QList ReferenceBlock::getExternalResources() { return list; } + diff --git a/ReferenceInterface.cpp b/ReferenceInterface.cpp index 8936952..fdebeaa 100644 --- a/ReferenceInterface.cpp +++ b/ReferenceInterface.cpp @@ -71,3 +71,8 @@ int ReferenceInterface::translateMultiplicity(const QString& txt) { } return mult; } + +int ReferenceInterface::getClockDomain() throw(Exception) { + + throw(Exception(IFACE_INVALID_TYPE,this)); +} diff --git a/ReferenceInterface.h b/ReferenceInterface.h index 1ba21ed..cf54f4a 100644 --- a/ReferenceInterface.h +++ b/ReferenceInterface.h @@ -22,7 +22,8 @@ public : ReferenceInterface(AbstractBlock* _owner, const QString& _name, int _direction, int _purpose, const QString& _type, const QString& _width, int _endianess = LittleEndian, int _multiplicity=1) throw (Exception); // getters - inline int getMultiplicity() { return multiplicity; } + inline int getMultiplicity() { return multiplicity; } + int getClockDomain() throw(Exception); // determine at which freq. is synchronized iface // setters void setMultiplicity(int _multiplicity); diff --git a/SpecialBlock.cpp b/SpecialBlock.cpp index fdec328..9576dc9 100644 --- a/SpecialBlock.cpp +++ b/SpecialBlock.cpp @@ -1,7 +1,7 @@ #include "SpecialBlock.h" #include "FunctionalInterface.h" -SpecialBlock::SpecialBlock(int _type, GroupBlock* _parent, ReferenceBlock* _reference, bool createIfaces) throw(Exception) : FunctionalBlock(_parent, _reference, createIfaces) { +SpecialBlock::SpecialBlock(Graph *_graph, int _type, GroupBlock* _parent, ReferenceBlock* _reference, bool createIfaces) throw(Exception) : FunctionalBlock(_graph, _parent, _reference, createIfaces) { specialType = _type; } @@ -58,7 +58,7 @@ void SpecialBlock::checkInputPatternCompatibilitySource() throw(Exception) { } void SpecialBlock::computeOutputPatternSource(int nbExec) throw(Exception) { - cout << "computing output pattern of " << qPrintable(name) << " for " << nbExec << " executions" << endl; + cout << "computing output pattern of special block " << qPrintable(name) << " for " << nbExec << " executions" << endl; foreach(AbstractInterface* iface, getControlOutputs()) { FunctionalInterface* connIface = AI_TO_FUN(iface); // create output pattern @@ -97,14 +97,15 @@ void SpecialBlock::computeOutputPatternClockConvert(int nbExec) throw(Exception) #ifdef DEBUG_FCTNAME cout << "call to " << qPrintable(fctName) << endl; #endif - cout << "computing output pattern of " << qPrintable(name) << endl; + cout << "computing output pattern of special block " << qPrintable(name) << endl; /* CAUTION: it is assumed that all clock domain converters are using * a clk_in and clk_out signals for input and output clocks. */ AbstractInterface* clkIn = getIfaceFromName("clk_in"); AbstractInterface* clkOut = getIfaceFromName("clk_out"); - //cout << "freq clk_in = " << clkIn- + 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) { diff --git a/SpecialBlock.h b/SpecialBlock.h index aff0d6b..5e47cd9 100644 --- a/SpecialBlock.h +++ b/SpecialBlock.h @@ -16,7 +16,7 @@ using namespace Qt; class SpecialBlock : public FunctionalBlock { public: - SpecialBlock(int _type, GroupBlock* _parent, ReferenceBlock* _reference, bool createIfaces = true) throw(Exception); + SpecialBlock(Graph* _graph, int _type, GroupBlock* _parent, ReferenceBlock* _reference, bool createIfaces = true) throw(Exception); ~SpecialBlock(); // getters diff --git a/blast.creator.user b/blast.creator.user index 7270400..1890744 100644 --- a/blast.creator.user +++ b/blast.creator.user @@ -1,10 +1,10 @@ - + EnvironmentId - {c8006d66-d34f-42be-ad10-d0207752286d} + {3701e197-5b6c-48ea-9e98-a6cf6de18672} ProjectExplorer.Project.ActiveTarget @@ -61,7 +61,7 @@ Desktop Desktop - {2c9bf876-3476-44eb-8065-1f0844704dda} + {ed04208c-8774-456b-99b9-4a02094ca7a4} 0 0 0