Skip to content

Commit

Permalink
Verilog: pull out recursive application of verilog_synthesist::synth_…
Browse files Browse the repository at this point in the history
…expr

verilog_synthesist::synth_expr is always applied recursively to the operands
of the given expression.  This commit pulls this out of the case split.
  • Loading branch information
kroening committed Oct 7, 2024
1 parent 8bbc75e commit ab546f8
Showing 1 changed file with 4 additions and 24 deletions.
28 changes: 4 additions & 24 deletions src/verilog/verilog_synthesis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ Function: verilog_synthesist::synth_expr

exprt verilog_synthesist::synth_expr(exprt expr, symbol_statet symbol_state)
{
// Do the operands recursively
for(auto &op : expr.operands())
op = synth_expr(op, symbol_state);

if(expr.id()==ID_symbol)
{
const symbolt &symbol=ns.lookup(to_symbol_expr(expr));
Expand Down Expand Up @@ -245,9 +249,6 @@ exprt verilog_synthesist::synth_expr(exprt expr, symbol_statet symbol_state)
}
else if(expr.id() == ID_concatenation)
{
for(auto &op : expr.operands())
op = synth_expr(op, symbol_state);

if(
expr.type().id() == ID_verilog_unsignedbv ||
expr.type().id() == ID_verilog_signedbv)
Expand Down Expand Up @@ -276,8 +277,6 @@ exprt verilog_synthesist::synth_expr(exprt expr, symbol_statet symbol_state)
DATA_INVARIANT(
power_expr.lhs().type() == power_expr.type(),
"power expression type consistency");
power_expr.lhs() = synth_expr(power_expr.lhs(), symbol_state);
power_expr.rhs() = synth_expr(power_expr.rhs(), symbol_state);

// encode into aval/bval
if(is_four_valued(expr.type()))
Expand Down Expand Up @@ -306,7 +305,6 @@ exprt verilog_synthesist::synth_expr(exprt expr, symbol_statet symbol_state)
{
{
auto &op = to_typecast_expr(expr).op();
op = synth_expr(op, symbol_state);

// we perform some form of simplification for these
if(op.is_constant())
Expand Down Expand Up @@ -347,8 +345,6 @@ exprt verilog_synthesist::synth_expr(exprt expr, symbol_statet symbol_state)
auto &part_select = to_verilog_non_indexed_part_select_expr(expr);
auto &src = part_select.src();

src = synth_expr(src, symbol_state);

auto op1 = numeric_cast_v<mp_integer>(to_constant_expr(part_select.msb()));
auto op2 = numeric_cast_v<mp_integer>(to_constant_expr(part_select.lsb()));

Expand Down Expand Up @@ -449,46 +445,30 @@ exprt verilog_synthesist::synth_expr(exprt expr, symbol_statet symbol_state)
}
else if(expr.id() == ID_verilog_logical_equality)
{
for(auto &op : expr.operands())
op = synth_expr(op, symbol_state);
return aval_bval(to_verilog_logical_equality_expr(expr));
}
else if(expr.id() == ID_verilog_logical_inequality)
{
for(auto &op : expr.operands())
op = synth_expr(op, symbol_state);
return aval_bval(to_verilog_logical_inequality_expr(expr));
}
else if(expr.id() == ID_verilog_wildcard_equality)
{
for(auto &op : expr.operands())
op = synth_expr(op, symbol_state);
return aval_bval(to_verilog_wildcard_equality_expr(expr));
}
else if(expr.id() == ID_verilog_wildcard_inequality)
{
for(auto &op : expr.operands())
op = synth_expr(op, symbol_state);
return aval_bval(to_verilog_wildcard_inequality_expr(expr));
}
else if(expr.id() == ID_not)
{
auto &not_expr = to_not_expr(expr);
not_expr.op() = synth_expr(not_expr.op(), symbol_state);

// encode into aval/bval
if(is_four_valued(expr.type()))
return aval_bval(not_expr);
else
return expr; // leave as is
}
else if(expr.has_operands())
{
for(auto &op : expr.operands())
op = synth_expr(op, symbol_state);

return expr;
}
else
return expr; // leave as is

Expand Down

0 comments on commit ab546f8

Please sign in to comment.