\r
GroupBlock* parentBlock = AB_TO_GRP(parent);\r
\r
- cout << "connecting clk/rst for child " << qPrintable(name) << " of " << qPrintable(parentBlock->getName()) << endl;\r
+\r
\r
QList<AbstractInterface* > lstClk = getInterfaces(AbstractInterface::Input,AbstractInterface::Clock);\r
QList<AbstractInterface* > lstRst = getInterfaces(AbstractInterface::Input,AbstractInterface::Reset);\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
}\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
}\r
if ((fromClk == NULL) || (fromRst == NULL)) {\r
throw(Exception(IFACE_GROUP_NOCLKRST,parentBlock));\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
}\r
}\r
\r
\r
public:\r
\r
- enum ModifierVHDLContext {AnyContext = 0, Entity = 1, Component = 2, Architecture = 3 };\r
+ enum ModifierVHDLContext {AnyContext = 0, Entity = 1, Component = 2, Architecture = 3, Signal = 4 };\r
enum ModifierVHDLFlags { NoComma = 1 };\r
\r
AbstractInputModifier(ConnectedInterface* _associatedIface);\r
QString ret="";
bool ok;
- cout << "iface " << qPrintable(name) << " must be evaluated to vhdl :" << qPrintable(width) << " with type = " << qPrintable(getTypeString()) << endl;
+ //cout << "iface " << qPrintable(name) << " must be evaluated to vhdl :" << qPrintable(width) << " with type = " << qPrintable(getTypeString()) << endl;
+
+ if (context == Instance) {
+ if (direction == Output) {
+ ret = "from_"+owner->getName()+"_"+name;
+ }
+ else if (direction == InOut) {
+ ret = "fromto_"+owner->getName()+"_"+name;
+ }
+ return ret;
+ }
// create the width part
QString widthStr = "";
ret += widthStr;
}
else if (context == Signal) {
- ret = widthStr;
- }
- else if (context == Architecture) {
-
+ if (direction == Output) {
+ ret = "from_"+owner->getName()+"_"+name+" : "+widthStr;
+ }
+ else if (direction == InOut) {
+ ret = "fromto_"+owner->getName()+"_"+name+" : "+widthStr;
+ }
+ else if (direction == Input) {
+ ret = owner->getName()+"_"+name+" : "+widthStr;
+ }
}
return ret;
enum IfaceWidthDir { LittleEndian = 1, BigEndian}; //! LittleEndian = X downto 0, BigEndian = 0 to X
enum IfacePurpose { AnyPurpose = 0, Data = 1, Control, Clock, Reset, Wishbone };
enum IfaceDirection { AnyDirection = 0, Input = 1, Output = 2, InOut = 3 };
- enum IfaceVHDLContext {AnyContext = 0, Entity = 1, Component = 2, Architecture = 3, Signal = 4 }; // NB : 3 is when creating an instance of the block that owns this iface
+ enum IfaceVHDLContext {AnyContext = 0, Entity = 1, Component = 2, Instance = 3, Signal = 4 };
enum IfaceVHDLFlags { NoComma = 1 };
static int getIntDirection(QString str);
*/\r
enum ParamWBAccess { Read = 1, Write = 2};\r
enum ParamWBDuration { Permanent = 1, Trigger = 2 };\r
- enum ParamVHDLContext { Entity = 1, Component = 2, Architecture = 3 }; // NB : 3 is when creating an instance of the block that owns this iface\r
+ enum ParamVHDLContext { Entity = 1, Component = 2, Instance = 3 }; // NB : 3 is when creating an instance of the block that owns this iface\r
enum ParamVHDLFlags { NoComma = 1 };\r
\r
BlockParameter();\r
ret = formatNoValue.arg(name).arg(getTypeString());\r
}\r
}\r
- else if (context == BlockParameter::Architecture) {\r
+ else if (context == BlockParameter::Instance) {\r
QString format = "%1 => %2";\r
if ((flags & BlockParameter::NoComma) == 0) {\r
format.append(";");\r
}\r
AbstractBlock* parent = owner->getParent();\r
- BlockParameter* p = parent->getParameterFromName(name);\r
+ BlockParameter* p = NULL;\r
+ if (parent != NULL) {\r
+ p = parent->getParameterFromName(name);\r
+ }\r
if (p != NULL) {\r
/* the parent group has a generic parameter with the same\r
name\r
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
initInterfaceItems();
#include "DelayInputModifier.h"\r
#include "ConnectedInterface.h"\r
+#include "AbstractBlock.h"\r
\r
DelayInputModifier::DelayInputModifier(ConnectedInterface *_associatedInterface, int _delayLength) : AbstractInputModifier(_associatedInterface) {\r
setDelayLength(_delayLength);\r
\r
QString DelayInputModifier::toVHDL(int context, int flags) throw(Exception) {\r
\r
+\r
+ ConnectedInterface* fromCtlIface = associatedIface->getConnectedFrom();\r
+ ConnectedInterface* fromIface = AI_TO_CON(fromCtlIface->getAssociatedIface());\r
+\r
+ ConnectedInterface* toCtlIface = associatedIface;\r
+ ConnectedInterface* toIface = AI_TO_CON(toCtlIface->getAssociatedIface());\r
+ QString toName = toIface->getOwner()->getName()+"_"+toIface->getName();\r
+ QString toCtlName = toCtlIface->getOwner()->getName()+"_"+toCtlIface->getName();\r
+ QString dm1 = "";\r
+ QString dm2 = "";\r
+ dm1.setNum(delayLength-1);\r
+ dm2.setNum(delayLength-2);\r
+ QString ret="";\r
+ if (context == Architecture) {\r
+ ret = toName + "_mod_process : process(clk,reset)\n";\r
+ ret += " begin\n";\r
+ ret += " if reset = '1' then\n";\r
+ ret += " "+toName+"_dly <= (others => (others => '0'));\n";\r
+ ret += " "+toCtlName+"_dly <= (others => '0');\n";\r
+ ret += " "+toName+"_mod <= (others => '0');\n";\r
+ ret += " "+toCtlName+"_mod <= '0';\n";\r
+ ret += " elsif rising_edge(clk) then\n";\r
+ ret += " "+toName+"_mod <= "+toName+"_dly("+dm1+");\n";\r
+ ret += " "+toCtlName+"_mod <= "+toCtlName+"_dly("+dm1+");\n";\r
+ ret += " "+toName+"_dly(0) <= "+fromIface->toVHDL(AbstractInterface::Instance,0)+";\n";\r
+ ret += " "+toCtlName+"_dly(0) <= "+fromCtlIface->toVHDL(AbstractInterface::Instance,0)+";\n";\r
+ ret += " "+toName+"_dly(1 to "+dm1+") <= "+toName+"_dly(0 to "+dm2+");\n";\r
+ ret += " "+toCtlName+"_dly(1 to "+dm1+") <= "+toCtlName+"_dly(0 to "+dm2+");\n";\r
+ ret += " end if\n";\r
+ ret += " end process "+toName + "_mod_process\n";\r
+ }\r
+ else if (context == Signal) {\r
+ QString sig = toIface->toVHDL(AbstractInterface::Signal,0);\r
+ sig.replace(" : ","_mod : ");\r
+ ret = " signal "+sig+"\n";\r
+ sig = toCtlIface->toVHDL(AbstractInterface::Signal,0);\r
+ sig.replace(" : ","_mod : ");\r
+ ret += " signal "+sig+"\n";\r
+ QString wStr="";\r
+ wStr.setNum(toIface->getWidth());\r
+ ret += " signal "+toName+"_dly : vector_of_std_logic_vector"+wStr+"(0 to "+dm1+");\n";\r
+ ret += " signal "+toCtlName+"_dly : vector_of_std_logic(0 to "+dm1+");\n";\r
+ }\r
+\r
+ return ret;\r
+\r
}\r
\r
QString DelayInputModifier::getTypeStr() {\r
// 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);
+ 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;
out << " SIGNALS" << endl;
out << " ----------------------------" << endl << endl;
- out << " -- signals from input ports of " << name << endl;
- QList<AbstractInterface*> listInputs = getInputs();
- foreach(AbstractInterface* iface, listInputs) {
+
+ foreach(AbstractBlock* block, blocks) {
+ try {
+ out << " -- signals from output ports of " << block->getName() << endl;
+ QList<AbstractInterface*> listOutputs = block->getOutputs();
+ foreach(AbstractInterface* iface, listOutputs) {
+ if ((iface->getPurpose() == AbstractInterface::Data)||(iface->getPurpose() == AbstractInterface::Control)) {
+ out << " signal " << iface->toVHDL(AbstractInterface::Signal,0) << endl;
+ }
+ else if (block->getName() == "clkrstgen") {
+ if ((iface->getPurpose() == AbstractInterface::Clock)||(iface->getPurpose() == AbstractInterface::Reset)) {
+ out << " signal " << iface->toVHDL(AbstractInterface::Signal,0) << endl;
+ }
+ }
+ }
+ }
+ catch(Exception e) {
+ throw(e);
+ }
+ out << endl;
+ }
+ foreach(AbstractBlock* block, blocks) {
+ try {
+ out << " -- signals for modified input ports of " << block->getName() << endl;
+ QList<AbstractInterface*> listInputs = block->getInputs();
+ foreach(AbstractInterface* iface, listInputs) {
+ if (iface->getPurpose() == AbstractInterface::Control) {
+ ConnectedInterface* connCtlIface = AI_TO_CON(iface);
+ AbstractInputModifier* modifier = connCtlIface->getInputModifier();
+ if (modifier != NULL) {
+ out << modifier->toVHDL(AbstractInputModifier::Signal,0) << endl;
+ }
+ }
+ }
+ }
+ catch(Exception e) {
+ throw(e);
+ }
+ out << endl;
+ }
+
+ out << "begin" << endl;
+
+ // generate signals that goes to the output ports
+
+ out << " -- connections to output ports of " << name << endl;
+ QList<AbstractInterface*> listOutputs = getOutputs();
+ foreach(AbstractInterface* iface, listOutputs) {
if ((iface->getPurpose() == AbstractInterface::Data)||(iface->getPurpose() == AbstractInterface::Control)) {
ConnectedInterface* connIface = AI_TO_CON(iface);
- QString prefixName = name+"_"+iface->getName()+"_TO_";
- foreach(ConnectedInterface* toIface, connIface->getConnectedTo()) {
- QString sigName = prefixName+toIface->getOwner()->getName()+"_"+toIface->getName();
- out << " signal " << sigName << " : " << iface->toVHDL(AbstractInterface::Signal,0) << endl;
- }
+ ConnectedInterface* fromIface = connIface->getConnectedFrom();
+ out << " " << connIface->getName() << " <= " << fromIface->toVHDL(AbstractInterface::Instance,0) << ";" << endl;
}
}
+
out << endl;
+
+
+
+ // generate instances
foreach(AbstractBlock* block, blocks) {
try {
- out << " -- signals from output ports of " << block->getName() << endl;
+ out << " " << block->getName() << "_1 : " << block->getName() << endl;
+
+ QList<BlockParameter*> listGenerics = block->getGenericParameters();
+ QList<AbstractInterface*> listInputs = block->getInputs();
QList<AbstractInterface*> listOutputs = block->getOutputs();
- foreach(AbstractInterface* iface, listOutputs) {
- if ((iface->getPurpose() == AbstractInterface::Data)||(iface->getPurpose() == AbstractInterface::Control)) {
- ConnectedInterface* connIface = AI_TO_CON(iface);
- QString prefixName = block->getName()+"_"+iface->getName()+"_TO_";
- foreach(ConnectedInterface* toIface, connIface->getConnectedTo()) {
- QString sigName = prefixName+toIface->getOwner()->getName()+"_"+toIface->getName();
- out << " signal " << sigName << " : " << iface->toVHDL(AbstractInterface::Signal,0) << endl;
+ QList<AbstractInterface*> listBidirs = block->getBidirs();
+
+ if (!listGenerics.isEmpty()) {
+ out << " generic map (" << endl;
+ for(i=0;i<listGenerics.size()-1;i++) {
+ out << " " << listGenerics.at(i)->toVHDL(BlockParameter::Instance, BlockParameter::NoComma) << "," << endl;
+ }
+ out << " " << listGenerics.at(i)->toVHDL(BlockParameter::Instance,BlockParameter::NoComma) << endl;
+ out << " )" << endl;
+ }
+
+ out << " port map (" << endl;
+ QString portMap = "";
+
+ for(i=0;i<listInputs.size();i++) {
+ ConnectedInterface* connIface = AI_TO_CON(listInputs.at(i));
+ ConnectedInterface* fromIface = connIface->getConnectedFrom();
+
+ if (fromIface->isFunctionalInterface()) {
+ portMap += " " + connIface->getName() + " => ";
+ bool hasMod = false;
+ if (connIface->getPurpose() == AbstractInterface::Data) {
+ ConnectedInterface* connCtlIface = AI_TO_CON(connIface->getAssociatedIface());
+ if ((connCtlIface != NULL) && (connCtlIface->getInputModifier() != NULL)) {
+ hasMod = true;
+ }
+ }
+ else if (connIface->getPurpose() == AbstractInterface::Control) {
+ if (connIface->getInputModifier() != NULL) {
+ hasMod = true;
+ }
}
+ if (hasMod) {
+ portMap += connIface->getOwner()->getName()+"_"+connIface->getName()+"_mod,\n";
+ }
+ else {
+ portMap += fromIface->toVHDL(AbstractInterface::Instance, AbstractInterface::NoComma) + ",\n";
+ }
+ }
+ else if (fromIface->isGroupInterface()) {
+ portMap += " " + connIface->getName() + " => " + fromIface->getName() + ",\n";
+ }
+ }
+ if (listOutputs.size()>0) {
+ for(i=0;i<listOutputs.size();i++) {
+ ConnectedInterface* connIface = AI_TO_CON(listOutputs.at(i));
+ portMap += " " + connIface->getName() + " => " + connIface->toVHDL(AbstractInterface::Instance, AbstractInterface::NoComma) + ",\n";
+ }
+ }
+ if (listBidirs.size()>0) {
+ for(i=0;i<listBidirs.size();i++) {
+ ConnectedInterface* connIface = AI_TO_CON(listBidirs.at(i));
+ portMap += " " + connIface->getName() + " => " + connIface->toVHDL(AbstractInterface::Instance, AbstractInterface::NoComma) + ",\n";
}
}
+ portMap.chop(2);
+ out << portMap << endl;
+
+
+ out << " );" << endl;
}
catch(Exception e) {
throw(e);
out << endl;
}
+ // generate input modifiers
+ foreach(AbstractBlock* block, blocks) {
+
+ foreach(AbstractInterface* iface, block->getControlInputs()) {
+ ConnectedInterface* connIface = AI_TO_CON(iface);
+ // check if it is connected
+ if (connIface->getConnectedFrom() == NULL) {
+ throw(Exception(IFACE_NOT_CONNECTED,this));
+ }
+ AbstractInputModifier* modifier = connIface->getInputModifier();
+ if (modifier != NULL) {
+ try {
+ out << modifier->toVHDL(AbstractInputModifier::Architecture,0) << endl;
+ }
+ catch(Exception e) {
+ throw(e);
+ }
+ }
+ }
+ }
out << "end architecture rtl;" << endl;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
-<!-- Written by QtCreator 4.2.0, 2018-03-27T18:47:18. -->
+<!-- Written by QtCreator 4.2.0, 2018-03-29T22:16:07. -->
<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">
<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>