diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-06-23 11:38:40 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-06-23 11:38:40 +0200 |
commit | 766ca83af482b46a292ef50e4b96ccd34f2a58df (patch) | |
tree | 73b5cb19dd50fe302b6fa87b4cf88e60065ca159 | |
parent | 54f5e47e5c3e2d2ba9aa9e671a591b42200b1187 (diff) | |
download | ghdl-766ca83af482b46a292ef50e4b96ccd34f2a58df.tar.gz ghdl-766ca83af482b46a292ef50e4b96ccd34f2a58df.tar.bz2 ghdl-766ca83af482b46a292ef50e4b96ccd34f2a58df.zip |
synth-stmts: fix for unordered choices in case statement.
-rw-r--r-- | src/synth/synth-stmts.adb | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/synth/synth-stmts.adb b/src/synth/synth-stmts.adb index e00cf19e4..306441e6f 100644 --- a/src/synth/synth-stmts.adb +++ b/src/synth/synth-stmts.adb @@ -511,11 +511,16 @@ package body Synth.Stmts is Case_Info : Choice_Info_Type; Annex_Arr : Annex_Array_Acc; + + -- Array of alternatives Alts : Alternative_Data_Acc; Alt_Idx : Alternative_Index; + Others_Alt_Idx : Alternative_Index; + + -- Array of choices. Contains tuple of (Value, Alternative). Choice_Data : Choice_Data_Array_Acc; Choice_Idx : Natural; - Others_Alt_Idx : Alternative_Index; + Case_El : Case_Element_Array_Acc; Nbr_Wires : Natural; @@ -540,7 +545,7 @@ package body Synth.Stmts is -- to 2**W (eg: a partially filled memory) -- - divide and conquier - -- Create a wire for the expression. + -- Create a net for the expression. Sel := Synth_Expression (Syn_Inst, Expr); -- Count choices and alternatives. @@ -604,6 +609,7 @@ package body Synth.Stmts is end loop; pragma Assert (Choice_Idx = Choice_Data'Last); + -- Sort by order. Sort_String_Choices (Case_Info); -- Create list of wire_id, sort it. @@ -621,12 +627,14 @@ package body Synth.Stmts is Sel_Net := Get_Net (Sel, Get_Type (Expr)); + -- For each wire, compute the result. for I in Wires'Range loop declare Wi : constant Wire_Id := Wires (I); Last_Val : constant Net := Get_Last_Assigned_Value (Wi); Res : Net; Default : Net; + C : Natural; begin -- Extract the value for each alternative. for Alt of Alts.all loop @@ -642,9 +650,10 @@ package body Synth.Stmts is end loop; -- Build the map between choices and values. - for J in Choice_Data'Range loop - Case_El (J) := (Sel => Choice_Data (J).Val, - Val => Alts (Choice_Data (J).Alt).Val); + for J in Annex_Arr'Range loop + C := Natural (Annex_Arr (J)); + Case_El (J) := (Sel => Choice_Data (C).Val, + Val => Alts (Choice_Data (C).Alt).Val); end loop; -- Extract default value (for missing alternative). |