return lst;\r
}\r
\r
+void AbstractBlock::connectClock(QString clkName, int idGen) throw(Exception) {\r
\r
+ GroupBlock* parentBlock = AB_TO_GRP(parent); \r
+ ConnectedInterface* fromClk = NULL;\r
+ ConnectedInterface* toClk = AI_TO_CON(getIfaceFromName(clkName));\r
\r
-void AbstractBlock::connectClkReset() throw(Exception) {\r
-\r
- GroupBlock* parentBlock = AB_TO_GRP(parent);\r
-\r
-\r
-\r
- QList<AbstractInterface* > lstClk = getInterfaces(AbstractInterface::Input,AbstractInterface::Clock);\r
- QList<AbstractInterface* > lstRst = getInterfaces(AbstractInterface::Input,AbstractInterface::Reset);\r
+ if (parentBlock->isTop()) {\r
+ QString genName = "clkrstgen_" + QString::number(idGen);\r
+ AbstractBlock* clkrstgen = parentBlock->getFunctionalBlockByName(genName);\r
+ if (clkrstgen == NULL) {\r
+ throw(Exception(IFACE_TOP_NOCLKRSTGEN,this));\r
+ }\r
+ else {\r
+ fromClk = AI_TO_CON(clkrstgen->getIfaceFromName("clk")); \r
+ }\r
+ cout << "connecting clock for " << qPrintable(name) << " to " << qPrintable(genName) << endl;\r
+ }\r
+ else {\r
+ // searching for ext_clk_idGen\r
+ QString name = "ext_clk_"+QString::number(idGen);\r
+ fromClk = AI_TO_CON(parentBlock->getIfaceFromName(name));\r
+ cout << "connecting clk for child " << qPrintable(name) << " of " << qPrintable(parentBlock->getName()) << endl;\r
+ }\r
\r
- if ((lstClk.isEmpty()) || (lstRst.isEmpty())) {\r
- throw(Exception(IFACE_GROUP_NOCLKRST,this));\r
+ if (fromClk == NULL) {\r
+ throw(Exception(IFACE_GROUP_NOCLKRST,parentBlock));\r
+ }\r
+ else {\r
+ fromClk->connectTo(toClk);\r
+ cout << "connection done between " << qPrintable(toClk->getConnectedFrom()->getOwner()->getName()) << "/" << qPrintable(toClk->getConnectedFrom()->getName());\r
+ cout << " and " << qPrintable(toClk->getOwner()->getName()) << "/" << qPrintable(toClk->getName()) << endl;\r
}\r
+}\r
\r
- ConnectedInterface* toClk = AI_TO_CON(lstClk.at(0));\r
- ConnectedInterface* toRst = AI_TO_CON(lstRst.at(0));\r
+void AbstractBlock::connectReset(QString rstName, int idGen) throw(Exception) {\r
\r
- ConnectedInterface* fromClk = NULL;\r
+ GroupBlock* parentBlock = AB_TO_GRP(parent);\r
ConnectedInterface* fromRst = NULL;\r
+ ConnectedInterface* toRst = AI_TO_CON(getIfaceFromName(rstName));\r
\r
if (parentBlock->isTop()) {\r
- AbstractBlock* clkrstgen = parentBlock->getFunctionalBlockByName("clkrstgen");\r
+ QString genName = "clkrstgen_" + QString::number(idGen);\r
+ AbstractBlock* clkrstgen = parentBlock->getFunctionalBlockByName(genName);\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
- cout << "connecting clk/rst for " << qPrintable(name) << " to clkrstgen" << endl;\r
+ cout << "connecting reset for " << qPrintable(name) << " to " << qPrintable(genName) << endl;\r
}\r
else {\r
- fromClk = AI_TO_CON(parentBlock->getIfaceFromName("clk"));\r
- fromRst = AI_TO_CON(parentBlock->getIfaceFromName("reset"));\r
- cout << "connecting clk/rst for child " << qPrintable(name) << " of " << qPrintable(parentBlock->getName()) << endl;\r
+ QString name = "ext_reset_"+QString::number(idGen);\r
+ fromRst = AI_TO_CON(parentBlock->getIfaceFromName(name));\r
+ cout << "connecting reset for child " << qPrintable(name) << " of " << qPrintable(parentBlock->getName()) << endl;\r
}\r
- if ((fromClk == NULL) || (fromRst == NULL)) {\r
+\r
+ if (fromRst == NULL) {\r
throw(Exception(IFACE_GROUP_NOCLKRST,parentBlock));\r
}\r
else {\r
- fromClk->connectTo(toClk);\r
fromRst->connectTo(toRst);\r
- cout << "connection done between " << qPrintable(toClk->getConnectedFrom()->getOwner()->getName()) << "/" << qPrintable(toClk->getConnectedFrom()->getName());\r
- cout << " and " << qPrintable(toClk->getOwner()->getName()) << "/" << qPrintable(toClk->getName()) << endl;\r
+ cout << "connection done between " << qPrintable(toRst->getConnectedFrom()->getOwner()->getName()) << "/" << qPrintable(toRst->getConnectedFrom()->getName());\r
+ cout << " and " << qPrintable(toRst->getOwner()->getName()) << "/" << qPrintable(toRst->getName()) << endl;\r
}\r
}\r
\r
bool isWBConfigurable();\r
\r
// others\r
- void connectClkReset() throw(Exception); \r
+\r
+ /*!\r
+ * \brief connectClkReset connects the clock and reset inputs to a clkrstgen block or the the group ifaces\r
+ * \param idBlockClk is the id of the clock interface (there may be severals)\r
+ * \param idGen is the id of the clkrstgen block\r
+ */\r
+ void connectClock(QString clkName, int idGen = 0) throw(Exception);\r
+ void connectReset(QString rstName, int idGen = 0) throw(Exception);\r
virtual QList<QString> getExternalResources() = 0; // returns the list of all external files needed for VHDL generation\r
virtual void generateVHDL(const QString& path) throw(Exception) = 0; // main entry to generate the VHDL code\r
void generateComponent(QTextStream& out, bool hasController=false) throw(Exception); // generate the component using reference\r
return true;
}
+AbstractInterface* AbstractInterface::getClockIface() {
+ if (clkIfaceType == ClockName) {
+ return owner->getIfaceFromName(clkIface);
+ }
+ return NULL;
+}
+
bool AbstractInterface::setClockIface(QString name) {
/* 2 cases :
* - this is a Data interface
QString getDirectionString();
inline AbstractBlock *getOwner() { return owner;}
inline AbstractInterface* getAssociatedIface() { return associatedIface; }
- inline QString getClockIface() { return clkIface; }
+ inline QString getClockIfaceString() { return clkIface; }
inline int getClockIfaceType() { return clkIfaceType; }
+ AbstractInterface* getClockIface();
double getDoubleWidth() throw(QException);
dispatcher = _dispatcher;
params = _params;
+ nbClock = 0;
+ comboClkGen = NULL;
+ nbRst = 0;
+ comboRstGen = NULL;
+
// creating the widget : tree, buttons, ...
QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom, this);
tree = new QTreeWidget(this);
buttonAdd->setEnabled(false);
comboScenes = new QComboBox();
- QHBoxLayout* layBottom = new QHBoxLayout;
- layBottom->addWidget(buttonAdd);
- layBottom->addWidget(comboScenes);
+ QHBoxLayout* layAdd = new QHBoxLayout;
+ layAdd->addWidget(buttonAdd);
+ layAdd->addWidget(comboScenes);
+
+ layClkRst = new QGridLayout;
+
+ boxClkRst = new QGroupBox("Clock/reset connection");
+ boxClkRst->setLayout(layClkRst);
+
+ QVBoxLayout* layBottom = new QVBoxLayout;
+ layBottom->addLayout(layAdd);
+ layBottom->addWidget(boxClkRst);
+
connect(tree, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(clicked()));
connect(tree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(doubleClicked()));
- connect(buttonAdd, SIGNAL(clicked()), this, SLOT(addClicked()));
+ connect(buttonAdd, SIGNAL(clicked()), this, SLOT(addClicked()));
BlockCategory* cat = params->categoryTree->searchCategory(0);
layout->addLayout(layBottom);
this->setLayout(layout);
- this->setFixedSize(300,230);
+ //this->setFixedSize(300,230);
}
QTreeWidgetItem *item = tree->selectedItems().at(0);
if(item->data(1,Qt::DisplayRole).isValid() && item->data(2,Qt::DisplayRole).isValid()){
- int idParent = item->data(1,Qt::DisplayRole).toInt();
+ int idCat = item->data(1,Qt::DisplayRole).toInt();
int idBlock = item->data(2,Qt::DisplayRole).toInt();
- QVariant v = comboScenes->currentData();
+ QVariant v = comboScenes->currentData();
+
cout << "adding block to scene " << v.toInt() << endl;
- dispatcher->addBlock(Dispatcher::Design, idParent, idBlock, v.toInt());
+
+ QHash<QString, int> clkRstToGen;
+ for(int i=0;i<layClkRst->rowCount();i++) {
+ QLayoutItem* item = layClkRst->itemAtPosition(i,0);
+ QLabel* lab = (QLabel *)(item->widget());
+ item = layClkRst->itemAtPosition(i,1);
+ QComboBox* combo = (QComboBox *)(item->widget());
+ clkRstToGen.insert(lab->text(),combo->currentIndex());
+ }
+
+
+ dispatcher->addBlock(Dispatcher::Design, idCat, idBlock, v.toInt(), clkRstToGen);
}
// only take the first selected
void BlockLibraryWidget::clicked() {
if(tree->selectedItems().length() > 0){
QTreeWidgetItem *item = tree->selectedItems().at(0);
- if(item->data(1,Qt::DisplayRole).isValid())
+ if(item->data(1,Qt::DisplayRole).isValid()) {
buttonAdd->setEnabled(true);
- else
+ int idParent = item->data(1,Qt::DisplayRole).toInt();
+ int idBlock = item->data(2,Qt::DisplayRole).toInt();
+ updateClkRst(idParent, idBlock);
+ }
+ else {
buttonAdd->setEnabled(false);
+ }
}
}
comboScenes->addItem(iter.value(),QVariant(iter.key()));
}
}
+
+void BlockLibraryWidget::updateClkRst(int idCat, int idBlock) {
+
+ while (layClkRst->count() > 0) {
+ QWidget* widget = layClkRst->itemAt(0)->widget();
+ layClkRst->removeWidget(widget);
+ delete widget;
+ }
+
+ if (nbClock != 0) {
+ for(int i=0;i<nbClock;i++) {
+ comboClkGen[i]->deleteLater();
+ }
+ delete [] comboClkGen;
+ }
+ if (nbRst != 0) {
+ for(int i=0;i<nbRst;i++) {
+ comboRstGen[i]->deleteLater();
+ }
+ delete [] comboRstGen;
+ }
+
+ ReferenceBlock* ref = params->getReferenceBlock(idCat,idBlock);
+ QList<AbstractInterface*> lstClocks = ref->getInterfaces(AbstractInterface::Input, AbstractInterface::Clock);
+ nbClock = lstClocks.size();
+ QList<AbstractInterface*> lstRst = ref->getInterfaces(AbstractInterface::Input, AbstractInterface::Reset);
+ nbRst = lstRst.size();
+
+ comboClkGen = new QComboBox*[lstClocks.size()];
+ for(int i=0;i<lstClocks.size();i++) {
+ comboClkGen[i] = new QComboBox();
+ QString name = "";
+ int id = 0;
+ foreach(double d, params->clocks) {
+ name = "ext_clk_"+QString::number(id)+" (";
+ name += QString::number(d) + " MHz)";
+ comboClkGen[i]->addItem(name);
+ id++;
+ }
+ }
+
+ comboRstGen = new QComboBox*[lstRst.size()];
+ for(int i=0;i<lstRst.size();i++) {
+ comboRstGen[i] = new QComboBox();
+ QString name = "";
+ for(int j=0;j<params->clocks.size();j++) {
+ name = "ext_rst_"+QString::number(j);
+ comboRstGen[i]->addItem(name);
+ }
+ }
+ layClkRst->addWidget(new QLabel("Clock/Reset name"), 0, 0);
+ layClkRst->addWidget(new QLabel("connect to"), 0, 1);
+ int row = 1;
+ foreach(AbstractInterface* iface, lstClocks) {
+ layClkRst->addWidget(new QLabel(iface->getName()), row,0);
+ layClkRst->addWidget(comboClkGen[row-1],row, 1);
+ row++;
+ }
+ foreach(AbstractInterface* iface, lstRst) {
+ layClkRst->addWidget(new QLabel(iface->getName()), row,0);
+ layClkRst->addWidget(comboRstGen[row-1-nbClock],row, 1);
+ row++;
+ }
+
+}
public slots:
void updateComboScene();
+ void updateClkRst(int idCat, int idBlock);
private slots:
- void addClicked();
- void clicked();
- void doubleClicked();
+ void addClicked();
+ void clicked();
+ void doubleClicked();
private:
QTreeWidget* tree;
QPushButton* buttonAdd;
QComboBox* comboScenes;
+
+ QGroupBox* boxClkRst;
+ QGridLayout* layClkRst;
+ QComboBox** comboClkGen;
+ int nbClock;
+ QComboBox** comboRstGen;
+ int nbRst;
+
// other attributes
void addChild(BlockCategory *catParent, QTreeWidgetItem* itemParent);
//cout << "block abs. pos: " << absPos.x() << "," << absPos.y() << " | ";
//cout << "block current. pos: " << currentPosition.x() << "," << currentPosition.y() << " | ";
- if ((gapX < 0) && (absPos.x() == marginConn)) {
+ if ((position == Left) || (position == Right)) {
+ gapX = 0;
+ }
+ else if ((gapX < 0) && (absPos.x() == marginConn)) {
gapX = 0;
}
else if (absPos.x()+gapX < marginConn) {
gapX = marginConn-absPos.x();
}
- if ((gapY < 0) && (absPos.y() == marginConn)) {
+ if ((position == Top) || (position == Bottom)) {
+ gapY = 0;
+ }
+ else if ((gapY < 0) && (absPos.y() == marginConn)) {
gapY = 0;
}
else if (absPos.y()+gapY < marginConn) {
functionalBlock->addInterface(ctlIface);
}
}
- // connect clk and rst to group clk/rst or to clkrstgen
- if ((name != "clkrstgen") && (parentGroupBlock != NULL)) {
- try {
- functionalBlock->connectClkReset();
- }
- catch(Exception e) {
- AbstractBlock* source = (AbstractBlock *)(e.getSource());
- cerr << qPrintable(source->getName()) << ":" << qPrintable(e.getMessage()) << endl;
- throw(e);
- }
- }
// creating InterfaceItem
createInterfaceItems();
#include "DelayInputModifier.h"
-#include "InterfacePropertiesWindow.h"
+#include "InterfacePropertiesDialog.h"
+
+#include <QHashIterator>
int Dispatcher::sceneCounter = 0;
}
-BoxItem* Dispatcher::addBlock(Context context, int idCategory, int idBlock, int idScene) {
+BoxItem* Dispatcher::addBlock(Context context, int idCategory, int idBlock, int idScene, QHash<QString, int> clkRstToGen) {
static QString fctName = "Dispatcher::addBlock()";
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
scene->createSourceItem(newOne);
}
else {
+
GroupBlock* group = AB_TO_GRP(scene->getGroupItem()->getRefBlock());
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<QString,int> 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());
+ }
+ }
+ }
params->blockToItem.insert(newOne,item);
}
params->unsaveModif = true;
return item;
}
+void Dispatcher::addClkRstGenBlock(Context context, double frequency) {
+ static QString fctName = "Dispatcher::addClkRstGenBlock()";
+#ifdef DEBUG_FCTNAME
+ cout << "call to " << qPrintable(fctName) << endl;
+#endif
+
+
+ if (context == Design) {
+
+ params->clocks.append(frequency);
+
+ // get the top group
+ GroupBlock *group = params->getGraph()->getTopGroup();
+ GroupScene *scene = topGroupWidget->getScene();
+
+ // creating the clkrstgen block
+ ReferenceBlock* ref = params->getHiddenReferenceBlock("clkrstgen");
+ FunctionalBlock* newOne = params->getGraph()->createFunctionalBlock(group, ref, true);
+
+ QString name = "clkrstgen_";
+ name += QString::number(params->clocks.size()-1);
+ newOne->setName(name);
+
+ // creating the box item
+ BoxItem* item = scene->createBoxItem(newOne, BoxItem::Left, AbstractBoxItem::Dimension);
+ item->setVisible(false);
+
+ ConnectedInterface* fromIfaceClk = NULL;
+ ConnectedInterface* fromIfaceReset = NULL;
+ QString clkName = "ext_clk_"+QString::number(params->clocks.size()-1);
+ QString rstName = "ext_reset_"+QString::number(params->clocks.size()-1);
+ fromIfaceClk = new GroupInterface(group,clkName, AbstractInterface::Input, AbstractInterface::Clock);
+ fromIfaceReset = new GroupInterface(group,rstName, AbstractInterface::Input, AbstractInterface::Reset);
+ group->addInterface(fromIfaceClk);
+ group->addInterface(fromIfaceReset);
+ // creating top group ext_clk iface item
+ GroupItem* groupItem = scene->getGroupItem();
+ InterfaceItem* fromIfaceItemClk = new InterfaceItem(0.5 , Parameters::West, fromIfaceClk, groupItem, params, true);
+ groupItem->addInterfaceItem(fromIfaceItemClk,true);
+ // creating top group ext_reset iface item
+ InterfaceItem* fromIfaceItemReset = new InterfaceItem(0.5 , Parameters::West, fromIfaceReset, groupItem, params, false);
+ groupItem->addInterfaceItem(fromIfaceItemReset,true);
+ // connecting ext_clk iface items
+ InterfaceItem* toIfaceItemClk = item->searchInterfaceItemByName("ext_clk");
+ if (toIfaceItemClk == NULL) {
+ cerr << "Abnormal case while connecting top group ext_clk to clkrstgen" << endl;
+ }
+ createConnection(context,fromIfaceItemClk, toIfaceItemClk, false);
+ // connecting ext_reset iface items
+ InterfaceItem* toIfaceItemReset = item->searchInterfaceItemByName("ext_reset");
+ if (toIfaceItemReset == NULL) {
+ cerr << "Abnormal case while connecting top group ext_reset to clkrstgen" << endl;
+ }
+ createConnection(context,fromIfaceItemReset, toIfaceItemReset, false);
+
+ params->blockToItem.insert(newOne,item);
+ params->unsaveModif = true;
+ }
+}
+
+
GroupWidget *Dispatcher::createTopScene(Context context){
static QString fctName = "Dispatcher::createTopScene()";
if (context == Design) {
- // creating the clkrstgen block
- ReferenceBlock* ref = params->getHiddenReferenceBlock("clkrstgen");
- FunctionalBlock* newOne = params->getGraph()->createFunctionalBlock(topBlock, ref, true);
- // creating the clkrstgen item
- BoxItem* clkResetItem = scene->createBoxItem(newOne, BoxItem::TopLeft, AbstractBoxItem::Position | AbstractBoxItem::Dimension, BoxItem::NoSpan);
- params->blockToItem.insert(newOne,clkResetItem);
- // creating top group ext_clk iface item
- ConnectedInterface* fromIfaceClk = AI_TO_CON(topBlock->getIfaceFromName("ext_clk"));
- InterfaceItem* fromIfaceItemClk = new InterfaceItem(0.5 , Parameters::West, fromIfaceClk, group, params, true);
- group->addInterfaceItem(fromIfaceItemClk,true);
- // creating top group ext_reset iface item
- ConnectedInterface* fromIfaceReset = AI_TO_CON(topBlock->getIfaceFromName("ext_reset"));
- InterfaceItem* fromIfaceItemReset = new InterfaceItem(0.5 , Parameters::West, fromIfaceReset, group, params, false);
- group->addInterfaceItem(fromIfaceItemReset,true);
- // connecting ext_clk iface items
- InterfaceItem* toIfaceItemClk = clkResetItem->searchInterfaceItemByName("ext_clk");
- if (toIfaceItemClk == NULL) {
- cerr << "Abnormal case while connecting top group ext_clk to clkrstgen" << endl;
- }
- createConnection(context,fromIfaceItemClk, toIfaceItemClk, false);
- // connecting ext_reset iface items
- InterfaceItem* toIfaceItemReset = clkResetItem->searchInterfaceItemByName("ext_reset");
- if (toIfaceItemReset == NULL) {
- cerr << "Abnormal case while connecting top group ext_reset to clkrstgen" << endl;
- }
- createConnection(context,fromIfaceItemReset, toIfaceItemReset, false);
+ // create clkrstgen
+ double freq = params->clocks.at(0);
+ params->clocks.clear();
+ addClkRstGenBlock(context,freq);
}
-
groupList.append(topGroupWidget);
return topGroupWidget;
}
#ifdef DEBUG_FCTNAME
cout << "call to " << qPrintable(fctName) << endl;
#endif
+ bool createIfaces = true;
+ if (context == Load) {
+ createIfaces = false;
+ }
// getting the parent block in the graph
GroupBlock* parent = AB_TO_GRP(scene->getGroupItem()->getRefBlock());
cout << "new group : parent = "<< qPrintable(parent->getName()) << endl;
- GroupBlock* groupBlock = params->getGraph()->createChildGroupBlock(parent);
+ GroupBlock* groupBlock = params->getGraph()->createChildGroupBlock(parent, createIfaces);
cout << "new group : child = "<< qPrintable(groupBlock->getName()) << ", child of " << qPrintable(groupBlock->getParent()->getName()) << endl;
// creating the BlockItem in the scene
BoxItem* newItem = scene->createBoxItem(groupBlock);
}
void Dispatcher::showProperties(Context context, InterfaceItem *inter) {
- new InterfacePropertiesWindow(inter);
+ QDialog* dial = new InterfacePropertiesDialog(inter);
+ dial->exec();
}
/* connectInterToGroup() :
/**************************
* block ops
*************************/
- BoxItem* addBlock(Context context, int idCategory, int idBlock, int idScene);
+ BoxItem* addBlock(Context context, int idCategory, int idBlock, int idScene, QHash<QString,int> clkRstToGen );
+ void addClkRstGenBlock(Context context, double frequency);
void removeBoxItem(Context context, BoxItem* item);
void duplicateBoxItem(Context context, BoxItem* item);
void renameFunctionalBlock(Context context, BoxItem* item);
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
+ it would be a good idea to make the user choose which one\r
must be connected to defautl clk.\r
Presently, the first encountered is chosen\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
void computeOutputPattern(int nbExec = -1) throw(Exception);\r
void computeAdmittanceDelays() throw(Exception); // compute differences between IP and admittance\r
\r
-private: \r
+protected:\r
// patterns\r
void createDelta() throw(Exception);\r
void createConsumptionPattern() throw(Exception); // initialize a QList<char> for each interface from patterns defined in implementation\r
void createProductionPattern() throw(Exception); // initialize a QList<char> for each interface from patterns defined in implementation\r
void createProductionCounter() throw(Exception); // initialize a QList<int> from counter defined in implementation\r
void createAdmittance(int nbExec) throw(Exception); // initialize a QList<char> from consumption pattern and delta\r
+ void createInputPattern() throw(Exception);\r
\r
void clearConsumptionPattern();\r
- void clearProductionPattern();\r
- void createInputPattern() throw(Exception);\r
+ void clearProductionPattern(); \r
void clearInputPattern();\r
void clearOutputPattern();\r
void clearAdmittanceDelays();\r
GroupBlock::GroupBlock(GroupBlock *_parent, bool createIfaces) throw(Exception) : AbstractBlock() {
+ parent = _parent;
GroupInterface* clk = NULL;
GroupInterface* rst = NULL;
// force topGroup to false if this group has a parent
- if (_parent != NULL) {
+ if (parent != NULL) {
topGroup = false;
name = QString("sub_group")+"_"+QString::number(counter++);
- // creating clk/rst interfaces
- clk = new GroupInterface(this,"clk", AbstractInterface::Input, AbstractInterface::Clock);
- rst = new GroupInterface(this,"reset", AbstractInterface::Input, AbstractInterface::Reset);
- addInterface(clk);
- addInterface(rst);
-
- try {
- connectClkReset();
- }
- catch(Exception e) {
- AbstractBlock* source = (AbstractBlock *)(e.getSource());
- cerr << qPrintable(source->getName()) << ":" << qPrintable(e.getMessage()) << endl;
- throw(e);
- }
}
else {
topGroup = true;
name = QString("top_group");
// creating external clk/rst interfaces
- clk = new GroupInterface(this,"ext_clk", AbstractInterface::Input, AbstractInterface::Clock);
- rst = new GroupInterface(this,"ext_reset", AbstractInterface::Input, AbstractInterface::Reset);
- addInterface(clk);
- addInterface(rst);
- // creating clkrstgen block and connecting it to this: done in Dispatcher since this has no access to library
- cout << "created ext_clk and reset ifaces for top group" << endl;
}
- parent = _parent;
+ if (createIfaces) {
+ if (topGroup) {
+ clk = new GroupInterface(this,"ext_clk_0", AbstractInterface::Input, AbstractInterface::Clock);
+ rst = new GroupInterface(this,"ext_reset_0", AbstractInterface::Input, AbstractInterface::Reset);
+ addInterface(clk);
+ addInterface(rst);
+ }
+ else {
+ // get all clock and reset from parent
+ QList<AbstractInterface*> lstClk = parent->getInterfaces(AbstractInterface::Input, AbstractInterface::Clock);
+ QList<AbstractInterface*> lstRst = parent->getInterfaces(AbstractInterface::Input, AbstractInterface::Reset);
+ foreach(AbstractInterface* iface, lstClk) {
+ clk = new GroupInterface(this,iface->getName(),AbstractInterface::Input, AbstractInterface::Clock);
+ addInterface(clk);
+ }
+ foreach(AbstractInterface* iface, lstRst) {
+ rst = new GroupInterface(this,iface->getName(),AbstractInterface::Input, AbstractInterface::Reset);
+ addInterface(rst);
+ }
+ }
+ }
}
GroupBlock::~GroupBlock() {
QAction* removeAction = NULL;
QAction* renameAction = NULL;
QAction* showParameters = NULL;
+ QAction* addExtClkAction = NULL;
InterfaceItem* ifaceItem = getInterfaceItemFromCursor(event->pos().x(), event->pos().y());
showParameters = menu.addAction("Show parameters");
}
renameAction = menu.addAction("Rename");
+ if (refBlock->isTopGroupBlock()) {
+ addExtClkAction = menu.addAction("Add new external clock/reset");
+ }
+
}
QAction* selectedAction = menu.exec(event->screenPos());
}
else if(selectedAction == showParameters) {
new ParametersWindow(refBlock, params, NULL);
- }
+ }
+ else if (selectedAction == addExtClkAction) {
+ bool ok = false;
+ double freq = QInputDialog::getDouble(NULL,"Adding a clkrstgen","External clock frequency (in MHz)",100,0,100000,1,&ok);
+ if (!ok) return;
+ dispatcher->addClkRstGenBlock(Dispatcher::Design, freq);
+ }
}
InterfaceItem* GroupItem::isHoverInterface(QPointF point) {
if(!ok) throw(Exception(PROJECTFILE_CORRUPTED));
GroupInterface *groupIface = new GroupInterface(groupBlock,name,direction,purpose);
- GroupInterface *groupCtlIface = new GroupInterface(groupBlock,name+"_enb",direction,AbstractInterface::Control);
- groupCtlIface->setAssociatedIface(groupIface);
-
+ groupBlock->addInterface(groupIface);
InterfaceItem *interfaceItem = new InterfaceItem(position,orientation,groupIface,this,params);
interfaceItem->setId(id);
-
- groupBlock->addInterface(groupIface);
- groupBlock->addInterface(groupCtlIface);
addInterfaceItem(interfaceItem, false);
+
+ if (purpose == AbstractInterface::Data) {
+ GroupInterface *groupCtlIface = new GroupInterface(groupBlock,name+"_enb",direction,AbstractInterface::Control);
+ groupCtlIface->setAssociatedIface(groupIface);
+ groupBlock->addInterface(groupCtlIface);
+ }
cout << "interface add to " << groupBlock->getName().toStdString() << endl;
}
--- /dev/null
+#include "InterfacePropertiesDialog.h"
+
+#include "ConnectedInterface.h"
+
+InterfacePropertiesDialog::InterfacePropertiesDialog(InterfaceItem *_inter, QWidget *parent) : QDialog(parent) {
+ inter = _inter;
+ QGroupBox* box = new QGroupBox("Properties");
+ okButton = new QPushButton(tr("OK"));
+
+ QGridLayout* layProp = new QGridLayout;
+
+ int w = inter->refInter->getWidth();
+ QString wStr = "";
+ if (w == -1) {
+ wStr = "invalid_size";
+ }
+ else {
+ if (w == 0) w++; // 0 means a boolean thus, size of 1 bit
+ wStr.setNum(w);
+ }
+
+ layProp->addWidget(new QLabel("Interface properties"), 0, 0);
+ layProp->addWidget(new QLabel(" "), 1, 0);
+
+ layProp->addWidget(new QLabel("Name :"), 2, 0);
+ layProp->addWidget(new QLabel(inter->getName()), 2, 1);
+ layProp->addWidget(new QLabel("Width :"), 3, 0);
+ layProp->addWidget(new QLabel(wStr), 3, 1);
+ layProp->addWidget(new QLabel("Direction :"), 4, 0);
+ layProp->addWidget(new QLabel(inter->refInter->getDirectionString()), 4, 1);
+ layProp->addWidget(new QLabel("Purpose :"), 5, 0);
+ layProp->addWidget(new QLabel(inter->refInter->getPurposeString()), 5, 1);
+ layProp->addWidget(new QLabel("Type :"), 6, 0);
+ layProp->addWidget(new QLabel(inter->refInter->getTypeString()), 6, 1);
+
+ QHBoxLayout* layBottom = new QHBoxLayout;
+ layBottom->addStretch();
+ layBottom->addWidget(okButton);
+
+ QVBoxLayout* layAll = new QVBoxLayout;
+ layAll->addLayout(layProp);
+ layAll->addLayout(layBottom);
+
+ setLayout(layAll);
+
+ connect(okButton,SIGNAL(clicked()),this, SLOT(accept()));
+}
--- /dev/null
+#ifndef __INTERFACEPROPERTIESWINDOW_H__
+#define __INTERFACEPROPERTIESWINDOW_H__
+
+#include <QtWidgets>
+
+#include "InterfaceItem.h"
+
+class InterfacePropertiesDialog : public QDialog {
+
+ Q_OBJECT
+
+public:
+ InterfacePropertiesDialog(InterfaceItem *_inter, QWidget *parent = 0);
+
+private:
+
+ QPushButton *okButton;
+ InterfaceItem *inter;
+
+};
+
+#endif // INTERFACEPROPERTIESWINDOW_H
+++ /dev/null
-#include "InterfacePropertiesWindow.h"
-
-#include "ConnectedInterface.h"
-
-InterfacePropertiesWindow::InterfacePropertiesWindow(InterfaceItem *_inter, QWidget *parent) :
- QWidget(parent)
-{
- inter = _inter;
-
- layout = new QGridLayout;
-
- int w = inter->refInter->getWidth();
- QString wStr = "";
- if (w == -1) {
- wStr = "invalid_size";
- }
- else {
- if (w == 0) w++; // 0 means a boolean thus, size of 1 bit
- wStr.setNum(w);
- }
-
- layout->addWidget(new QLabel("Interface properties"), 0, 0);
- layout->addWidget(new QLabel(" "), 1, 0);
-
- layout->addWidget(new QLabel("Name :"), 2, 0);
- layout->addWidget(new QLabel(inter->getName()), 2, 1);
- layout->addWidget(new QLabel("Width :"), 3, 0);
- layout->addWidget(new QLabel(wStr), 3, 1);
- layout->addWidget(new QLabel("Direction :"), 4, 0);
- layout->addWidget(new QLabel(inter->refInter->getDirectionString()), 4, 1);
- layout->addWidget(new QLabel("Purpose :"), 5, 0);
- layout->addWidget(new QLabel(inter->refInter->getPurposeString()), 5, 1);
- layout->addWidget(new QLabel("Type :"), 6, 0);
- layout->addWidget(new QLabel(inter->refInter->getTypeString()), 6, 1);
-
- this->setLayout(layout);
-
- show();
-}
+++ /dev/null
-#ifndef __INTERFACEPROPERTIESWINDOW_H__
-#define __INTERFACEPROPERTIESWINDOW_H__
-
-#include <QtWidgets>
-
-#include "InterfaceItem.h"
-
-class InterfacePropertiesWindow : public QWidget
-{
- Q_OBJECT
-public:
- explicit InterfacePropertiesWindow(InterfaceItem *_inter, QWidget *parent = 0);
-
-private:
- QGridLayout *layout;
- InterfaceItem *inter;
-
-
-
-};
-
-#endif // INTERFACEPROPERTIESWINDOW_H
GroupWidget* topGroup = dispatcher->loadProject(params->projectFile);
if (topGroup != NULL) {
addTopGroup(topGroup);
- library->updateComboScene();
+ library->updateComboScene();
params->isCurrentProject = true;
enableProjectActions(true, PROJECT_CLOSE | PROJECT_SAVE | PROJECT_SAVEAS | PROJECT_LIB, OP_RAZ);
enableAnalysisActions(true, ANALYSIS_ANALYZE | ANALYSIS_GENERATE, OP_RAZ);
enableAnalysisActions(true, ANALYSIS_ANALYZE | ANALYSIS_GENERATE, OP_RAZ);
GroupWidget* topGroup = dispatcher->createTopScene(Dispatcher::Design);
addTopGroup(topGroup);
- library->updateComboScene();
+ library->updateComboScene();
library->show();
params->isCurrentProject = true;
}
toWrite << iface->getDirection();
toWrite << iface->getMultiplicity();
toWrite << iface->getClockIfaceType();
- toWrite << iface->getClockIface();
+ toWrite << iface->getClockIfaceString();
}
}
// secondly write control ifaces
toWrite << iface->getDirection();
toWrite << iface->getMultiplicity();
toWrite << iface->getClockIfaceType();
- toWrite << iface->getClockIface();
+ toWrite << iface->getClockIfaceString();
}
}
// secondly, write other ifaces
toWrite << iface->getDirection();
toWrite << iface->getMultiplicity();
toWrite << iface->getClockIfaceType();
- toWrite << iface->getClockIface();
+ toWrite << iface->getClockIfaceString();
}
}
toWrite << b.outputs.size();
toWrite << iface->getDirection();
toWrite << iface->getMultiplicity();
toWrite << iface->getClockIfaceType();
- toWrite << iface->getClockIface();
+ toWrite << iface->getClockIfaceString();
}
}
// secondly, write other ifaces
toWrite << iface->getDirection();
toWrite << iface->getMultiplicity();
toWrite << iface->getClockIfaceType();
- toWrite << iface->getClockIface();
+ toWrite << iface->getClockIfaceString();
}
}
toWrite << b.bidirs.size();
toWrite << iface->getDirection();
toWrite << iface->getMultiplicity();
toWrite << iface->getClockIfaceType();
- toWrite << iface->getClockIface();
+ toWrite << iface->getClockIfaceString();
}
out << blockData;
--- /dev/null
+#include "SpecialBlock.h"\r
+\r
+SpecialBlock::SpecialBlock(SpecialType _type, GroupBlock* _parent, ReferenceBlock* _reference, bool createIfaces) throw(Exception) : FunctionalBlock(_parent, _reference, createIfaces) {\r
+ type = _type; \r
+}\r
+\r
+SpecialBlock::~SpecialBlock() {\r
+}\r
+\r
+void SpecialBlock::checkInputPatternCompatibility() throw(Exception) {\r
+ try {\r
+ switch(type) {\r
+ case ClockConvert :\r
+ checkInputPatternCompatibilityClockConvert();\r
+ break;\r
+ case ClkRstGen:\r
+ checkInputPatternCompatibilityClkRstGen();\r
+ break;\r
+ }\r
+ }\r
+ catch(Exception e) {\r
+ throw (e);\r
+ }\r
+}\r
+\r
+void SpecialBlock::computeOutputPattern(int nbExec) throw(Exception) {\r
+ try {\r
+ switch(type) {\r
+ case ClockConvert :\r
+ computeOutputPatternClockConvert(nbExec);\r
+ break;\r
+ case ClkRstGen:\r
+ computeOutputPatternClkRstGen(nbExec);\r
+ break;\r
+ }\r
+ }\r
+ catch(Exception e) {\r
+ throw (e);\r
+ }\r
+}\r
+\r
+void SpecialBlock::checkInputPatternCompatibilityClockConvert() throw(Exception) {\r
+}\r
+void SpecialBlock::computeOutputPatternClockConvert(int nbExec) throw(Exception) {\r
+}\r
+\r
+\r
+void SpecialBlock::checkInputPatternCompatibilityClkRstGen() throw(Exception) {\r
+}\r
+void SpecialBlock::computeOutputPatternClkRstGen(int nbExec) throw(Exception) {\r
+}\r
--- /dev/null
+#ifndef __SPECIALBLOCK_H__\r
+#define __SPECIALBLOCK_H__\r
+\r
+#include <iostream>\r
+\r
+#include <QtCore>\r
+\r
+#include "FunctionalBlock.h"\r
+class FunctionalBlock; \r
+\r
+using namespace std;\r
+using namespace Qt;\r
+\r
+\r
+\r
+class SpecialBlock : public FunctionalBlock {\r
+public:\r
+\r
+ enum SpecialType { ClockConvert = 0, ClkRstGen = 1 };\r
+ \r
+ SpecialBlock(SpecialType _type, GroupBlock* _parent, ReferenceBlock* _reference, bool createIfaces = true) throw(Exception);\r
+ ~SpecialBlock();\r
+ // getters\r
+ \r
+ // setters\r
+ \r
+ // testers\r
+\r
+ // others\r
+ \r
+ // patterns\r
+ void checkInputPatternCompatibility() throw(Exception);\r
+ void computeOutputPattern(int nbExec = -1) throw(Exception);\r
+\r
+private:\r
+ SpecialType type;\r
+ \r
+ void checkInputPatternCompatibilityClockConvert() throw(Exception);\r
+ void computeOutputPatternClockConvert(int nbExec = -1) throw(Exception);\r
+ void checkInputPatternCompatibilityClkRstGen() throw(Exception);\r
+ void computeOutputPatternClkRstGen(int nbExec = -1) throw(Exception);\r
+\r
+};\r
+\r
+\r
+\r
+#endif // __SPEICALBLOCK_H__\r
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 4.2.0, 2018-04-27T16:43:37. -->
+<!-- Written by QtCreator 4.2.0, 2018-04-30T11:05:13. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
ExternalResource.h
CustomDialog.h
CustomDialog.cpp
+InterfacePropertiesDialog.cpp
+InterfacePropertiesDialog.h
NewProjectDialog.h
NewProjectDialog.cpp
Exception.h
AbstractBoxItem.cpp
FunctionalBlock.cpp
FunctionalBlock.h
+SpecialBlock.cpp
+SpecialBlock.h
GroupBlock.h
GroupBlock.cpp
BlockImplementation.h
ParametersWindow.cpp
ArithmeticEvaluator.cpp
ArithmeticEvaluator.h
-InterfacePropertiesWindow.h
-InterfacePropertiesWindow.cpp
<category name="wishbone" id="5" parent="0"/>
<category name="generators" id="6" parent="0"/>
<category name="observers" id="7" parent="0"/>
- <category name="user" id="8" parent="0"/>
+ <category name="special" id="8" parent="0"/>
+ <category name="clock related" id="9" parent="8"/>
+ <category name="clock domain converter" id="10" parent="9"/>
+ <category name="user" id="66" parent="0"/>
<category name="unclassified" id="99" parent="0"/>
</categories>
<name>
apf27_wb_master
</name>
- <category ids="100" />
+ <category ids="8" />
<description>
<brief>
This block is the wishbone master of the design, connected to the i.MX of APF27
<block version="0.1">
<informations>
<name>clkdomain_convert_1024x8</name>
- <category ids="6"/>
+ <category ids="10"/>
<description>
<brief>This IP allows to pass 8 bits values from a clock domain to another. It uses a FIFO of 1024 entries.
</brief>
<input width="1" multiplicity="1" endian="little" type="boolean" name="clk_rd" purpose="clock"/>
<input width="1" multiplicity="1" endian="little" type="boolean" name="clk_wr" purpose="clock"/>
<input width="1" multiplicity="1" endian="little" type="boolean" name="reset" purpose="reset"/>
- <input width="8" multiplicity="1" endian="little" type="natural" name="data_in" purpose="data"/>
+ <input width="8" multiplicity="1" endian="little" type="natural" name="data_in" purpose="data" clock="clk_rd"/>
<control iface="data_in"/>
</inputs>
<outputs>
- <output width="8" multiplicity="1" endian="little" type="natural" name="data_out" purpose="data"/>
+ <output width="8" multiplicity="1" endian="little" type="natural" name="data_out" purpose="data" clock="clk_wr"/>
<control iface="data_out"/>
</outputs>
</interfaces>
<category ids="100" />
<description>
<brief>
- This block generate a reset signal synchronous to clock
+ This block generates a reset signal synchronous to an external clock
</brief>
<detailed>
- This block generate a reset signal synchronous to clock and is the entry point
- of the external clock and asynchronous reset.
+ This block generates a reset signal synchronous to clock. The block is automatically
+ connected to the external clock and asynchronous reset.
</detailed>
</description>
</informations>
COMMON-OBJ = $(BUILDPATH)/AbstractBlock.o \
$(BUILDPATH)/FunctionalBlock.o \
+ $(BUILDPATH)/SpecialBlock.o \
$(BUILDPATH)/ReferenceBlock.o \
$(BUILDPATH)/GroupBlock.o \
$(BUILDPATH)/AbstractInterface.o \
$(BUILDPATH)/moc_BlocksToConfigureWidget.o \
$(BUILDPATH)/ParametersWindow.o \
$(BUILDPATH)/moc_ParametersWindow.o \
- $(BUILDPATH)/InterfacePropertiesWindow.o \
- $(BUILDPATH)/moc_InterfacePropertiesWindow.o \
+ $(BUILDPATH)/InterfacePropertiesDialog.o \
+ $(BUILDPATH)/moc_InterfacePropertiesDialog.o \
$(BUILDPATH)/CustomDialog.o \
$(BUILDPATH)/moc_CustomDialog.o \
$(BUILDPATH)/NewProjectDialog.o \