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 QString clkName = "clk";
\r
38 QString resetName = "reset";
\r
39 if (toIface->getOwner()->getParent()->isTopGroupBlock()) {
\r
40 clkName = "from_clkrstgen_clk";
\r
41 resetName ="from_clkrstgen_reset";
\r
44 if (context == Architecture) {
\r
45 ret = toName + "_mod_process : process("+clkName+","+resetName+")\n";
\r
47 ret += " if "+resetName+" = '1' then\n";
\r
48 ret += " "+toName+"_dly <= (others => (others => '0'));\n";
\r
49 ret += " "+toCtlName+"_dly <= (others => '0');\n";
\r
50 ret += " "+toName+"_mod <= (others => '0');\n";
\r
51 ret += " "+toCtlName+"_mod <= '0';\n";
\r
52 ret += " elsif rising_edge("+clkName+") then\n";
\r
53 ret += " "+toName+"_mod <= "+toName+"_dly("+dm1+");\n";
\r
54 ret += " "+toCtlName+"_mod <= "+toCtlName+"_dly("+dm1+");\n";
\r
55 ret += " "+toName+"_dly(0) <= "+fromIface->toVHDL(AbstractInterface::Instance,0)+";\n";
\r
56 ret += " "+toCtlName+"_dly(0) <= "+fromCtlIface->toVHDL(AbstractInterface::Instance,0)+";\n";
\r
57 ret += " "+toName+"_dly(1 to "+dm1+") <= "+toName+"_dly(0 to "+dm2+");\n";
\r
58 ret += " "+toCtlName+"_dly(1 to "+dm1+") <= "+toCtlName+"_dly(0 to "+dm2+");\n";
\r
59 ret += " end if;\n";
\r
60 ret += " end process "+toName + "_mod_process;\n";
\r
62 else if (context == Signal) {
\r
63 QString sig = toIface->toVHDL(AbstractInterface::Signal,0);
\r
64 sig.replace(" : ","_mod : ");
\r
65 ret = " signal "+sig+"\n";
\r
66 sig = toCtlIface->toVHDL(AbstractInterface::Signal,0);
\r
67 sig.replace(" : ","_mod : ");
\r
68 ret += " signal "+sig+"\n";
\r
70 wStr.setNum(toIface->getWidth());
\r
71 ret += " signal "+toName+"_dly : vector_of_std_logic_vector"+wStr+"(0 to "+dm1+");\n";
\r
72 ret += " signal "+toCtlName+"_dly : vector_of_std_logic(0 to "+dm1+");\n";
\r
79 QString DelayInputModifier::getTypeStr() {
\r
83 QString DelayInputModifier::getParametersStr() {
\r
84 return QString::number(delayLength);
\r
87 bool DelayInputModifier::isDelay() {
\r