From 7a9e79ea798272e63139d212a79d8b3f7c3e741c Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 21 Sep 2020 08:29:39 -0400 Subject: [PATCH] Fix -G dropping public indication (#2561). --- Changes | 2 ++ src/V3LinkDot.cpp | 1 + test_regress/t/t_param_public.cpp | 4 ++++ test_regress/t/t_param_public.pl | 2 +- test_regress/t/t_param_public.v | 2 ++ 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index 4445d47ec..b9724f83b 100644 --- a/Changes +++ b/Changes @@ -9,6 +9,8 @@ The contributors that suggested a given feature are shown in []. Thanks! **** Support # as a comment in -f files (#2497). [phantom-killua] +**** Fix -G dropping public indication (#2561). [Andrew Goessling] + * Verilator 4.100 2020-09-07 diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 610e30f0b..db98918d0 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -1128,6 +1128,7 @@ class LinkDotFindVisitor : public AstNVisitor { AstVar* newp = new AstVar(nodep->fileline(), AstVarType(AstVarType::GPARAM), nodep->name(), nodep); + newp->combineType(nodep); string svalue = v3Global.opt.parameter(nodep->name()); if (AstNode* valuep = AstConst::parseParamLiteral(nodep->fileline(), svalue)) { diff --git a/test_regress/t/t_param_public.cpp b/test_regress/t/t_param_public.cpp index b167dbf31..1620fb2d4 100644 --- a/test_regress/t/t_param_public.cpp +++ b/test_regress/t/t_param_public.cpp @@ -10,6 +10,7 @@ #include "Vt_param_public.h" #include "Vt_param_public_p.h" +#include "Vt_param_public_t.h" int main(int argc, char* argv[]) { Vt_param_public* topp = new Vt_param_public; @@ -17,6 +18,9 @@ int main(int argc, char* argv[]) { Verilated::debug(0); // Make sure public tag worked + if (static_cast(Vt_param_public_t::TOP_PARAM) != 30) { + vl_fatal(__FILE__, __LINE__, "dut", "bad value"); + } if (static_cast(Vt_param_public_p::INPACK) != 0) {} for (int i = 0; i < 10; i++) { diff --git a/test_regress/t/t_param_public.pl b/test_regress/t/t_param_public.pl index 345560283..6cec8bc56 100755 --- a/test_regress/t/t_param_public.pl +++ b/test_regress/t/t_param_public.pl @@ -12,7 +12,7 @@ scenarios(simulator => 1); if ($Self->{vlt_all}) { compile( - verilator_flags2 => ["--exe $Self->{t_dir}/$Self->{name}.cpp"], + verilator_flags2 => ["-GTOP_PARAM=30 --exe $Self->{t_dir}/$Self->{name}.cpp"], make_top_shell => 0, make_main => 0, ); diff --git a/test_regress/t/t_param_public.v b/test_regress/t/t_param_public.v index 36851a343..b896a596a 100644 --- a/test_regress/t/t_param_public.v +++ b/test_regress/t/t_param_public.v @@ -12,6 +12,8 @@ module t (/*AUTOARG*/ ); input clk; + parameter TOP_PARAM /*verilator public*/ = 20; + a #(1) a1 (); b #(2) b2 ();