Allow combination of rand and const modifiers
authorZachary Snow <zach@zachjs.com>
Thu, 21 Jan 2021 15:30:55 +0000 (08:30 -0700)
committerZachary Snow <zach@zachjs.com>
Thu, 21 Jan 2021 15:42:05 +0000 (08:42 -0700)
frontends/verilog/verilog_parser.y
tests/various/rand_const.sv [new file with mode: 0644]
tests/various/rand_const.ys [new file with mode: 0644]

index 2886db0e56a134963cfc2fa06d82c2a1f5b5cb03..8bd58d24c8cb0ec089c3a09ebdb6a0ecbf6655d7 100644 (file)
@@ -651,8 +651,16 @@ wire_type_signedness:
        %empty;
 
 wire_type_const_rand:
-       TOK_CONST { current_wire_const = true; } |
-       TOK_RAND  { current_wire_rand = true;  } |
+       TOK_RAND TOK_CONST {
+           current_wire_rand = true;
+           current_wire_const = true;
+       } |
+       TOK_CONST {
+           current_wire_const = true;
+       } |
+       TOK_RAND {
+           current_wire_rand = true;
+       } |
        %empty;
 
 opt_wire_type_token:
diff --git a/tests/various/rand_const.sv b/tests/various/rand_const.sv
new file mode 100644 (file)
index 0000000..be00812
--- /dev/null
@@ -0,0 +1,8 @@
+module top;
+       rand const reg rx;
+       const reg ry;
+       rand reg rz;
+       rand const integer ix;
+       const integer iy;
+       rand integer iz;
+endmodule
diff --git a/tests/various/rand_const.ys b/tests/various/rand_const.ys
new file mode 100644 (file)
index 0000000..74e43c7
--- /dev/null
@@ -0,0 +1 @@
+read_verilog -sv rand_const.sv