aboutsummaryrefslogtreecommitdiffstats
path: root/tests/various/param_struct.ys
diff options
context:
space:
mode:
authorKamil Rakoczy <krakoczy@antmicro.com>2021-11-16 10:59:54 +0100
committerGitHub <noreply@github.com>2021-11-16 10:59:54 +0100
commitfdb19a5b3a10572b1b84a26306ec5e83a4eff613 (patch)
tree9a968b5b8642361c6d0c14ec0b8887d153687dcb /tests/various/param_struct.ys
parent06bddb5e4902ddedf20cc7911289be06e0ce05e7 (diff)
downloadyosys-fdb19a5b3a10572b1b84a26306ec5e83a4eff613.tar.gz
yosys-fdb19a5b3a10572b1b84a26306ec5e83a4eff613.tar.bz2
yosys-fdb19a5b3a10572b1b84a26306ec5e83a4eff613.zip
Support parameters using struct as a wiretype (#3050)
Signed-off-by: Kamil Rakoczy <krakoczy@antmicro.com>
Diffstat (limited to 'tests/various/param_struct.ys')
-rw-r--r--tests/various/param_struct.ys51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/various/param_struct.ys b/tests/various/param_struct.ys
new file mode 100644
index 000000000..6d7a7c6ad
--- /dev/null
+++ b/tests/various/param_struct.ys
@@ -0,0 +1,51 @@
+read_verilog -sv << EOF
+package p;
+typedef struct packed {
+ logic a;
+ logic b;
+} struct_t;
+
+typedef struct packed {
+ struct_t g;
+ logic [2:0] h;
+} nested_struct_t;
+
+typedef union packed {
+ logic [4:0] x;
+} nested_union_t;
+
+parameter struct_t c = {1'b1, 1'b0};
+parameter nested_struct_t x = {{1'b1, 1'b0}, 1'b1, 1'b1, 1'b1};
+endpackage
+
+module dut ();
+parameter p::struct_t d = p::c;
+parameter p::nested_struct_t i = p::x;
+
+parameter p::nested_union_t u = {5'b11001};
+
+localparam e = d.a;
+localparam f = d.b;
+
+localparam j = i.g.a;
+localparam k = i.g.b;
+localparam l = i.h;
+localparam m = i.g;
+
+localparam o = u.x;
+
+always_comb begin
+ assert(d == 2'b10);
+ assert(e == 1'b1);
+ assert(f == 1'b0);
+ assert(j == 1'b1);
+ assert(k == 1'b0);
+ assert(l == 3'b111);
+// TODO: support access to whole sub-structs and unions
+// assert(m == 2'b10);
+ assert(u == 5'b11001);
+end
+endmodule
+EOF
+hierarchy; proc; opt
+sat -verify -seq 1 -tempinduct -prove-asserts -show-all