From f0ae046c5a712af91d8a10e2a8724f934989d848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Wed, 19 Jul 2023 20:08:22 +0200 Subject: [PATCH] opt_share: Fix input confusion with ANDNOT, ORNOT gates Distinguish between the A, B input ports of `$_ANDNOT_`, `$_ORNOT_` gates when considering those for sharing. Unlike the input ports of the other supported single-bit gates, those are not interchangeable. Fixes #3848. --- passes/opt/opt_share.cc | 3 +++ tests/opt/bug3848.ys | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tests/opt/bug3848.ys diff --git a/passes/opt/opt_share.cc b/passes/opt/opt_share.cc index ba85df975..bf9569d99 100644 --- a/passes/opt/opt_share.cc +++ b/passes/opt/opt_share.cc @@ -131,6 +131,9 @@ RTLIL::IdString decode_port_semantics(RTLIL::Cell *cell, RTLIL::IdString port_na if (cell->type.in(ID($lt), ID($le), ID($ge), ID($gt), ID($div), ID($mod), ID($divfloor), ID($modfloor), ID($concat), SHIFT_OPS) && port_name == ID::B) return port_name; + if (cell->type.in(ID($_ANDNOT_), ID($_ORNOT_))) + return port_name; + return ""; } diff --git a/tests/opt/bug3848.ys b/tests/opt/bug3848.ys new file mode 100644 index 000000000..32f540346 --- /dev/null +++ b/tests/opt/bug3848.ys @@ -0,0 +1,28 @@ +read_verilog -icells <