Add regression tests for enum typedefs in nested scopes
Check that enum literals declared by enum typedefs in generate blocks, named blocks, tasks and functions can be referenced from the same scope. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
9bc86af284
commit
10349287a0
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"type" : "normal",
|
||||
"source" : "br_gh1385.v",
|
||||
"iverilog-args" : [ "-g2005-sv" ],
|
||||
"vlog95" : {
|
||||
"__comment" : "Generate scopes are not translated",
|
||||
"type" : "CE"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"type" : "normal",
|
||||
"source" : "br_gh1385a.v",
|
||||
"iverilog-args" : [ "-g2005-sv" ],
|
||||
"vlog95" : {
|
||||
"__comment" : "Enum typedefs are not translated",
|
||||
"type" : "CE"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"type" : "normal",
|
||||
"source" : "br_gh1385b.v",
|
||||
"iverilog-args" : [ "-g2005-sv" ],
|
||||
"vlog95" : {
|
||||
"__comment" : "Enum typedefs are not translated",
|
||||
"type" : "CE"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"type" : "normal",
|
||||
"source" : "br_gh1385c.v",
|
||||
"iverilog-args" : [ "-g2005-sv" ],
|
||||
"vlog95" : {
|
||||
"__comment" : "Enum typedefs are not translated",
|
||||
"type" : "CE"
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue