diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-05-03 07:38:44 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-05-04 19:04:06 +0200 |
commit | 02a92af133fe9e1c9beeedbbe6f8e664fbd4e7cc (patch) | |
tree | e359a6b9578bd159294a30efb7341b0d7a084432 /src/synth/netlists-butils.adb | |
parent | 55be56868c8589563046bacc2fd777fa44811847 (diff) | |
download | ghdl-02a92af133fe9e1c9beeedbbe6f8e664fbd4e7cc.tar.gz ghdl-02a92af133fe9e1c9beeedbbe6f8e664fbd4e7cc.tar.bz2 ghdl-02a92af133fe9e1c9beeedbbe6f8e664fbd4e7cc.zip |
netlists-butils: add a minor optimization to mux4.
Diffstat (limited to 'src/synth/netlists-butils.adb')
-rw-r--r-- | src/synth/netlists-butils.adb | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/synth/netlists-butils.adb b/src/synth/netlists-butils.adb index c1afb5588..c02239b8b 100644 --- a/src/synth/netlists-butils.adb +++ b/src/synth/netlists-butils.adb @@ -46,9 +46,6 @@ package body Netlists.Butils is -- Handle SEL bits by 2, so group case_element by 4. for I in 1 .. Natural (Wd / 2) loop - -- Extract 2 bits from the selector. - Sub_Sel := Build_Extract (Ctxt, Sel, Width (2 * (I - 1)), 2); - Set_Location (Sub_Sel, Sel_Loc); Mask := Shift_Left (not 0, Natural (2 * I)); Iels := Els'First; Oels := Els'First; @@ -61,6 +58,7 @@ package body Netlists.Butils is El_Idx : Natural; Rsel : Net; begin + -- Extract 2 bits from the selector. G := (others => Default); for K in 0 .. 3 loop exit when Iels > Lels; @@ -76,9 +74,19 @@ package body Netlists.Butils is and G (2) /= No_Net and G (3) /= No_Net then - Rsel := Build_Mux4 (Ctxt, - Sub_Sel, G (0), G (1), G (2), G (3)); - Set_Location (Rsel, Sel_Loc); + -- The 4 choices are available. + if G (0) = G (1) and G (0) = G (2) and G (0) = G (3) then + -- But they are the same: no need to choose! + Rsel := G (0); + else + Sub_Sel := Build_Extract (Ctxt, + Sel, Width (2 * (I - 1)), 2); + Set_Location (Sub_Sel, Sel_Loc); + + Rsel := Build_Mux4 (Ctxt, + Sub_Sel, G (0), G (1), G (2), G (3)); + Set_Location (Rsel, Sel_Loc); + end if; else for K in 0 .. 1 loop if G (2 * K) /= No_Net and G (2 * K + 1) /= No_Net then |