3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-23 00:55:32 +00:00

Corrected handling of nested typedefs of struct/union

This also corrects shadowing of constants in struct/union types.
This commit is contained in:
Dag Lem 2023-01-29 20:22:00 +01:00 committed by Zachary Snow
parent 0b8f728590
commit cff53d6d87
4 changed files with 81 additions and 52 deletions

View file

@ -17,6 +17,12 @@ module top;
always @(*) assert(inner_i1 == 4'hA);
always @(*) assert(inner_enum1 == 3'h3);
// adapted from tests/verilog/typedef_const_shadow.sv
localparam W = 5;
typedef logic [W-1:0] T;
T x; // width 5
always @(*) assert($bits(x) == 5);
if (1) begin: genblock
// type declarations in child scopes shadow their parents
typedef logic [7:0] inner_type;
@ -34,6 +40,20 @@ module top;
} mystruct_t;
mystruct_t mystruct;
always @(*) assert($bits(mystruct) == 4);
// adapted from tests/verilog/typedef_const_shadow.sv
localparam W = 10;
typedef T U;
typedef logic [W-1:0] V;
struct packed {
logic [W-1:0] x; // width 10
U y; // width 5
V z; // width 10
} shadow;
// This currently only works as long as long as shadow is not typedef'ed
always @(*) assert($bits(shadow.x) == 10);
always @(*) assert($bits(shadow.y) == 5);
always @(*) assert($bits(shadow.z) == 10);
end
inner_type inner_i2 = 8'h42;

View file

@ -19,8 +19,10 @@ module top;
p::p_t ps;
} s_t;
typedef s_t s1_t;
s_t s;
s_t s1;
s1_t s1;
p::p_t ps;