Skip to content

Commit 5c154f3

Browse files
committed
netlist: fix further extractbits off-by-one errors
This fixes a further extracbits off-by-one error in the netlist generator.
1 parent e31efbf commit 5c154f3

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CORE
2+
verilog3.sv
3+
--smv-netlist
4+
^EXIT=0$
5+
^SIGNAL=0$
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module main;
2+
wire [7:0] some_wire;
3+
wire [31:0] something_else;
4+
assign something_else = some_wire[7:1];
5+
endmodule

src/trans-netlist/trans_to_netlist.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,10 @@ void convert_trans_to_netlistt::convert_lhs_rec(
594594
if(!to_integer_non_constant(to_extractbits_expr(expr).index(), new_from))
595595
{
596596
boolbv_widtht boolbv_width(ns);
597-
mp_integer new_to = new_from + boolbv_width(expr.type());
597+
const auto width = boolbv_width(expr.type());
598+
DATA_INVARIANT(
599+
width != 0, "trans_to_netlist got extractbits with zero-width operand");
600+
mp_integer new_to = new_from + width - 1;
598601

599602
from = new_from.to_ulong();
600603
to = new_to.to_ulong();

0 commit comments

Comments
 (0)