mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-24 01:25:33 +00:00
opt_expr: Fix #4590
If all the (non-select) inputs of a `$_MUX{4,8,16}_` are undefined, replace it, just like we do for `$mux` and `$_MUX_`. Add `tests/opt/opt_expr_mux_undef.ys` to verify this. This doesn't do any const folding on the wide muxes, or shrinking to less wide muxes. It only handles the case where all inputs are 'x and the mux can be completely removed.
This commit is contained in:
parent
63b3ce0c77
commit
406b400458
2 changed files with 304 additions and 0 deletions
|
@ -1573,6 +1573,20 @@ skip_identity:
|
|||
}
|
||||
}
|
||||
|
||||
if (mux_undef && cell->type.in(ID($_MUX4_), ID($_MUX8_), ID($_MUX16_))) {
|
||||
int num_inputs = 4;
|
||||
if (cell->type == ID($_MUX8_)) num_inputs = 8;
|
||||
if (cell->type == ID($_MUX16_)) num_inputs = 16;
|
||||
int undef_inputs = 0;
|
||||
for (auto &conn : cell->connections())
|
||||
if (!conn.first.in(ID::S, ID::T, ID::U, ID::V, ID::Y))
|
||||
undef_inputs += conn.second.is_fully_undef();
|
||||
if (undef_inputs == num_inputs) {
|
||||
replace_cell(assign_map, module, cell, "mux_undef", ID::Y, cell->getPort(ID::A));
|
||||
goto next_cell;
|
||||
}
|
||||
}
|
||||
|
||||
#define FOLD_1ARG_CELL(_t) \
|
||||
if (cell->type == ID($##_t)) { \
|
||||
RTLIL::SigSpec a = cell->getPort(ID::A); \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue