aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-11-03 21:13:43 +0100
committerTristan Gingold <tgingold@free.fr>2019-11-03 21:15:09 +0100
commit916c0a1e8e765a77863ca984bef1d7c0be77edc0 (patch)
tree759fa885d49b0a021b5c7c0d30ada17d0620d31b /src
parent63f06845f2ba7aa339a235aaf98b6e089fe5901f (diff)
downloadghdl-916c0a1e8e765a77863ca984bef1d7c0be77edc0.tar.gz
ghdl-916c0a1e8e765a77863ca984bef1d7c0be77edc0.tar.bz2
ghdl-916c0a1e8e765a77863ca984bef1d7c0be77edc0.zip
netlists-builders: add build2_uresize.
Diffstat (limited to 'src')
-rw-r--r--src/synth/netlists-builders.adb24
-rw-r--r--src/synth/netlists-builders.ads7
2 files changed, 31 insertions, 0 deletions
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;