Fix imported array assignment literals (#5642) (#5648)

This commit is contained in:
Todd Strader 2024-12-02 15:08:47 -05:00 committed by GitHub
parent 4781a6046a
commit b6f292f556
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 1 deletions

View File

@ -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);
}
}

View File

@ -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