diff --git a/ivtest/ivltests/br_gh1385.v b/ivtest/ivltests/br_gh1385.v new file mode 100644 index 000000000..40a382b2f --- /dev/null +++ b/ivtest/ivltests/br_gh1385.v @@ -0,0 +1,39 @@ +// Check that enum literals declared inside generate blocks are available in +// the generated scope. + +module test; + + reg failed; + + `define check(val, exp) do begin \ + if (val !== exp) begin \ + $display("FAILED(%0d). '%s' expected %b, got %b", `__LINE__, \ + `"val`", exp, val); \ + failed = 1'b1; \ + end \ + end while (0) + + if (1) begin : g + typedef enum logic [3:0] { + A = 4'd1, + B = 4'd2 + } EN_T; + + EN_T e = A; + + initial begin + failed = 1'b0; + + #1; + `check(e, A); + + e = B; + `check(e, B); + + if (!failed) begin + $display("PASSED"); + end + end + end + +endmodule diff --git a/ivtest/ivltests/br_gh1385a.v b/ivtest/ivltests/br_gh1385a.v new file mode 100644 index 000000000..e0cd4d1c1 --- /dev/null +++ b/ivtest/ivltests/br_gh1385a.v @@ -0,0 +1,37 @@ +// Check that enum literals declared inside named blocks are available in +// the block scope. + +module test; + + reg failed; + + `define check(val, exp) do begin \ + if (val !== exp) begin \ + $display("FAILED(%0d). '%s' expected %b, got %b", `__LINE__, \ + `"val`", exp, val); \ + failed = 1'b1; \ + end \ + end while (0) + + initial begin : b + typedef enum logic [3:0] { + A = 4'd1, + B = 4'd2 + } EN_T; + + static EN_T e = A; + + failed = 1'b0; + + #1; + `check(e, A); + + e = B; + `check(e, B); + + if (!failed) begin + $display("PASSED"); + end + end + +endmodule diff --git a/ivtest/ivltests/br_gh1385b.v b/ivtest/ivltests/br_gh1385b.v new file mode 100644 index 000000000..26d15a52f --- /dev/null +++ b/ivtest/ivltests/br_gh1385b.v @@ -0,0 +1,41 @@ +// Check that enum literals declared inside tasks are available in the task +// scope. + +module test; + + reg failed; + + `define check(val, exp) do begin \ + if (val !== exp) begin \ + $display("FAILED(%0d). '%s' expected %b, got %b", `__LINE__, \ + `"val`", exp, val); \ + failed = 1'b1; \ + end \ + end while (0) + + task check_task_enum; + typedef enum logic [3:0] { + A = 4'd1, + B = 4'd2 + } EN_T; + + static EN_T e = A; + + `check(e, A); + + e = B; + `check(e, B); + endtask + + initial begin + failed = 1'b0; + + #1; + check_task_enum(); + + if (!failed) begin + $display("PASSED"); + end + end + +endmodule diff --git a/ivtest/ivltests/br_gh1385c.v b/ivtest/ivltests/br_gh1385c.v new file mode 100644 index 000000000..0a5117ee6 --- /dev/null +++ b/ivtest/ivltests/br_gh1385c.v @@ -0,0 +1,39 @@ +// Check that enum literals declared inside functions are available in the +// function scope. + +module test; + + reg failed; + + `define check(val, exp) do begin \ + if (val !== exp) begin \ + $display("FAILED(%0d). '%s' expected %b, got %b", `__LINE__, \ + `"val`", exp, val); \ + failed = 1'b1; \ + end \ + end while (0) + + function logic [3:0] check_func_enum; + typedef enum logic [3:0] { + A = 4'd1, + B = 4'd2 + } EN_T; + + static EN_T e = A; + + e = B; + check_func_enum = e; + endfunction + + initial begin + failed = 1'b0; + + #1; + `check(check_func_enum(), 4'd2); + + if (!failed) begin + $display("PASSED"); + end + end + +endmodule diff --git a/ivtest/regress-vvp.list b/ivtest/regress-vvp.list index df582b9e6..1758a35a0 100644 --- a/ivtest/regress-vvp.list +++ b/ivtest/regress-vvp.list @@ -82,6 +82,10 @@ br_gh1258a vvp_tests/br_gh1258a.json br_gh1258b vvp_tests/br_gh1258b.json br_gh1286 vvp_tests/br_gh1286.json br_gh1323 vvp_tests/br_gh1323.json +br_gh1385 vvp_tests/br_gh1385.json +br_gh1385a vvp_tests/br_gh1385a.json +br_gh1385b vvp_tests/br_gh1385b.json +br_gh1385c vvp_tests/br_gh1385c.json ca_time_real vvp_tests/ca_time_real.json case1 vvp_tests/case1.json case2 vvp_tests/case2.json diff --git a/ivtest/vvp_tests/br_gh1385.json b/ivtest/vvp_tests/br_gh1385.json new file mode 100644 index 000000000..8cdc9e3d5 --- /dev/null +++ b/ivtest/vvp_tests/br_gh1385.json @@ -0,0 +1,9 @@ +{ + "type" : "normal", + "source" : "br_gh1385.v", + "iverilog-args" : [ "-g2005-sv" ], + "vlog95" : { + "__comment" : "Generate scopes are not translated", + "type" : "CE" + } +} diff --git a/ivtest/vvp_tests/br_gh1385a.json b/ivtest/vvp_tests/br_gh1385a.json new file mode 100644 index 000000000..82757362e --- /dev/null +++ b/ivtest/vvp_tests/br_gh1385a.json @@ -0,0 +1,9 @@ +{ + "type" : "normal", + "source" : "br_gh1385a.v", + "iverilog-args" : [ "-g2005-sv" ], + "vlog95" : { + "__comment" : "Enum typedefs are not translated", + "type" : "CE" + } +} diff --git a/ivtest/vvp_tests/br_gh1385b.json b/ivtest/vvp_tests/br_gh1385b.json new file mode 100644 index 000000000..c2e17a36d --- /dev/null +++ b/ivtest/vvp_tests/br_gh1385b.json @@ -0,0 +1,9 @@ +{ + "type" : "normal", + "source" : "br_gh1385b.v", + "iverilog-args" : [ "-g2005-sv" ], + "vlog95" : { + "__comment" : "Enum typedefs are not translated", + "type" : "CE" + } +} diff --git a/ivtest/vvp_tests/br_gh1385c.json b/ivtest/vvp_tests/br_gh1385c.json new file mode 100644 index 000000000..8f0c46a12 --- /dev/null +++ b/ivtest/vvp_tests/br_gh1385c.json @@ -0,0 +1,9 @@ +{ + "type" : "normal", + "source" : "br_gh1385c.v", + "iverilog-args" : [ "-g2005-sv" ], + "vlog95" : { + "__comment" : "Enum typedefs are not translated", + "type" : "CE" + } +}