diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-11-05 19:03:08 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-11-05 19:03:08 +0100 |
commit | 103e373e194fa782770cae50573f924b78b0bdf2 (patch) | |
tree | 08136be7ca856569fe5b739037dbc1e7f7de3c1f /src/synth/netlists-folds.adb | |
parent | 448fc4b63b3ffcb8d64b2ef1ff52ae2f800ea494 (diff) | |
download | ghdl-103e373e194fa782770cae50573f924b78b0bdf2.tar.gz ghdl-103e373e194fa782770cae50573f924b78b0bdf2.tar.bz2 ghdl-103e373e194fa782770cae50573f924b78b0bdf2.zip |
netlists: add build2_sresize, simplify code.
Diffstat (limited to 'src/synth/netlists-folds.adb')
-rw-r--r-- | src/synth/netlists-folds.adb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/synth/netlists-folds.adb b/src/synth/netlists-folds.adb index a360c2a49..fd35ed8ed 100644 --- a/src/synth/netlists-folds.adb +++ b/src/synth/netlists-folds.adb @@ -147,6 +147,29 @@ package body Netlists.Folds is end if; end Build2_Uresize; + function Build2_Sresize (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_Strunc, I, W); + else + pragma Assert (Wn < W); + Res := Build_Extend (Ctxt, Id_Sextend, I, W); + end if; + Locations.Set_Location (Res, Loc); + return Res; + end if; + end Build2_Sresize; + function Build2_Extract (Ctxt : Context_Acc; I : Net; Off, W : Width) return Net is begin |