Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions test/err_scope_name_clash/dut.sv
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// A generate block named like another declaration of its scope (LRM 3.13,
// 27.6). Legal forms must stay silent; each ILLEGAL line is one error.
module err_scope_name_clash #(parameter int N = 2) (
input logic [3:0] a,
output logic [3:0] y
);
logic named;
logic [3:0] acc;

// Legal: one label on both branches of a conditional generate, a loop of
// several iterations, labels distinct from every declaration.
if (N == 2) begin : g_sel
assign y = a;
end else begin : g_sel
assign y = ~a;
end
for (genvar i = 0; i < 4; i++) begin : g_bits
assign acc[i] = a[i];
end
assign named = acc[0];

// Illegal.
for (genvar i = 0; i < 1; i++) begin : named // ILLEGAL: a reg's name
end
for (genvar i = 0; i < 1; i++) begin : g_twice
end
for (genvar i = 0; i < 1; i++) begin : g_twice // ILLEGAL: second g_twice
end
if (N > 0) begin : blk
end
initial begin : blk // ILLEGAL: clashes above
end
endmodule
7 changes: 7 additions & 0 deletions test/err_scope_name_clash/test_structural.ys
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# The read must FAIL: Surelog reports UH0744 on the three ILLEGAL generate
# block names in dut.sv (one repeats a reg's name, one repeats another
# generate block, one is repeated by a named initial block). The exact
# count pins it to those: a label shared by the two branches of a
# conditional generate and the iterations of one loop must stay silent.
logger -expect error "Surelog reported 0 fatal, 0 syntax and 3 other error" 1
read_sv -nonote -noinfo -nowarning dut.sv
Loading