1 #include "DelayInputModifier.h"
\r
2 #include "ConnectedInterface.h"
\r
3 #include "AbstractBlock.h"
\r
5 DelayInputModifier::DelayInputModifier(ConnectedInterface *_associatedInterface, int _delayLength) : AbstractInputModifier(_associatedInterface) {
\r
6 setDelayLength(_delayLength);
\r
9 void DelayInputModifier::setDelayLength(int _delayLength) {
\r
10 if (_delayLength < 1) _delayLength = 1;
\r
11 delayLength = _delayLength;
\r
14 QList<char>* DelayInputModifier::getModifiedInput(QList<char>* input) {
\r
17 for(int i=0;i<delayLength;i++) pattern->append(0);
\r
18 pattern->append(*input);
\r
22 QString DelayInputModifier::toVHDL(int context, int flags) throw(Exception) {
\r
25 ConnectedInterface* fromCtlIface = associatedIface->getConnectedFrom();
\r
26 ConnectedInterface* fromIface = AI_TO_CON(fromCtlIface->getAssociatedIface());
\r
28 ConnectedInterface* toCtlIface = associatedIface;
\r
29 ConnectedInterface* toIface = AI_TO_CON(toCtlIface->getAssociatedIface());
\r
30 QString toName = toIface->getOwner()->getName()+"_"+toIface->getName();
\r
31 QString toCtlName = toCtlIface->getOwner()->getName()+"_"+toCtlIface->getName();
\r
34 dm2.setNum(delayLength-2);
\r
35 dm3.setNum(delayLength-3);
\r
37 int idClock = toIface->getClockDomain();
\r
38 QString clkName = "ext_clk_"+QString::number(idClock);
\r
39 QString resetName = "ext_reset_"+QString::number(idClock);
\r
40 if (toIface->getOwner()->getParent()->isTopGroupBlock()) {
\r
41 clkName = "from_clkrstgen_"+QString::number(idClock)+"_clk";
\r
42 resetName ="from_clkrstgen_"+QString::number(idClock)+"_reset";
\r
45 if (context == Architecture) {
\r
46 ret = toName + "_mod_process : process("+clkName+","+resetName+")\n";
\r
48 ret += " if "+resetName+" = '1' then\n";
\r
49 ret += " "+toName+"_dly <= (others => (others => '0'));\n";
\r
50 ret += " "+toCtlName+"_dly <= (others => '0');\n";
\r
51 ret += " "+toName+"_mod <= (others => '0');\n";
\r
52 ret += " "+toCtlName+"_mod <= '0';\n";
\r
53 ret += " elsif rising_edge("+clkName+") then\n";
\r
54 ret += " "+toName+"_mod <= "+toName+"_dly("+dm2+");\n";
\r
55 ret += " "+toCtlName+"_mod <= "+toCtlName+"_dly("+dm2+");\n";
\r
56 ret += " "+toName+"_dly(0) <= "+fromIface->toVHDL(AbstractInterface::Instance,0)+";\n";
\r
57 ret += " "+toCtlName+"_dly(0) <= "+fromCtlIface->toVHDL(AbstractInterface::Instance,0)+";\n";
\r
58 ret += " "+toName+"_dly(1 to "+dm2+") <= "+toName+"_dly(0 to "+dm3+");\n";
\r
59 ret += " "+toCtlName+"_dly(1 to "+dm2+") <= "+toCtlName+"_dly(0 to "+dm3+");\n";
\r
60 ret += " end if;\n";
\r
61 ret += " end process "+toName + "_mod_process;\n";
\r
63 else if (context == Signal) {
\r
64 QString sig = toIface->toVHDL(AbstractInterface::Signal,0);
\r
65 sig.replace(" : ","_mod : ");
\r
66 ret = " signal "+sig+"\n";
\r
67 sig = toCtlIface->toVHDL(AbstractInterface::Signal,0);
\r
68 sig.replace(" : ","_mod : ");
\r
69 ret += " signal "+sig+"\n";
\r
71 wStr.setNum(toIface->getWidth());
\r
72 ret += " signal "+toName+"_dly : vector_of_std_logic_vector"+wStr+"(0 to "+dm2+");\n";
\r
73 ret += " signal "+toCtlName+"_dly : vector_of_std_logic(0 to "+dm2+");\n";
\r
80 QString DelayInputModifier::getTypeStr() {
\r
84 QString DelayInputModifier::getParametersStr() {
\r
85 return QString::number(delayLength);
\r
88 bool DelayInputModifier::isDelay() {
\r