Fix nested struct within parameter port list (#6818) (#6824)

This commit is contained in:
Luca Colagrande 2025-12-17 00:08:49 +01:00 committed by GitHub
parent 35dcf70f48
commit a9ef4b3ff1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 9 deletions

View File

@ -583,16 +583,18 @@ class LinkParseVisitor final : public VNVisitor {
UINFO(9, "Reused impltypedef " << nodep << " --> " << defp);
} else {
// Definition must be inserted right after the variable (etc) that needed it
// AstVar, AstTypedef, AstNodeFTask are common containers
// AstVar, AstTypedef, AstNodeFTask, AstParamTypeDType are common containers
AstNode* backp = nodep->backp();
for (; backp; backp = backp->backp()) {
if (VN_IS(backp, Var) || VN_IS(backp, Typedef) || VN_IS(backp, NodeFTask)) break;
if (VN_IS(backp, Var) || VN_IS(backp, Typedef) || VN_IS(backp, NodeFTask)
|| VN_IS(backp, ParamTypeDType))
break;
}
UASSERT_OBJ(backp, nodep,
"Implicit enum/struct type created under unexpected node type");
AstNodeDType* const dtypep = nodep->childDTypep();
dtypep->unlinkFrBack();
if (VN_IS(backp, Typedef)) {
if (VN_IS(backp, Typedef) || VN_IS(backp, ParamTypeDType)) {
// A typedef doesn't need us to make yet another level of typedefing
// For typedefs just remove the AstRefDType level of abstraction
nodep->replaceWith(dtypep);

View File

@ -7,20 +7,31 @@
class ParamClass #(string P = "ABC", R = "GDF");
endclass
module t #(parameter int A = 0, B = 1, C = 2, type D = int, E = string);
parameter bit F = 1'b0, G = 1'b1;
parameter type H = int, I = string;
module t #(
parameter int A = 0, B = 1, C = 2, type D = int, E = string, F =
struct packed {
struct packed {
logic a;
} b;
}
);
parameter bit G = 1'b0, H = 1'b1;
parameter type I = int, J = string;
E str1 = "abc";
I str2 = "";
J str2 = "";
F struct1;
assign struct1.b.a = 1'b1;
initial begin
automatic ParamClass param_class = new;
if ($typename(B) != "int") $stop;
if ($typename(C) != "int") $stop;
if (str1.len() != 3) $stop;
if ($typename(G) != "bit") $stop;
if ($typename(H) != "bit") $stop;
if (str2.len() != 0) $stop;
if ($typename(param_class.R) != "string") $stop;
if ($typename(struct1.b.a) != "MEMBERDTYPE 'a'") $stop;
$write("*-* All Finished *-*\n");
$finish;
end