diff --git a/Changes b/Changes index 9a21bb638..123aa09f9 100644 --- a/Changes +++ b/Changes @@ -27,6 +27,7 @@ Verilator 4.217 devel * Fix VL_STREAML_FAST_QQI with 64 bit left-hand-side (#3232) (#3235) * Fix $sformat of inputs/outputs (#3236). [Adrien Le Masle] * Fix associative array foreach loop (#3229). +* Fix splitting of _eval and other top level functions. [Geza Lore, Shunyao CAD] Verilator 4.216 2021-12-05 diff --git a/src/V3Clock.cpp b/src/V3Clock.cpp index 2989aea3c..0ff85bd13 100644 --- a/src/V3Clock.cpp +++ b/src/V3Clock.cpp @@ -207,8 +207,7 @@ private: } void splitCheck(AstCFunc* ofuncp) { if (!v3Global.opt.outputSplitCFuncs() || !ofuncp->stmtsp()) return; - if (EmitCBaseCounterVisitor(ofuncp->stmtsp()).count() < v3Global.opt.outputSplitCFuncs()) - return; + if (EmitCBaseCounterVisitor(ofuncp).count() < v3Global.opt.outputSplitCFuncs()) return; int funcnum = 0; int func_stmts = 0; @@ -223,8 +222,9 @@ private: const int stmts = EmitCBaseCounterVisitor(itemp).count(); if (!funcp || (func_stmts + stmts) > v3Global.opt.outputSplitCFuncs()) { // Make a new function - funcp = new AstCFunc{ofuncp->fileline(), ofuncp->name() + cvtToStr(++funcnum), - m_topScopep->scopep()}; + funcp + = new AstCFunc{ofuncp->fileline(), ofuncp->name() + "__" + cvtToStr(funcnum++), + m_topScopep->scopep()}; funcp->dontCombine(true); funcp->isStatic(false); funcp->isLoose(true); diff --git a/test_regress/t/t_flag_csplit_eval.pl b/test_regress/t/t_flag_csplit_eval.pl index dfd67259c..325f38067 100755 --- a/test_regress/t/t_flag_csplit_eval.pl +++ b/test_regress/t/t_flag_csplit_eval.pl @@ -15,25 +15,21 @@ sub check_evals { local $/; undef $/; my $wholefile = <$fh>; - if ($wholefile =~ /___eval[0-9]+/) { + if ($wholefile =~ /___eval__[0-9]+\(.*\)\s*{/) { ++$got; } } - $got >= 3 or error("Too few _eval functions found: $got"); + $got >= 2 or error("Too few _eval functions found: $got"); } scenarios(vlt_all => 1); compile( - v_flags2 => ["--output-split 1 --output-split-cfuncs 1 --exe ../$Self->{main_filename}"], -# verilator_make_gmake => 0, - ); - -# Very slow to compile, so generally skip it -execute( - check_finished => 1, + v_flags2 => ["--output-split 1 --output-split-cfuncs 20"], + verilator_make_gmake => 0, # Slow to compile, so skip it ); check_evals(); + ok(1); 1; diff --git a/test_regress/t/t_flag_csplit_eval.v b/test_regress/t/t_flag_csplit_eval.v index 685fc7612..53c7976d9 100644 --- a/test_regress/t/t_flag_csplit_eval.v +++ b/test_regress/t/t_flag_csplit_eval.v @@ -22,6 +22,14 @@ module t (/*AUTOARG*/ final if (cnt0 == 0) $stop; final if (cnt1 != 0) $stop; + // Some dummy statements to make the code larger + generate + genvar i; + for (i = 0 ; i < 100; i = i + 1) begin + always @(posedge clk) $c("/*", i, "*/"); + end + endgenerate + always_comb begin if (cnt0==99) begin $write("*-* All Finished *-*\n");