From ee3a4ce14dce584afeba4003232e934488c2701b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Tue, 7 Nov 2023 16:21:39 +0100 Subject: [PATCH 1/2] synth_lattice: Merge NOT gates on DFF control signals `dfflegalize` will emit NOT gates to drive control signals on flip-flops when mapping to supported flip-flop polarities. Typically in a design this will produce a number of NOT gates driven by the same signal. For one reason or another ABC doesn't fully cancel this redundancy during LUT mapping. Insert an explicit `opt_merge` pass to improve synthesis QoR. --- techlibs/lattice/synth_lattice.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/techlibs/lattice/synth_lattice.cc b/techlibs/lattice/synth_lattice.cc index e2987d025..7ecfb95de 100644 --- a/techlibs/lattice/synth_lattice.cc +++ b/techlibs/lattice/synth_lattice.cc @@ -409,6 +409,7 @@ struct SynthLatticePass : public ScriptPass dfflegalize_args += " -cell $_DLATCH_?_ x"; } run("dfflegalize" + dfflegalize_args, "($_ALDFF_*_ only if -asyncprld, $_DLATCH_* only if not -asyncprld, $_*DFFE_* only if not -nodffe)"); + run("opt_merge"); if ((abc9 && dff) || help_mode) run("zinit -all w:* t:$_DFF_?_ t:$_DFFE_??_ t:$_SDFF*", "(only if -abc9 and -dff)"); run("techmap -D NO_LUT -map +/lattice/cells_map.v"); From fed272099958bfc29dadec0ee366d20056171c00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Tue, 7 Nov 2023 16:25:20 +0100 Subject: [PATCH 2/2] synth_lattice: Optimize flip-flop memories better After `memory_map` maps memories to flip-flops we need to let `opt` remove undef muxes, otherwise we block enable/reset signal inference by `opt_dff` which is in detriment to QoR. --- techlibs/lattice/synth_lattice.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/techlibs/lattice/synth_lattice.cc b/techlibs/lattice/synth_lattice.cc index 7ecfb95de..738ef0334 100644 --- a/techlibs/lattice/synth_lattice.cc +++ b/techlibs/lattice/synth_lattice.cc @@ -373,7 +373,7 @@ struct SynthLatticePass : public ScriptPass { run("opt -fast -mux_undef -undriven -fine"); run("memory_map"); - run("opt -undriven -fine"); + run("opt -undriven -fine -mux_undef"); } if (check_label("map_gates"))