Skip to content

Commit 38fdb6d

Browse files
committed
Add regression test for case-generate defaults without a colon
Check an omitted colon before a single module item and a named block containing a nested generate. Check both a matching case and the default selection. The vlog95 variant expects a compilation error because that backend does not translate generate scopes. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
1 parent bd50e65 commit 38fdb6d

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Check that a case-generate default does not require a colon.
2+
3+
module M #(parameter SELECT = 0) (output [1:0] value);
4+
5+
generate
6+
case (SELECT)
7+
0: assign value[0] = 1'b0;
8+
default assign value[0] = 1'b1;
9+
endcase
10+
case (SELECT)
11+
0: assign value[1] = 1'b0;
12+
default begin : g
13+
if (1) begin : nested
14+
assign value[1] = 1'b1;
15+
end
16+
end
17+
endcase
18+
endgenerate
19+
20+
endmodule
21+
22+
module test;
23+
24+
wire [1:0] matched, unmatched;
25+
26+
M #(0) i_matched(matched);
27+
M #(1) i_unmatched(unmatched);
28+
29+
initial begin
30+
#1;
31+
if (matched !== 2'b00 || unmatched !== 2'b11) begin
32+
$display("FAILED: matched=%b unmatched=%b", matched, unmatched);
33+
end else begin
34+
$display("PASSED");
35+
end
36+
end
37+
38+
endmodule

‎ivtest/regress-vvp.list‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class_property_array_invalid_compare vvp_tests/class_property_array_invalid_comp
9393
class_property_array_invalid_read vvp_tests/class_property_array_invalid_read.json
9494
class_property_array_invalid_write vvp_tests/class_property_array_invalid_write.json
9595
constfunc_call_signedness vvp_tests/constfunc_call_signedness.json
96+
generate_case_default vvp_tests/generate_case_default.json
9697
initial_null vvp_tests/initial_null.json
9798
initial_null_verilog_fail vvp_tests/initial_null_verilog_fail.json
9899
packed_typedef_part_select vvp_tests/packed_typedef_part_select.json
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type" : "normal",
3+
"source" : "generate_case_default.v",
4+
"iverilog-args" : [ "-g2001" ],
5+
"vlog95" : {
6+
"__comment" : "Generate scopes are not translated by vlog95.",
7+
"type" : "CE"
8+
}
9+
}

0 commit comments

Comments
 (0)