diff --git a/src/V3LinkDot.cpp b/src/V3LinkDot.cpp index 0cbc5bc79..9a5933af2 100644 --- a/src/V3LinkDot.cpp +++ b/src/V3LinkDot.cpp @@ -2779,7 +2779,10 @@ class LinkDotResolveVisitor final : public VNVisitor { if (AstVar* const varp = VN_CAST(foundp->nodep(), Var)) { if (varp->isParam() || varp->isGenVar()) { // Attach found Text reference to PatMember - nodep->varrefp(new AstVarRef{nodep->fileline(), varp, VAccess::READ}); + nodep->varrefp( + new AstVarRef{nodep->fileline(), + foundp->imported() ? foundp->classOrPackagep() : nullptr, + varp, VAccess::READ}); UINFO(9, indent() << " new " << nodep->varrefp() << endl); } } diff --git a/test_regress/t/t_param_pattern_init.v b/test_regress/t/t_param_pattern_init.v index f175e4bcf..69fefffec 100644 --- a/test_regress/t/t_param_pattern_init.v +++ b/test_regress/t/t_param_pattern_init.v @@ -7,6 +7,15 @@ `define stop $stop `define checkh(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", `__FILE__,`__LINE__, (gotv), (expv)); `stop; end while(0); +package some_pkg; + localparam FOO = 5; + localparam BAR = 6; + + typedef enum int { + QUX = 7 + } pkg_enum_t; +endpackage + module t (/*AUTOARG*/ // Inputs clk @@ -69,6 +78,22 @@ module t (/*AUTOARG*/ `checkh(enum_array[2], 32'ha5a5); end + logic [31:0] package_array [8]; + + import some_pkg::*; + always_comb package_array = '{ + FOO: 32'h9876, + BAR: 32'h1212, + QUX: 32'h5432, + default: 0 + }; + + always_ff @(posedge clk) begin + `checkh(package_array[5], 32'h9876); + `checkh(package_array[6], 32'h1212); + `checkh(package_array[7], 32'h5432); + end + always_ff @(posedge clk) begin cyc <= cyc + 1; if (cyc == 2) begin