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 dm1.setNum(delayLength-1);
\r
35 dm2.setNum(delayLength-2);
\r
37 if (context == Architecture) {
\r
38 ret = toName + "_mod_process : process(clk,reset)\n";
\r
40 ret += " if reset = '1' then\n";
\r
41 ret += " "+toName+"_dly <= (others => (others => '0'));\n";
\r
42 ret += " "+toCtlName+"_dly <= (others => '0');\n";
\r
43 ret += " "+toName+"_mod <= (others => '0');\n";
\r
44 ret += " "+toCtlName+"_mod <= '0';\n";
\r
45 ret += " elsif rising_edge(clk) then\n";
\r
46 ret += " "+toName+"_mod <= "+toName+"_dly("+dm1+");\n";
\r
47 ret += " "+toCtlName+"_mod <= "+toCtlName+"_dly("+dm1+");\n";
\r
48 ret += " "+toName+"_dly(0) <= "+fromIface->toVHDL(AbstractInterface::Instance,0)+";\n";
\r
49 ret += " "+toCtlName+"_dly(0) <= "+fromCtlIface->toVHDL(AbstractInterface::Instance,0)+";\n";
\r
50 ret += " "+toName+"_dly(1 to "+dm1+") <= "+toName+"_dly(0 to "+dm2+");\n";
\r
51 ret += " "+toCtlName+"_dly(1 to "+dm1+") <= "+toCtlName+"_dly(0 to "+dm2+");\n";
\r
53 ret += " end process "+toName + "_mod_process\n";
\r
55 else if (context == Signal) {
\r
56 QString sig = toIface->toVHDL(AbstractInterface::Signal,0);
\r
57 sig.replace(" : ","_mod : ");
\r
58 ret = " signal "+sig+"\n";
\r
59 sig = toCtlIface->toVHDL(AbstractInterface::Signal,0);
\r
60 sig.replace(" : ","_mod : ");
\r
61 ret += " signal "+sig+"\n";
\r
63 wStr.setNum(toIface->getWidth());
\r
64 ret += " signal "+toName+"_dly : vector_of_std_logic_vector"+wStr+"(0 to "+dm1+");\n";
\r
65 ret += " signal "+toCtlName+"_dly : vector_of_std_logic(0 to "+dm1+");\n";
\r
72 QString DelayInputModifier::getTypeStr() {
\r
76 QString DelayInputModifier::getParametersStr() {
\r
77 return QString::number(delayLength);
\r
80 bool DelayInputModifier::isDelay() {
\r