From 916c0a1e8e765a77863ca984bef1d7c0be77edc0 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Sun, 3 Nov 2019 21:13:43 +0100 Subject: netlists-builders: add build2_uresize. --- src/synth/netlists-builders.adb | 24 ++++++++++++++++++++++++ src/synth/netlists-builders.ads | 7 +++++++ 2 files changed, 31 insertions(+) (limited to 'src') diff --git a/src/synth/netlists-builders.adb b/src/synth/netlists-builders.adb index 0d88ec7ce..b1f9eb826 100644 --- a/src/synth/netlists-builders.adb +++ b/src/synth/netlists-builders.adb @@ -21,6 +21,7 @@ with Types_Utils; use Types_Utils; with Name_Table; use Name_Table; with Std_Names; use Std_Names; +with Netlists.Locations; package body Netlists.Builders is function Create_Input (Id : String; W : Width := 0) return Port_Desc is @@ -1075,6 +1076,29 @@ package body Netlists.Builders is return O; end Build_Extend; + function Build2_Uresize (Ctxt : Context_Acc; + I : Net; + W : Width; + Loc : Location_Type := No_Location) + return Net + is + Wn : constant Width := Get_Width (I); + Res : Net; + begin + if Wn = W then + return I; + else + if Wn > W then + Res := Build_Trunc (Ctxt, Id_Utrunc, I, W); + else + pragma Assert (Wn < W); + Res := Build_Extend (Ctxt, Id_Uextend, I, W); + end if; + Locations.Set_Location (Res, Loc); + return Res; + end if; + end Build2_Uresize; + function Build_Dyn_Insert (Ctxt : Context_Acc; I : Net; V : Net; P : Net; Off : Uns32) return Net is diff --git a/src/synth/netlists-builders.ads b/src/synth/netlists-builders.ads index 1b42b52ab..bff411e64 100644 --- a/src/synth/netlists-builders.ads +++ b/src/synth/netlists-builders.ads @@ -123,6 +123,13 @@ package Netlists.Builders is function Build_Extend (Ctxt : Context_Acc; Id : Module_Id; I : Net; W : Width) return Net; + -- Zero extend, noop or truncate I so that its width is W. + function Build2_Uresize (Ctxt : Context_Acc; + I : Net; + W : Width; + Loc : Location_Type := No_Location) + return Net; + function Build_Extract (Ctxt : Context_Acc; I : Net; Off, W : Width) return Net; -- cgit v1.2.3