diff --git a/ivtest/ivltests/bits3.v b/ivtest/ivltests/bits3.v new file mode 100644 index 000000000..3c1e87b23 --- /dev/null +++ b/ivtest/ivltests/bits3.v @@ -0,0 +1,34 @@ +// Check that passing a data type to $bits works as expected + +module test; + +bit failed = 1'b0; + +`define check(type, value) \ + if ($bits(type) !== value) begin \ + $display("FAILED: $bits(", `"type`", ") is %0d", $bits(type), " expected %0d", value); \ + failed = 1'b1; \ + end + +typedef int T1; +typedef int T2[3:0]; + +initial begin + `check(reg, 1); + `check(logic, 1); + `check(bit, 1); + `check(logic [3:0], 4); + `check(byte, 8); + `check(shortint, 16); + `check(int, 32); + `check(longint, 64); + `check(struct packed { int x; shortint y; }, 32 + 16); + `check(T1, 32); + `check(T2, 4 * 32); + + if (failed == 1'b0) begin + $display("PASSED"); + end +end + +endmodule diff --git a/ivtest/regress-sv.list b/ivtest/regress-sv.list index fc9d76edf..f2102f74a 100644 --- a/ivtest/regress-sv.list +++ b/ivtest/regress-sv.list @@ -101,6 +101,7 @@ assign_op_type normal,-g2009 ivltests bitp1 normal,-g2005-sv ivltests bits normal,-g2005-sv ivltests bits2 normal,-g2005-sv ivltests +bits3 normal,-g2005-sv ivltests br884 normal,-g2009 ivltests br917a normal,-g2009 ivltests br917b normal,-g2009 ivltests