Fix struct literal on pattern assignment (#5552) (#5559)

This commit is contained in:
Todd Strader 2024-10-24 18:50:57 -04:00 committed by GitHub
parent fd2917c928
commit 83081aaefc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 57 additions and 1 deletions

View File

@ -5544,7 +5544,7 @@ class WidthVisitor final : public VNVisitor {
userIterate(modVarp->childDTypep(),
WidthVP{SELF, BOTH}.p()); // May relink pointed to node
AstNodeDType* const setDtp = modVarp->childDTypep()->cloneTree(false);
patternp->childDTypep(setDtp);
if (!patternp->childDTypep()) patternp->childDTypep(setDtp);
userIterateChildren(nodep, WidthVP{setDtp, BOTH}.p());
didWidth = true;
}

View File

@ -0,0 +1,18 @@
#!/usr/bin/env python3
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2024 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
import vltest_bootstrap
test.scenarios('simulator')
test.compile(verilator_flags2=["--debug"])
test.execute()
test.passes()

View File

@ -0,0 +1,38 @@
// DESCRIPTION: Verilator: Demonstrate struct literal param assignment problem
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2024 by Wilson Snyder.
// SPDX-License-Identifier: CC0-1.0
package Some_pkg;
typedef struct packed {
int foo;
} some_struct_t;
endpackage
module sub #(
parameter Some_pkg::some_struct_t the_some_struct
) ();
endmodule
module t (/*AUTOARG*/
// Inputs
clk
);
input clk;
// finish report
always @ (posedge clk) begin
$write("*-* All Finished *-*\n");
$finish;
end
sub #(
.the_some_struct(
Some_pkg::some_struct_t'{
foo: 1
}))
the_sub ();
endmodule