#include "ConnectedInterface.h"\r
\r
\r
-AbstractBlock::AbstractBlock() {\r
+AbstractBlock::AbstractBlock(Graph *_graph) {\r
name = "";\r
parent = NULL;\r
specialType = NotSpecial;\r
+ graph = _graph;\r
}\r
\r
/*\r
#include "AbstractInterface.h"\r
class AbstractInterface;\r
class BlockParameter;\r
+class Graph;\r
\r
#define AB_TO_REF(ptr) ((ReferenceBlock*)ptr)\r
#define AB_TO_FUN(ptr) ((FunctionalBlock*)ptr)\r
enum SpecialType { NotSpecial = 0, Source = 1, Sink = 2, ClkConvert = 3 };\r
\r
\r
- AbstractBlock();\r
+ AbstractBlock(Graph* _graph);\r
//AbstractBlock(const QString& _name);\r
virtual ~AbstractBlock();\r
\r
inline int getSpecialType() { return specialType; }\r
inline QString getVersion() { return version; }\r
inline int nbParameters() { return params.size(); }\r
+ inline Graph* getGraph() { return graph; }\r
\r
inline QList<AbstractInterface*> getInputs() { return inputs; }\r
inline QList<AbstractInterface*> getOutputs() { return outputs; }\r
QString name;\r
int specialType;\r
QString version;\r
+ Graph* graph;\r
\r
// parameters\r
QList<BlockParameter *> params;\r
#include "BlockParameterPort.h"
#include "AbstractBlock.h"
#include "Parameters.h"
+#include "Graph.h"
AbstractInterface::AbstractInterface(AbstractBlock* _owner) {
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)) {
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
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
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;
#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
#include "ArithmeticEvaluator.h"\r
\r
\r
-FunctionalBlock::FunctionalBlock(GroupBlock *_parent, ReferenceBlock *_reference, bool createIfaces) throw(Exception) : AbstractBlock() {\r
+FunctionalBlock::FunctionalBlock(Graph *_graph, GroupBlock *_parent, ReferenceBlock *_reference, bool createIfaces) throw(Exception) : AbstractBlock(_graph) {\r
//if (! _reference->isReferenceBlock()) throw(Exception(BLOCK_INVALID_TYPE));\r
//if (! _group->isGroupBlock()) throw(Exception(BLOCK_INVALID_TYPE));\r
reference = _reference;\r
class FunctionalBlock : public AbstractBlock {\r
public:\r
\r
- FunctionalBlock(GroupBlock* _parent, ReferenceBlock* _reference, bool createIfaces = true) throw(Exception);\r
+ FunctionalBlock(Graph* _graph, GroupBlock* _parent, ReferenceBlock* _reference, bool createIfaces = true) throw(Exception);\r
~FunctionalBlock();\r
// getters\r
inline ReferenceBlock* getReference() { return reference; }\r
#include "FunctionalBlock.h"\r
#include "GroupBlock.h"\r
\r
-\r
FunctionalInterface::FunctionalInterface(AbstractBlock* _owner, ReferenceInterface *_reference) throw(Exception) : ConnectedInterface(_owner) {\r
\r
if (_owner == NULL) throw(Exception(BLOCK_NULL));\r
return false;\r
}\r
\r
+int FunctionalInterface::getClockDomain() throw(Exception) {\r
+\r
+ int idClock = -1;\r
+\r
+ FunctionalInterface* iface = NULL;\r
+ if (clkIfaceType == ClockName) {\r
+ iface = AI_TO_FUN(getClockIface());\r
+ }\r
+ else if ((direction == Input) && (purpose == Clock)) {\r
+ iface = this;\r
+ }\r
+\r
+ if ( iface != NULL) {\r
+\r
+ // if iface is a functional interface, it is connected to clkrstgen_X (in top group) or to ext_clk_X (in subgroup)\r
+ ConnectedInterface* connFrom = iface->getConnectedFrom();\r
+ if (connFrom == NULL) throw(Exception(IFACE_INVALID_CLKFREQ,this));\r
+\r
+ if (connFrom->getOwner()->isFunctionalBlock()) {\r
+ QString name = connFrom->getOwner()->getName();\r
+ cout << "conn from clkrstgen: searching for clkdomain in " << qPrintable(name) << endl;\r
+ name.remove(0,10);\r
+ bool ok;\r
+ idClock = name.toInt(&ok);\r
+ if (!ok) throw(Exception(IFACE_INVALID_CLKFREQ,this));\r
+ }\r
+ else {\r
+ QString name = connFrom->getName();\r
+ cout << "conn from group: searching for clkdomain in " << qPrintable(name) << endl;\r
+ name.remove(0,8);\r
+ bool ok;\r
+ idClock = name.toInt(&ok);\r
+ if (!ok) throw(Exception(IFACE_INVALID_CLKFREQ,this));\r
+ }\r
+ }\r
+\r
+ return idClock;\r
+}\r
+\r
\r
void FunctionalInterface::connectionsValidation(QStack<AbstractInterface *> *interfacetoValidate, QList<AbstractInterface *> *validatedInterfaces) throw(Exception) {\r
\r
\r
// getters\r
inline ReferenceInterface* getReference() { return reference; }\r
+ int getClockDomain() throw(Exception); // determine at which freq. is synchronized iface\r
//inline QList<char>* getConsumptionPattern() { return consumptionPattern; }\r
//inline QList<char>* getProductionPattern() { return productionPattern; } \r
\r
}
void Graph::createTopGroup(bool createTopGroupIfaces) {
- topGroup = new GroupBlock(NULL, createTopGroupIfaces);
+ topGroup = new GroupBlock(this, NULL, createTopGroupIfaces);
topGroup->setName("top group");
groups.append(topGroup);
}
}
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;
}
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);
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;
}
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;
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
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<AbstractInterface*> *interfacetoValidate, QList<AbstractInterface*> *validatedInterfaces) throw(Exception) {
cout << "group interface connection validation" << endl;
}
// getters
int getWidth();
-
+ int getClockDomain() throw(Exception); // determine at which freq. is synchronized iface
// setters
// testers
return ref;\r
}\r
\r
-double Parameters::getFeedingClockFrequency(AbstractInterface *iface) {\r
-\r
- int idClock = 0;\r
-\r
- if (iface->isReferenceInterface()) return 0.0;\r
-\r
- if (iface->getClockIfaceType() == AbstractInterface::ParameterName) {\r
- BlockParameter* param = iface->getOwner()->getParameterFromName(iface->getClockIfaceString());\r
- if (!param->isUserParameter()) return 0.0;\r
- bool ok;\r
- double freq = param->getDoubleValue(&ok);\r
- if (!ok) {\r
- cerr << "Abnormal case: cannot retrieve clock id from parameter " << qPrintable(param->getName()) << endl;\r
- }\r
- return freq;\r
- }\r
- else if ( (iface->getClockIfaceType() == AbstractInterface::ClockName) || ((iface->getDirection() == AbstractInterface::Input) && (iface->getPurpose() == AbstractInterface::Clock))) {\r
-\r
- // if iface is not clock, retrieve the clock related to it\r
- if (iface->getClockIfaceType() == AbstractInterface::ClockName) {\r
- iface = iface->getClockIface();\r
- }\r
- // if iface is a group interface, then iface name is ext_clk_X, thus extract the X\r
- if (iface->isGroupInterface()) {\r
- QString name = iface->getName();\r
- name.remove(0,8);\r
- bool ok;\r
- idClock = name.toInt(&ok);\r
- if (!ok) {\r
- cerr << "Abnormal case: cannot retrieve clock id from iface name " << qPrintable(iface->getName()) << endl;\r
- return 0.0;\r
- }\r
- }\r
- // if iface is a functional interface, it is connected to clkrstgen_X (in top group) or to ext_clk_X (in subgroup)\r
- else if (iface->isFunctionalInterface()) {\r
- FunctionalInterface* funIface = AI_TO_FUN(iface);\r
- ConnectedInterface* connFrom = funIface->getConnectedFrom();\r
- if (connFrom == NULL) {\r
- cerr << "Abnormal case: input clock " << qPrintable(iface->getName()) << " is not connected" << endl;\r
- return 0.0;\r
- }\r
- if (iface->getOwner()->isTopGroupBlock()) {\r
- QString name = connFrom->getOwner()->getName();\r
- name.remove(0,10);\r
- bool ok;\r
- idClock = name.toInt(&ok);\r
- if (!ok) {\r
- cerr << "Abnormal case: cannot retrieve clock id for " << qPrintable(iface->getName()) << endl;\r
- return 0.0;\r
- }\r
- }\r
- else {\r
- QString name = connFrom->getName();\r
- name.remove(0,8);\r
- bool ok;\r
- idClock = name.toInt(&ok);\r
- if (!ok) {\r
- cerr << "Abnormal case: cannot retrieve clock id for " << qPrintable(iface->getName()) << endl;\r
- return 0.0;\r
- }\r
- }\r
- }\r
- }\r
- return graph->getClock(idClock);\r
-}\r
\r
void Parameters::createDelayBlock() {\r
delayRef = new ReferenceBlock("no.xml");\r
void destroyGraph();\r
inline Graph* getGraph() { return graph; } \r
ReferenceBlock* getReferenceBlock(int idCategory, int idBlock); // get the reference block from its category and index\r
- ReferenceBlock* getHiddenReferenceBlock(QString blockName); // get a hidden block by name, i.e. in category 100 \r
- double getFeedingClockFrequency(AbstractInterface* iface); // determine at which freq. is synchronized iface\r
+ ReferenceBlock* getHiddenReferenceBlock(QString blockName); // get a hidden block by name, i.e. in category 100 \r
\r
void clear();\r
\r
#include "BlockParameterWishbone.h"
#include "Parameters.h"
-ReferenceBlock::ReferenceBlock(const QString _xmlFile) : AbstractBlock() {
+ReferenceBlock::ReferenceBlock(const QString _xmlFile) : AbstractBlock(NULL) {
xmlFile = _xmlFile;
}
return list;
}
+
}
return mult;
}
+
+int ReferenceInterface::getClockDomain() throw(Exception) {
+
+ throw(Exception(IFACE_INVALID_TYPE,this));
+}
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);
#include "SpecialBlock.h"\r
#include "FunctionalInterface.h"\r
\r
-SpecialBlock::SpecialBlock(int _type, GroupBlock* _parent, ReferenceBlock* _reference, bool createIfaces) throw(Exception) : FunctionalBlock(_parent, _reference, createIfaces) {\r
+SpecialBlock::SpecialBlock(Graph *_graph, int _type, GroupBlock* _parent, ReferenceBlock* _reference, bool createIfaces) throw(Exception) : FunctionalBlock(_graph, _parent, _reference, createIfaces) {\r
specialType = _type;\r
}\r
\r
}\r
void SpecialBlock::computeOutputPatternSource(int nbExec) throw(Exception) {\r
\r
- cout << "computing output pattern of " << qPrintable(name) << " for " << nbExec << " executions" << endl;\r
+ cout << "computing output pattern of special block " << qPrintable(name) << " for " << nbExec << " executions" << endl;\r
foreach(AbstractInterface* iface, getControlOutputs()) {\r
FunctionalInterface* connIface = AI_TO_FUN(iface);\r
// create output pattern\r
#ifdef DEBUG_FCTNAME\r
cout << "call to " << qPrintable(fctName) << endl;\r
#endif\r
- cout << "computing output pattern of " << qPrintable(name) << endl;\r
+ cout << "computing output pattern of special block " << qPrintable(name) << endl;\r
\r
/* CAUTION: it is assumed that all clock domain converters are using\r
* a clk_in and clk_out signals for input and output clocks.\r
*/\r
AbstractInterface* clkIn = getIfaceFromName("clk_in");\r
AbstractInterface* clkOut = getIfaceFromName("clk_out");\r
- //cout << "freq clk_in = " << clkIn-\r
+ cout << "freq clk_in = " << clkIn->getClockFrequency() << endl;\r
+ cout << "freq clk_out = " << clkOut->getClockFrequency() << endl;\r
\r
// in case of inputPattern not created, do it\r
if (lengthIP <= 0) {\r
class SpecialBlock : public FunctionalBlock {\r
public: \r
\r
- SpecialBlock(int _type, GroupBlock* _parent, ReferenceBlock* _reference, bool createIfaces = true) throw(Exception);\r
+ SpecialBlock(Graph* _graph, int _type, GroupBlock* _parent, ReferenceBlock* _reference, bool createIfaces = true) throw(Exception);\r
~SpecialBlock();\r
// getters \r
\r
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 4.2.0, 2018-05-03T21:14:33. -->
+<!-- Written by QtCreator 4.2.0, 2018-05-04T14:41:26. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
- <value type="QByteArray">{c8006d66-d34f-42be-ad10-d0207752286d}</value>
+ <value type="QByteArray">{3701e197-5b6c-48ea-9e98-a6cf6de18672}</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">{ed04208c-8774-456b-99b9-4a02094ca7a4}</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>