aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-04-18 16:18:29 +0200
committerTristan Gingold <tgingold@free.fr>2020-04-18 16:18:29 +0200
commit49bcc683d35a606cb5d1d3629c512ded052dd442 (patch)
tree11ca12be25a8d649f40ac6fa5fbd0d6271c2e4da
parent8ae404dfdd4ef08262d2fdfeaeffc997cdb10596 (diff)
downloadghdl-49bcc683d35a606cb5d1d3629c512ded052dd442.tar.gz
ghdl-49bcc683d35a606cb5d1d3629c512ded052dd442.tar.bz2
ghdl-49bcc683d35a606cb5d1d3629c512ded052dd442.zip
netlists-butils: handle case statement with negative values. Fix #1240
-rw-r--r--src/synth/netlists-butils.adb54
1 files changed, 35 insertions, 19 deletions
diff --git a/src/synth/netlists-butils.adb b/src/synth/netlists-butils.adb
index 7b74def6d..c1afb5588 100644
--- a/src/synth/netlists-butils.adb
+++ b/src/synth/netlists-butils.adb
@@ -71,29 +71,45 @@ package body Netlists.Butils is
G (El_Idx) := Els (Iels).Val;
Iels := Iels + 1;
end loop;
- if G (3) /= No_Net then
+ if G (0) /= No_Net
+ and G (1) /= No_Net
+ 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);
- elsif G (2) /= No_Net then
- Rsel := Build_Mux2
- (Ctxt,
- Build_Extract_Bit (Ctxt, Sel, Width (2 * (I - 1)) + 1),
- Build_Mux2 (Ctxt,
- Build_Extract_Bit (Ctxt,
- Sel, Width (2 * (I - 1))),
- G (0), G (1)),
- G (2));
- Set_Location (Rsel, Sel_Loc);
- elsif G (1) /= No_Net then
- Rsel := Build_Mux2
- (Ctxt,
- Build_Extract_Bit (Ctxt,
- Sel, Width (2 * (I - 1))),
- G (0), G (1));
- Set_Location (Rsel, Sel_Loc);
else
- Rsel := G (0);
+ for K in 0 .. 1 loop
+ if G (2 * K) /= No_Net and G (2 * K + 1) /= No_Net then
+ G (K) := Build_Mux2
+ (Ctxt,
+ Build_Extract_Bit
+ (Ctxt, Sel, Width (2 * (I - 1))),
+ G (2 * K), G (2 * K + 1));
+ Set_Location (G (K), Sel_Loc);
+ else
+ if G (2 * K) /= No_Net then
+ G (K) := G (2 * K);
+ else
+ G (K) := G (2 * K + 1);
+ end if;
+ end if;
+ end loop;
+ if G (0) /= No_Net and G (1) /= No_Net then
+ Rsel := Build_Mux2
+ (Ctxt,
+ Build_Extract_Bit (Ctxt, Sel,
+ Width (2 * (I - 1) + 1)),
+ G (0), G (1));
+ Set_Location (Rsel, Sel_Loc);
+ else
+ if G (0) /= No_Net then
+ Rsel := G (0);
+ else
+ Rsel := G (1);
+ end if;
+ end if;
end if;
Els (Oels) := (Sel => S_Group, Val => Rsel);
Oels := Oels + 1;