Skip to content

Commit

Permalink
Verilog: generate ... endgenerate is optional
Browse files Browse the repository at this point in the history
The use of generate ... endgenerate became optional with 1364-2005.

Fixes issue #747.
  • Loading branch information
kroening committed Oct 3, 2024
1 parent 2e01686 commit ef84975
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
9 changes: 9 additions & 0 deletions regression/verilog/generate/generate-for3.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CORE
generate-for3.v
--module main --bound 1
^EXIT=0$
^SIGNAL=0$
--
--
The generate ... endgenerate keywords became optional with 1364-2005.
https://github.com/diffblue/hw-cbmc/issues/747
13 changes: 13 additions & 0 deletions regression/verilog/generate/generate-for3.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module main;

wire [15:0] some_wire;

// The generate ... endgenerate became optional with 1364-2005.
genvar i;
for (i = 0; i <= 15; i = i + 1)
assign some_wire[i] = (i%2) == 0;

// should pass
always assert property1: some_wire == 'b0101_0101_0101_0101;

endmodule
4 changes: 3 additions & 1 deletion src/verilog/verilog_elaborate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,9 @@ verilog_typecheckt::elaborate_level(const module_itemst &module_items)

for(auto &module_item : module_items)
{
if(module_item.id() == ID_generate_block)
if(
module_item.id() == ID_generate_block ||
module_item.id() == ID_generate_for || module_item.id() == ID_generate_if)
{
// elaborate_generate_item calls elaborate_level
// recursively.
Expand Down

0 comments on commit ef84975

Please sign in to comment.