diff options
author | Tristan Gingold <tgingold@free.fr> | 2021-08-28 10:20:34 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2021-08-28 13:22:31 +0200 |
commit | d17ac5c5afdef5007cf9c805bfd510a97fc3e752 (patch) | |
tree | c816162cb12e6b688d1023772ee4cd1ed687d453 /src | |
parent | 3c8db435b536117eeceb65693e2493033a3d664b (diff) | |
download | ghdl-d17ac5c5afdef5007cf9c805bfd510a97fc3e752.tar.gz ghdl-d17ac5c5afdef5007cf9c805bfd510a97fc3e752.tar.bz2 ghdl-d17ac5c5afdef5007cf9c805bfd510a97fc3e752.zip |
synth: add build2_concat2 and use it for vhdl concat.
Diffstat (limited to 'src')
-rw-r--r-- | src/synth/netlists-folds.adb | 11 | ||||
-rw-r--r-- | src/synth/netlists-folds.ads | 3 | ||||
-rw-r--r-- | src/synth/synth-vhdl_oper.adb | 8 |
3 files changed, 18 insertions, 4 deletions
diff --git a/src/synth/netlists-folds.adb b/src/synth/netlists-folds.adb index c3fc3d022..e1477870b 100644 --- a/src/synth/netlists-folds.adb +++ b/src/synth/netlists-folds.adb @@ -86,6 +86,17 @@ package body Netlists.Folds is end if; end Build2_Const_Int; + function Build2_Concat2 (Ctxt : Context_Acc; L, R : Net) return Net is + begin + if Get_Width (L) = 0 then + return R; + elsif Get_Width (R) = 0 then + return L; + else + return Build_Concat2 (Ctxt, L, R); + end if; + end Build2_Concat2; + function Build2_Concat (Ctxt : Context_Acc; Els : Net_Array) return Net is F : constant Int32 := Els'First; diff --git a/src/synth/netlists-folds.ads b/src/synth/netlists-folds.ads index c0590d73b..899a2163f 100644 --- a/src/synth/netlists-folds.ads +++ b/src/synth/netlists-folds.ads @@ -39,6 +39,9 @@ package Netlists.Folds is -- ELS(L) will be at offset 0. function Build2_Concat (Ctxt : Context_Acc; Els : Net_Array) return Net; + -- If L or R has a null width, return the other. + function Build2_Concat2 (Ctxt : Context_Acc; L, R : Net) return Net; + -- Truncate I to width W. Merge if the input is an extend. function Build2_Trunc (Ctxt : Context_Acc; Id : Module_Id; diff --git a/src/synth/synth-vhdl_oper.adb b/src/synth/synth-vhdl_oper.adb index fadd500b5..69213e9f9 100644 --- a/src/synth/synth-vhdl_oper.adb +++ b/src/synth/synth-vhdl_oper.adb @@ -975,7 +975,7 @@ package body Synth.Vhdl_Oper is Bnd : Bound_Type; N : Net; begin - N := Build_Concat2 (Ctxt, L, Get_Net (Ctxt, Right)); + N := Build2_Concat2 (Ctxt, L, Get_Net (Ctxt, Right)); Set_Location (N, Expr); Bnd := Create_Bounds_From_Length (Syn_Inst, @@ -991,7 +991,7 @@ package body Synth.Vhdl_Oper is Bnd : Bound_Type; N : Net; begin - N := Build_Concat2 (Ctxt, Get_Net (Ctxt, Left), R); + N := Build2_Concat2 (Ctxt, Get_Net (Ctxt, Left), R); Set_Location (N, Expr); Bnd := Create_Bounds_From_Length (Syn_Inst, @@ -1006,7 +1006,7 @@ package body Synth.Vhdl_Oper is N : Net; Bnd : Bound_Type; begin - N := Build_Concat2 + N := Build2_Concat2 (Ctxt, Get_Net (Ctxt, Left), Get_Net (Ctxt, Right)); Set_Location (N, Expr); Bnd := Create_Bounds_From_Length @@ -1021,7 +1021,7 @@ package body Synth.Vhdl_Oper is Bnd : Bound_Type; N : Net; begin - N := Build_Concat2 (Ctxt, L, R); + N := Build2_Concat2 (Ctxt, L, R); Set_Location (N, Expr); Bnd := Create_Bounds_From_Length (Syn_Inst, |