Support for-loop increments with commas.

This commit is contained in:
Wilson Snyder 2020-06-29 21:18:41 -04:00
parent af197f2ceb
commit 0b09636c58
6 changed files with 18 additions and 21 deletions

View File

@ -5,12 +5,14 @@ The contributors that suggested a given feature are shown in []. Thanks!
* Verilator 4.037 devel
*** Support VPI access to parameters and localparam. [Ludwig Rogiers]
*** Support VPI access to parameters and localparam. [Ludwig Rogiers]
**** Add new UNSUPPORTED error code to replace most previous Unsupported: messages.
**** With --bbox-unsup continue parsing on many (not all) UVM constructs.
**** Support for-loop increments with commas.
**** Fix to flush FST trace on termination due to $stop or assertion failure.
**** Fix part select error when multipling by power-of-two (#2413). [Conor McCullough]

View File

@ -2027,6 +2027,12 @@ private:
// Generally resolved during Primay, but might be at param time under AstUnlinkedRef
UASSERT_OBJ(m_statep->forPrimary() || m_statep->forPrearray(), nodep,
"ParseRefs should no longer exist");
if (nodep->name() == "this") {
nodep->v3warn(E_UNSUPPORTED, "Unsupported: this");
}
else if (nodep->name() == "super") {
nodep->v3warn(E_UNSUPPORTED, "Unsupported: super");
}
DotStates lastStates = m_ds;
bool start = (m_ds.m_dotPos == DP_NONE); // Save, as m_dotp will be changed
if (start) {

View File

@ -113,7 +113,7 @@ private:
// Assignment of next value check
AstAssign* incAssp = VN_CAST(incp, Assign);
if (!incAssp) return cantUnroll(nodep, "no increment assignment");
UASSERT_OBJ(!incAssp->nextp(), nodep, "increment shouldn't be a list");
if (incAssp->nextp()) return cantUnroll(nodep, "multiple increments");
m_forVarp = VN_CAST(initAssp->lhsp(), VarRef)->varp();
m_forVscp = VN_CAST(initAssp->lhsp(), VarRef)->varScopep();

View File

@ -3376,7 +3376,7 @@ for_stepE<nodep>: // IEEE: for_step + empty
for_step<nodep>: // IEEE: for_step
for_step_assignment { $$ = $1; }
| for_step ',' for_step_assignment { $$ = $1; BBUNSUP($2, "Unsupported: for loop step after the first comma"); }
| for_step ',' for_step_assignment { $$ = AstNode::addNextNull($1, $3); }
;
for_step_assignment<nodep>: // ==IEEE: for_step_assignment

View File

@ -1,18 +1,3 @@
%Error-UNSUPPORTED: t/t_for_comma_bad.v:14:21: Unsupported: for loop step after the first comma
14 | for (; ; a=a+1, b=b+1) ;
| ^
%Error-UNSUPPORTED: t/t_for_comma_bad.v:17:24: Unsupported: for loop step after the first comma
17 | for (; a<1; a=a+1, b=b+1) ;
| ^
%Error-UNSUPPORTED: t/t_for_comma_bad.v:20:27: Unsupported: for loop step after the first comma
20 | for (a=0; a<1; a=a+1, b=b+1) ;
| ^
%Error-UNSUPPORTED: t/t_for_comma_bad.v:23:35: Unsupported: for loop step after the first comma
23 | for (integer a=0; a<1; a=a+1, b=b+1) ;
| ^
%Error-UNSUPPORTED: t/t_for_comma_bad.v:26:39: Unsupported: for loop step after the first comma
26 | for (var integer a=0; a<1; a=a+1, b=b+1) ;
| ^
%Error-UNSUPPORTED: t/t_for_comma_bad.v:27:23: Unsupported: for loop initialization after the first comma
27 | for (integer a=0, integer b=0; a<1; ) ;
| ^
@ -22,7 +7,4 @@
%Error-UNSUPPORTED: t/t_for_comma_bad.v:29:23: Unsupported: for loop initialization after the first comma
29 | for (integer a=0, integer b=0; a<1; a=a+1, b=b+1) ;
| ^
%Error-UNSUPPORTED: t/t_for_comma_bad.v:29:48: Unsupported: for loop step after the first comma
29 | for (integer a=0, integer b=0; a<1; a=a+1, b=b+1) ;
| ^
%Error: Exiting due to

View File

@ -101,6 +101,13 @@ module t (/*AUTOARG*/
if (i != 20) $stop;
for (i=30; i<10; i++) ;
if (i != 30) $stop;
// Comma
loops = 0;
for (i=0; i<20; ++i, ++loops);
if (loops !== 20) $stop;
loops = 0;
for (i=0; i<20; ++loops, ++i);
if (loops !== 20) $stop;
//
$write("*-* All Finished *-*\n");
$finish;