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

Allow structs within structs.

This commit is contained in:
Peter Crozier 2020-05-12 17:20:34 +01:00
parent f482c9c016
commit 17f050d3c6
3 changed files with 38 additions and 7 deletions

View file

@ -15,6 +15,13 @@ module top;
bit [7:0] d;
} pack1;
struct packed {
byte a;
struct packed {
byte x, y;
} b;
} s2;
assign s.a = '1;
assign s.b = '1;
assign s.c = 8'hAA;
@ -25,6 +32,7 @@ module top;
assign pack1.b = 16'hAAAA;
assign pack1.c = '1;
assign pack1.d = 8'h55;
assign s2.b.x = 'h42;
always_comb assert(s.a == 1'b1);
always_comb assert(s.c == 8'hAA);
@ -35,5 +43,6 @@ module top;
always_comb assert(pack1.c == 8'hFF);
always_comb assert(pack1[15:8] == 8'hFF);
always_comb assert(pack1.d == 8'h55);
always_comb assert(s2.b.x == 'h42);
endmodule

View file

@ -58,4 +58,15 @@ module top;
assert(ir1.u.imm == 'hAA01);
end
union packed {
int word;
struct packed {
byte a, b, c, d;
} byte4;
} u;
assign u.word = 'h42;
always_comb begin
assert(u.byte4.d == 'h42);
end
endmodule