From 4f9b34615162f005ec7197d81c018bea14ddc037 Mon Sep 17 00:00:00 2001 From: Iztok Jeras Date: Tue, 23 Jun 2026 23:15:23 +0200 Subject: [PATCH] dfflibmap: simpler handling of cells with inverted data input polarity --- passes/techmap/dfflibmap.cc | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/passes/techmap/dfflibmap.cc b/passes/techmap/dfflibmap.cc index 6a5fbe204..516043db7 100644 --- a/passes/techmap/dfflibmap.cc +++ b/passes/techmap/dfflibmap.cc @@ -293,18 +293,11 @@ static void find_cell_dff(std::vector cells, IdString cell_t if (!parse_next_state(cell, ff->find("next_state"), cell_next_pin, cell_next_pol, cell_enable_pin, cell_enable_pol) || (has_enable && (cell_enable_pin.empty() || cell_enable_pol != enapol))) continue; - bool cell_rstval = rstval; - if (has_reset && !cell_next_pol) { - // next_state is negated - // we later propagate this inversion to the output, - // which requires the negation of the reset value - cell_rstval = !rstval; - } - if (has_reset && cell_rstval == false) { + if (has_reset && rstval != cell_next_pol) { if (!parse_pin(cell, ff->find("clear"), cell_rst_pin, cell_rst_pol) || cell_rst_pol != rstpol) continue; } - if (has_reset && cell_rstval == true) { + if (has_reset && rstval == cell_next_pol) { if (!parse_pin(cell, ff->find("preset"), cell_rst_pin, cell_rst_pol) || cell_rst_pol != rstpol) continue; } @@ -553,17 +546,11 @@ static void find_cell_dlatch(std::vector cells, IdString cel if (!parse_pin(cell, latch->find("data_in"), cell_data_pin, cell_data_pol)) continue; - if (has_reset && !cell_data_pol) { - // data_in is negated - // we later propagate this inversion to the output, - // which requires the negation of the reset value - rstval = !rstval; - } - if (has_reset && rstval == false) { + if (has_reset && rstval != cell_data_pol) { if (!parse_pin(cell, latch->find("clear"), cell_rst_pin, cell_rst_pol) || cell_rst_pol != rstpol) continue; } - if (has_reset && rstval == true) { + if (has_reset && rstval == cell_data_pol) { if (!parse_pin(cell, latch->find("preset"), cell_rst_pin, cell_rst_pol) || cell_rst_pol != rstpol) continue; }