From 0b09636c58d3a03524104e40bc001dfaf7def207 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 29 Jun 2020 21:18:41 -0400 Subject: [PATCH] Support for-loop increments with commas. --- Changes | 4 +++- src/V3LinkDot.cpp | 6 ++++++ src/V3Unroll.cpp | 2 +- src/verilog.y | 2 +- test_regress/t/t_for_comma_bad.out | 18 ------------------ test_regress/t/t_for_loop.v | 7 +++++++ 6 files changed, 18 insertions(+), 21 deletions(-) diff --git a/Changes b/Changes index 98292b2c7..bd121c246 100644 --- a/Changes +++ b/Changes @@ -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] diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index e5a057ef3..bbb8011d6 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -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) { diff --git a/src/V3Unroll.cpp b/src/V3Unroll.cpp index 76470a752..795d5ec04 100644 --- a/src/V3Unroll.cpp +++ b/src/V3Unroll.cpp @@ -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(); diff --git a/src/verilog.y b/src/verilog.y index 544afbed7..1a1cd7d62 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -3376,7 +3376,7 @@ for_stepE: // IEEE: for_step + empty for_step: // 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: // ==IEEE: for_step_assignment diff --git a/test_regress/t/t_for_comma_bad.out b/test_regress/t/t_for_comma_bad.out index 976f2036e..6b5a4f416 100644 --- a/test_regress/t/t_for_comma_bad.out +++ b/test_regress/t/t_for_comma_bad.out @@ -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 diff --git a/test_regress/t/t_for_loop.v b/test_regress/t/t_for_loop.v index 5de42aa49..24cd98a0c 100644 --- a/test_regress/t/t_for_loop.v +++ b/test_regress/t/t_for_loop.v @@ -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;