Skip to content

Commit fb9a9d4

Browse files
authored
Merge pull request #766 from diffblue/part-select-constant1
Verilog: constant folding for nonindexed part select
2 parents cc3bf4a + 3aa6eca commit fb9a9d4

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
part-select-constant1.sv
3+
--bound 0
4+
^\[.*\] .* PROVED up to bound 0$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module main;
2+
3+
// part-select expressions yield constants
4+
parameter p = 'b1010;
5+
parameter q = p[3:1];
6+
7+
assert final (q == 'b101);
8+
9+
endmodule

src/verilog/verilog_typecheck_expr.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1605,7 +1605,13 @@ exprt verilog_typecheck_exprt::elaborate_constant_expression(exprt expr)
16051605
PRECONDITION(false);
16061606
};
16071607

1608-
if(expr.id() == ID_reduction_or)
1608+
if(expr.id() == ID_verilog_non_indexed_part_select)
1609+
{
1610+
// Our simplifier does not know these, do lowering.
1611+
auto &part_select = to_verilog_non_indexed_part_select_expr(expr);
1612+
expr = part_select.lower();
1613+
}
1614+
else if(expr.id() == ID_reduction_or)
16091615
{
16101616
// The simplifier doesn't know how to simplify reduction_or
16111617
auto &reduction_or = to_unary_expr(expr);

0 commit comments

Comments
 (0)