#include <QMessageBox>\r
#include "AbstractInterface.h"\r
#include "BlockParameter.h"\r
+#include "GroupBlock.h"\r
+#include "ConnectedInterface.h"\r
\r
AbstractBlock::AbstractBlock() {\r
name = "";\r
parent = NULL;\r
}\r
\r
+/*\r
AbstractBlock::AbstractBlock(const QString& _name) {\r
name = normalizeName(_name);\r
parent = NULL;\r
}\r
+*/\r
\r
AbstractBlock::~AbstractBlock() {\r
\r
return s;\r
}\r
\r
+void AbstractBlock::connectClkReset() throw(Exception) {\r
+\r
+ GroupBlock* parentBlock = AB_TO_GRP(parent);\r
+\r
+ cout << "connecting clk/rst for child " << qPrintable(name) << " of " << qPrintable(parentBlock->getName()) << endl;\r
+\r
+ QList<AbstractInterface* > lstClk = getInterfaces(AbstractInterface::Input,AbstractInterface::Clock);\r
+ QList<AbstractInterface* > lstRst = getInterfaces(AbstractInterface::Input,AbstractInterface::Reset);\r
+\r
+ if ((lstClk.isEmpty()) || (lstRst.isEmpty())) {\r
+ throw(Exception(IFACE_GROUP_NOCLKRST,this));\r
+ }\r
+\r
+ ConnectedInterface* toClk = AI_TO_CON(lstClk.at(0));\r
+ ConnectedInterface* toRst = AI_TO_CON(lstRst.at(0));\r
+\r
+ ConnectedInterface* fromClk = NULL;\r
+ ConnectedInterface* fromRst = NULL;\r
+\r
+ if (parentBlock->isTop()) {\r
+ AbstractBlock* clkrstgen = parentBlock->getFunctionalBlockByName("clkrstgen");\r
+ if (clkrstgen == NULL) {\r
+ throw(Exception(IFACE_TOP_NOCLKRSTGEN,this));\r
+ }\r
+ else {\r
+ fromClk = AI_TO_CON(clkrstgen->getIfaceFromName("clk"));\r
+ fromRst = AI_TO_CON(clkrstgen->getIfaceFromName("reset"));\r
+ }\r
+ }\r
+ else {\r
+ fromClk = AI_TO_CON(parentBlock->getIfaceFromName("clk"));\r
+ fromRst = AI_TO_CON(parentBlock->getIfaceFromName("reset"));\r
+ }\r
+ if ((fromClk == NULL) || (fromRst == NULL)) {\r
+ throw(Exception(IFACE_GROUP_NOCLKRST,parentBlock));\r
+ }\r
+ else {\r
+ fromClk->connectTo(toClk);\r
+ fromRst->connectTo(toRst);\r
+ }\r
+\r
+\r
+}\r
+\r
+\r
\r
public: \r
\r
AbstractBlock();\r
- AbstractBlock(const QString& _name);\r
+ //AbstractBlock(const QString& _name);\r
virtual ~AbstractBlock();\r
\r
// getters\r
inline QList<BlockParameter *> getParameters() { return params; }\r
inline QList<AbstractInterface*> getInputs() { return inputs; }\r
inline QList<AbstractInterface*> getOutputs() { return outputs; }\r
- inline QList<AbstractInterface*> getBidirs() { return bidirs; }\r
+ inline QList<AbstractInterface*> getBidirs() { return bidirs; } \r
QList<BlockParameter *> getUserParameters();\r
QList<BlockParameter *> getGenericParameters();\r
QList<BlockParameter *> getPortParameters();\r
\r
// others\r
static QString normalizeName(const QString& name);\r
+ void connectClkReset() throw(Exception);\r
\r
virtual void parametersValidation(QList<AbstractBlock*>* checkedBlocks, QList<AbstractBlock*>* blocksToConfigure) = 0; // ugly but usefull \r
\r
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;
#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
lengthPP = -1;\r
delta = -1;\r
evaluator = NULL;\r
+\r
}\r
\r
FunctionalBlock::~FunctionalBlock() {\r
addParameter(p);\r
}\r
\r
+ ConnectedInterface* toClk = NULL;\r
+ ConnectedInterface* toRst = NULL;\r
// create interfaces from reference block\r
QList<AbstractInterface *> lstRef = reference->getInterfaces();\r
// store relation between functional and reference\r
exit(1);\r
}\r
hashIface.insert(lstRef.at(i),inter);\r
-\r
addInterface(inter);\r
+ /* WARNING FOR THE FUTURE :\r
+ in case of there are several clock interfaces ofr that block\r
+ it would be a godd idea to make the user choose which one\r
+ must be connected to defautl clk.\r
+ Presently, the first encountered is chosen\r
+ */\r
+ if ((toClk == NULL) && (inter->getPurpose() == AbstractInterface::Clock)) {\r
+ toClk = AI_TO_CON(inter);\r
+ }\r
+ if ((toRst == NULL) && (inter->getPurpose() == AbstractInterface::Reset)) {\r
+ toRst = AI_TO_CON(inter);\r
+ }\r
}\r
\r
AbstractInterface* funCtlIface = NULL;\r
} \r
}\r
}\r
-}\r
\r
+ // connect clk and rst to group clk/rst or to clkrstgen\r
+ if ((name != "clkrstgen") && (parent != NULL)) {\r
+ try {\r
+ connectClkReset();\r
+ }\r
+ catch(Exception e) {\r
+ AbstractBlock* source = (AbstractBlock *)(e.getSource());\r
+ cerr << qPrintable(source->getName()) << ":" << qPrintable(e.getMessage()) << endl;\r
+ throw(e);\r
+ }\r
+ }\r
+}\r
\r
QString FunctionalBlock::getReferenceXmlFile() {\r
return ((ReferenceBlock *)reference)->getXmlFile();\r
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() {
inline void addBlock(AbstractBlock* block) { blocks.append(block); }
void removeBlock(AbstractBlock* block);
AbstractBlock* getFunctionalBlockByName(QString name);
-
+
void removeAllBlocks();
void parametersValidation(QList<AbstractBlock *> *checkedBlocks, QList<AbstractBlock*>* blocksToConfigure);
void addGenericParameter(QString name, QString type, QString value);
}
else {
QDomText txtName = nodeNameTxt.toText();
- name = txtName.data().trimmed();
+ name = normalizeName(txtName.data().trimmed());
cout<< "block name : " << qPrintable(name) << endl;
}
// does strictly nothing
throw(Exception(INVALID_REFBLOCK_USE));
}
+
+
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 4.2.0, 2018-01-24T18:18:10. -->
+<!-- Written by QtCreator 4.2.0, 2018-01-24T21:11:11. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
- <value type="QByteArray">{3701e197-5b6c-48ea-9e98-a6cf6de18672}</value>
+ <value type="QByteArray">{c8006d66-d34f-42be-ad10-d0207752286d}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
- <value type="QByteArray" key="CurrentPreferences">qt2</value>
+ <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
- <value type="int" key="EditorConfiguration.IndentSize">2</value>
+ <value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
- <value type="int" key="EditorConfiguration.TabSize">4</value>
- <value type="bool" key="EditorConfiguration.UseGlobal">false</value>
+ <value type="int" key="EditorConfiguration.TabSize">8</value>
+ <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
- <value type="bool" key="EditorConfiguration.cleanWhitespace">false</value>
+ <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
</valuemap>
</data>
<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">{ed04208c-8774-456b-99b9-4a02094ca7a4}</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{2c9bf876-3476-44eb-8065-1f0844704dda}</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.RunConfiguration.0">
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
- <value type="uint" key="Analyzer.QmlProfiler.FlushInterval">0</value>
+ <value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
- <value type="bool" key="ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal">false</value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">%{buildDir}</value>
- <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Exécutable personnalisé</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Custom Executable</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>