diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-06-23 18:13:41 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-06-23 18:13:41 +0200 |
commit | c98cd530f2e58ecff06c6065c6e7427bf727875d (patch) | |
tree | 11db1dec79bfb332e1e406b4a959adf170d95f83 | |
parent | 4d7e1c0107a4656d76d9dbdddcd7cb34781d6d21 (diff) | |
download | ghdl-c98cd530f2e58ecff06c6065c6e7427bf727875d.tar.gz ghdl-c98cd530f2e58ecff06c6065c6e7427bf727875d.tar.bz2 ghdl-c98cd530f2e58ecff06c6065c6e7427bf727875d.zip |
synth: handle discrete choice in case statements.
-rw-r--r-- | src/synth/synth-stmts.adb | 6 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_expr.adb | 10 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/synth/synth-stmts.adb b/src/synth/synth-stmts.adb index 934584566..17be7396a 100644 --- a/src/synth/synth-stmts.adb +++ b/src/synth/synth-stmts.adb @@ -610,7 +610,11 @@ package body Synth.Stmts is pragma Assert (Choice_Idx = Choice_Data'Last); -- Sort by order. - Sort_String_Choices (Case_Info); + if Get_Kind (Get_Type (Expr)) in Iir_Kinds_Discrete_Type_Definition then + Sort_Discrete_Choices (Case_Info); + else + Sort_String_Choices (Case_Info); + end if; -- Create list of wire_id, sort it. Nbr_Wires := Count_Wires_In_Alternatives (Alts.all); diff --git a/src/vhdl/vhdl-sem_expr.adb b/src/vhdl/vhdl-sem_expr.adb index 2bfe77b49..e434ce0c1 100644 --- a/src/vhdl/vhdl-sem_expr.adb +++ b/src/vhdl/vhdl-sem_expr.adb @@ -2196,12 +2196,12 @@ package body Vhdl.Sem_Expr is is -- Compare two elements of ARR. -- Return true iff OP1 < OP2. - function Lt (Op1, Op2 : Natural) return Boolean is + function Lt (Op1, Op2 : Natural) return Boolean + is + E1 : constant Iir := Get_Choice_Expression (Info.Arr (Op1)); + E2 : constant Iir := Get_Choice_Expression (Info.Arr (Op2)); begin - return Compare_String_Literals - (Get_Choice_Expression (Info.Arr (Op1)), - Get_Choice_Expression (Info.Arr (Op2))) - = Compare_Lt; + return Compare_String_Literals (E1, E2) = Compare_Lt; end Lt; procedure Swap (From : Natural; To : Natural) is |