From 561b15d8066fcaa2147b7e95d9e2bcc7044c7f36 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Tue, 8 Oct 2019 18:49:57 +0200 Subject: synth: fix incorrect order for concat. --- src/synth/netlists-concats.adb | 7 +++++-- src/synth/synth-context.adb | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/synth/netlists-concats.adb b/src/synth/netlists-concats.adb index c833531b5..4c94fa6ac 100644 --- a/src/synth/netlists-concats.adb +++ b/src/synth/netlists-concats.adb @@ -56,6 +56,7 @@ package body Netlists.Concats is N := Build_Concat4 (Ctxt, C.Sarr (4), C.Sarr (3), C.Sarr (2), C.Sarr (1)); when 5 .. Static_Last => + -- Compute length. Wd := 0; for I in 1 .. C.Len loop Wd := Wd + Get_Width (C.Sarr (I)); @@ -64,9 +65,10 @@ package body Netlists.Concats is N := Build_Concatn (Ctxt, Wd, Uns32 (C.Len)); Inst := Get_Net_Parent (N); for I in 1 .. C.Len loop - Connect (Get_Input (Inst, Port_Idx (I - 1)), C.Sarr (I)); + Connect (Get_Input (Inst, Port_Idx (C.Len - I)), C.Sarr (I)); end loop; when Static_Last + 1 .. Int32'Last => + -- Compute length. pragma Assert (C.Len = Net_Tables.Last (C.Darr)); Wd := 0; for I in 1 .. C.Len loop @@ -76,7 +78,8 @@ package body Netlists.Concats is N := Build_Concatn (Ctxt, Wd, Uns32 (C.Len)); Inst := Get_Net_Parent (N); for I in Net_Tables.First .. C.Len loop - Connect (Get_Input (Inst, Port_Idx (I - 1)), C.Darr.Table (I)); + Connect (Get_Input (Inst, Port_Idx (C.Len - I)), + C.Darr.Table (I)); end loop; -- Free the vector. Net_Tables.Free (C.Darr); diff --git a/src/synth/synth-context.adb b/src/synth/synth-context.adb index a806c7591..93631120b 100644 --- a/src/synth/synth-context.adb +++ b/src/synth/synth-context.adb @@ -550,7 +550,7 @@ package body Synth.Context is C : Concat_Type; Res : Net; begin - for I in Val.Arr.V'Range loop + for I in reverse Val.Arr.V'Range loop Append (C, Get_Net (Val.Arr.V (I))); end loop; Build (Build_Context, C, Res); -- cgit v1.2.3