From 91a8e2335d1f1b3bf3232c60d84aec94fc8f85b9 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Wed, 6 May 2020 08:20:33 +0200 Subject: netlists-folds: add Build2_And, remove default location. --- src/synth/netlists-expands.adb | 2 +- src/synth/netlists-folds.adb | 24 ++++++++++++++++++------ src/synth/netlists-folds.ads | 16 ++++++++++------ 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/synth/netlists-expands.adb b/src/synth/netlists-expands.adb index fe7687014..6d79e8051 100644 --- a/src/synth/netlists-expands.adb +++ b/src/synth/netlists-expands.adb @@ -472,7 +472,7 @@ package body Netlists.Expands is Set_Location (Sh_S, Loc); R_Amt := Build_Dyadic (Ctxt, Id_Sub, Build_Const_UB32 (Ctxt, W_Val, W_Amt), - Build2_Uresize (Ctxt, Amt_N, W_Amt)); + Build2_Uresize (Ctxt, Amt_N, W_Amt, Loc)); Set_Location (R_Amt, Loc); Sh_C := Build_Shift_Rotate (Ctxt, Id_C, Val_N, R_Amt); Set_Location (Sh_C, Loc); diff --git a/src/synth/netlists-folds.adb b/src/synth/netlists-folds.adb index a46aef583..9aa070238 100644 --- a/src/synth/netlists-folds.adb +++ b/src/synth/netlists-folds.adb @@ -175,7 +175,7 @@ package body Netlists.Folds is function Build2_Uresize (Ctxt : Context_Acc; I : Net; W : Width; - Loc : Location_Type := No_Location) + Loc : Location_Type) return Net is Wn : constant Width := Get_Width (I); @@ -216,7 +216,7 @@ package body Netlists.Folds is function Build2_Sresize (Ctxt : Context_Acc; I : Net; W : Width; - Loc : Location_Type := No_Location) + Loc : Location_Type) return Net is Wn : constant Width := Get_Width (I); @@ -251,7 +251,7 @@ package body Netlists.Folds is I : Net; W : Width; Is_Signed : Boolean; - Loc : Location_Type := No_Location) + Loc : Location_Type) return Net is begin if Is_Signed then @@ -271,9 +271,7 @@ package body Netlists.Folds is end if; end Build2_Extract; - function Build2_Imp (Ctxt : Context_Acc; - A, B : Net; - Loc : Location_Type := No_Location) + function Build2_Imp (Ctxt : Context_Acc; A, B : Net; Loc : Location_Type) return Net is N : Net; @@ -284,4 +282,18 @@ package body Netlists.Folds is Set_Location (N, Loc); return N; end Build2_Imp; + + function Build2_And (Ctxt : Context_Acc; A, B : Net; Loc : Location_Type) + return Net + is + pragma Assert (B /= No_Net); + N : Net; + begin + if A = No_Net then + return B; + end if; + N := Build_Dyadic (Ctxt, Id_And, A, B); + Set_Location (N, Loc); + return N; + end Build2_And; end Netlists.Folds; diff --git a/src/synth/netlists-folds.ads b/src/synth/netlists-folds.ads index f00ded470..1aa020df9 100644 --- a/src/synth/netlists-folds.ads +++ b/src/synth/netlists-folds.ads @@ -48,14 +48,14 @@ package Netlists.Folds is function Build2_Uresize (Ctxt : Context_Acc; I : Net; W : Width; - Loc : Location_Type := No_Location) + Loc : Location_Type) return Net; -- Sign extend, noop or truncate I so that its width is W. function Build2_Sresize (Ctxt : Context_Acc; I : Net; W : Width; - Loc : Location_Type := No_Location) + Loc : Location_Type) return Net; -- If IS_SIGNED is true, this is Build2_Sresize, otherwise Build2_Uresize. @@ -63,7 +63,7 @@ package Netlists.Folds is I : Net; W : Width; Is_Signed : Boolean; - Loc : Location_Type := No_Location) + Loc : Location_Type) return Net; -- Same as Build_Extract, but return I iff extract all the bits. @@ -71,8 +71,12 @@ package Netlists.Folds is (Ctxt : Context_Acc; I : Net; Off, W : Width) return Net; -- Return A -> B == !A || B - function Build2_Imp (Ctxt : Context_Acc; - A, B : Net; - Loc : Location_Type := No_Location) + function Build2_Imp (Ctxt : Context_Acc; A, B : Net; Loc : Location_Type) + return Net; + + -- Return A & B. + -- If A is No_Net, simply return B so that it is possible to easily build + -- chain of conditions. + function Build2_And (Ctxt : Context_Acc; A, B : Net; Loc : Location_Type) return Net; end Netlists.Folds; -- cgit v1.2.3