Fix bug introduced in 3.661 with parametrized defines.

git-svn-id: file://localhost/svn/verilator/trunk/verilator@1042 77ca24e4-aefa-0310-84f0-b9a241c72d87
This commit is contained in:
Wilson Snyder 2008-04-25 14:01:50 +00:00
parent 73c3d4bb50
commit 0c73b547f1
6 changed files with 39 additions and 8 deletions

View File

@ -28,6 +28,8 @@ indicates the contributor was also the author of the fix; Thanks!
**** Fix internal error when params get non-constants. [Johan Wouters]
**** Fix bug introduced in 3.661 with parametrized defines.
* Verilator 3.661 2008/04/04
*** The --enable-defenv configure option added in 3.660 is now the default.

View File

@ -133,7 +133,7 @@ class V3PreLex {
void lineDirective(const char* text);
void incLineno() { m_curFilelinep->incLineno(); }
// Called by V3PreProc.cpp to inform lexer
void pushStateDefArg();
void pushStateDefArg(int level);
void pushStateDefValue();
void pushStateIncFilename();
void unputString(const char* textp);

View File

@ -141,6 +141,9 @@ psl [p]sl
<ARGMODE>{crnl} { linenoInc(); yytext="\n"; yyleng=1; return(VP_WHITE); }
<ARGMODE>{quote} { yy_push_state(STRMODE); yymore(); }
<ARGMODE>[(] { V3PreLex::s_currentLexp->m_parenLevel++;
// Note paren level 0 means before "(" of starting args
// Level 1 means "," between arguments
// Level 2+ means one argument's internal ()
if (V3PreLex::s_currentLexp->m_parenLevel>1) {
appendDefValue(yytext,yyleng);
} else {
@ -210,10 +213,10 @@ psl [p]sl
<INITIAL,PSLMULM,PSLONEM>. { return (VP_TEXT); }
%%
void V3PreLex::pushStateDefArg() {
void V3PreLex::pushStateDefArg(int level) {
// Enter define substitution argument state
yy_push_state(ARGMODE);
m_parenLevel = 0;
m_parenLevel = level;
m_defValue = "";
}

View File

@ -759,7 +759,7 @@ int V3PreProcImp::getToken() {
if (tok==VP_DEFARG && yyleng==1 && yytext[0]==',') {
refp->args().push_back(refp->nextarg());
m_state = ps_DEFARG;
m_lexp->pushStateDefArg();
m_lexp->pushStateDefArg(1);
refp->nextarg("");
goto next_tok;
} else if (tok==VP_DEFARG && yyleng==1 && yytext[0]==')') {
@ -901,7 +901,7 @@ int V3PreProcImp::getToken() {
UINFO(4,"Defref `"<<name<<" => parameterized"<<endl);
m_defRefs.push(V3DefineRef(name, params, m_lexp->m_parenLevel));
m_state = ps_DEFPAREN; m_stateFor = tok;
m_lexp->pushStateDefArg();
m_lexp->pushStateDefArg(0);
goto next_tok;
}
}

View File

@ -141,6 +141,19 @@ $c("Zap(\"","bug2","\");");;
wire tmp_d1 = d1; wire tmp_o1 = tmp_d1 + 1; assign o1 = tmp_o1 ;
wire tmp_d2 = d2 ; wire tmp_o2 = tmp_d2 + 1; assign o2 = tmp_o2 ;
generate for (i=0; i<(3); i=i+1) begin psl cover { m5k.f .ctl._ctl_mvldx_m1.d[i] & ~m5k.f .ctl._ctl_mvldx_m1.q[i] & !m5k.f .ctl._ctl_mvldx_m1.cond & ((m5k.f .ctl.alive & m5k.f .ctl.alive_m1))} report "fondNoRise: m5kc_fcl._ctl_mvldx_m1"; psl cover { ~m5k.f .ctl._ctl_mvldx_m1.d[i] & m5k.f .ctl._ctl_mvldx_m1.q[i] & !m5k.f .ctl._ctl_mvldx_m1.cond & ((m5k.f .ctl.alive & m5k.f .ctl.alive_m1))} report "fondNoFall: m5kc_fcl._ctl_mvldx_m1"; end endgenerate
@ -148,7 +161,7 @@ wire tmp_d2 = d2 ; wire tmp_o2 = tmp_d2 + 1; assign o2 = tmp_o2 ;
`line 104 "t/t_preproc.v" 0
`line 117 "t/t_preproc.v" 0
Line_Preproc_Check 105
`line 106 "t/t_preproc.v" 2
Line_Preproc_Check 118
`line 119 "t/t_preproc.v" 2

View File

@ -95,6 +95,19 @@ assign c = tmp_``c ;
`ADD_UP(d1,o1) // expansion is OK
`ADD_UP( d2 , o2 ) // expansion is bad
`define check(mod, width, flopname, gate, path) \
generate for (i=0; i<(width); i=i+1) begin \
psl cover { path.d[i] & ~path.q[i] & !path.cond & (gate)} report `"fondNoRise: mod.flopname`"; \
psl cover { ~path.d[i] & path.q[i] & !path.cond & (gate)} report `"fondNoFall: mod.flopname`"; \
end endgenerate
// parameterized macro with arguments that are macros
`define MK m5k.f
`define MF `MK .ctl
`define CK_fr (`MF.alive & `MF.alive_m1)
`check(m5kc_fcl, 3, _ctl_mvldx_m1, `CK_fr, `MF._ctl_mvldx_m1) // ignorecmt
//===========================================================================
// Ifdef