X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/blobdiff_plain/4cf57e6db08da791233d75237f62e74bc88dd427..4327c2b8817b627249d98d889835726217c81a4e:/DelayInputModifier.cpp diff --git a/DelayInputModifier.cpp b/DelayInputModifier.cpp index a35aa21..db89107 100644 --- a/DelayInputModifier.cpp +++ b/DelayInputModifier.cpp @@ -1,6 +1,8 @@ #include "DelayInputModifier.h" +#include "ConnectedInterface.h" +#include "AbstractBlock.h" -DelayInputModifier::DelayInputModifier(int _delayLength) : AbstractInputModifier() { +DelayInputModifier::DelayInputModifier(ConnectedInterface *_associatedInterface, int _delayLength) : AbstractInputModifier(_associatedInterface) { setDelayLength(_delayLength); } @@ -17,6 +19,63 @@ QList* DelayInputModifier::getModifiedInput(QList* input) { return pattern; } +QString DelayInputModifier::toVHDL(int context, int flags) throw(Exception) { + + + ConnectedInterface* fromCtlIface = associatedIface->getConnectedFrom(); + ConnectedInterface* fromIface = AI_TO_CON(fromCtlIface->getAssociatedIface()); + + ConnectedInterface* toCtlIface = associatedIface; + ConnectedInterface* toIface = AI_TO_CON(toCtlIface->getAssociatedIface()); + QString toName = toIface->getOwner()->getName()+"_"+toIface->getName(); + QString toCtlName = toCtlIface->getOwner()->getName()+"_"+toCtlIface->getName(); + QString dm2 = ""; + QString dm3 = ""; + dm2.setNum(delayLength-2); + dm3.setNum(delayLength-3); + QString ret=""; + QString clkName = "clk"; + QString resetName = "reset"; + if (toIface->getOwner()->getParent()->isTopGroupBlock()) { + clkName = "from_clkrstgen_clk"; + resetName ="from_clkrstgen_reset"; + } + + if (context == Architecture) { + ret = toName + "_mod_process : process("+clkName+","+resetName+")\n"; + ret += " begin\n"; + ret += " if "+resetName+" = '1' then\n"; + ret += " "+toName+"_dly <= (others => (others => '0'));\n"; + ret += " "+toCtlName+"_dly <= (others => '0');\n"; + ret += " "+toName+"_mod <= (others => '0');\n"; + ret += " "+toCtlName+"_mod <= '0';\n"; + ret += " elsif rising_edge("+clkName+") then\n"; + ret += " "+toName+"_mod <= "+toName+"_dly("+dm2+");\n"; + ret += " "+toCtlName+"_mod <= "+toCtlName+"_dly("+dm2+");\n"; + ret += " "+toName+"_dly(0) <= "+fromIface->toVHDL(AbstractInterface::Instance,0)+";\n"; + ret += " "+toCtlName+"_dly(0) <= "+fromCtlIface->toVHDL(AbstractInterface::Instance,0)+";\n"; + ret += " "+toName+"_dly(1 to "+dm2+") <= "+toName+"_dly(0 to "+dm3+");\n"; + ret += " "+toCtlName+"_dly(1 to "+dm2+") <= "+toCtlName+"_dly(0 to "+dm3+");\n"; + ret += " end if;\n"; + ret += " end process "+toName + "_mod_process;\n"; + } + else if (context == Signal) { + QString sig = toIface->toVHDL(AbstractInterface::Signal,0); + sig.replace(" : ","_mod : "); + ret = " signal "+sig+"\n"; + sig = toCtlIface->toVHDL(AbstractInterface::Signal,0); + sig.replace(" : ","_mod : "); + ret += " signal "+sig+"\n"; + QString wStr=""; + wStr.setNum(toIface->getWidth()); + ret += " signal "+toName+"_dly : vector_of_std_logic_vector"+wStr+"(0 to "+dm2+");\n"; + ret += " signal "+toCtlName+"_dly : vector_of_std_logic(0 to "+dm2+");\n"; + } + + return ret; + +} + QString DelayInputModifier::getTypeStr() { return "delay"; }