diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-04-12 23:28:42 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-04-12 23:31:20 +0200 |
commit | 3cfe2f9a62f7444cfb00c7c86a67aada2f7bae3f (patch) | |
tree | 7a0e00321f6eb50c06920b55181f9bdfe272f67e /src/synth | |
parent | 7b066064cc558b070a46c4d50aa54544101f2c2b (diff) | |
download | ghdl-3cfe2f9a62f7444cfb00c7c86a67aada2f7bae3f.tar.gz ghdl-3cfe2f9a62f7444cfb00c7c86a67aada2f7bae3f.tar.bz2 ghdl-3cfe2f9a62f7444cfb00c7c86a67aada2f7bae3f.zip |
synth-aggr: fix record aggregate element order. Fix #1217
Diffstat (limited to 'src/synth')
-rw-r--r-- | src/synth/synth-aggr.adb | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/synth/synth-aggr.adb b/src/synth/synth-aggr.adb index 25f32cacd..f915a7323 100644 --- a/src/synth/synth-aggr.adb +++ b/src/synth/synth-aggr.adb @@ -269,6 +269,7 @@ package body Synth.Aggr is Assoc : Node; Pos : Nat32; + -- POS is the element position, from 0 to nbr el - 1. procedure Set_Elem (Pos : Nat32) is Val : Valtyp; @@ -281,7 +282,9 @@ package body Synth.Aggr is Const_P := False; end if; Val := Synth_Subtype_Conversion (Val, El_Type, False, Value); - Rec (Nat32 (Pos + 1)) := Val; + -- Put in reverse order. The first record element (at position 0) + -- will be the LSB, so the last element of REC. + Rec (Nat32 (Rec'Last - Pos)) := Val; end Set_Elem; begin Assoc := Get_Association_Choices_Chain (Aggr); @@ -297,7 +300,7 @@ package body Synth.Aggr is when Iir_Kind_Choice_By_Others => for I in Rec'Range loop if Rec (I) = No_Valtyp then - Set_Elem (I - 1); + Set_Elem (Rec'Last - I); end if; end loop; when Iir_Kind_Choice_By_Name => @@ -322,7 +325,7 @@ package body Synth.Aggr is Arr : Net_Array_Acc; Idx : Nat32; begin - Arr := new Net_Array (Tab'Range); + Arr := new Net_Array (1 .. Tab'Length); Idx := 0; for I in Arr'Range loop if Tab (I).Val /= null then @@ -395,7 +398,7 @@ package body Synth.Aggr is Res := Create_Value_Memory (Aggr_Type); for I in Aggr_Type.Rec.E'Range loop Write_Value (Res.Val.Mem + Aggr_Type.Rec.E (I).Moff, - Tab_Res (Nat32 (I))); + Tab_Res (Tab_Res'Last - Nat32 (I) + 1)); end loop; else Res := Create_Value_Net |