aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth/netlists-folds.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-08-06 07:54:40 +0200
committerTristan Gingold <tgingold@free.fr>2020-08-06 07:54:40 +0200
commit959f80c052665d07a28e1b1b20e89d6e12d0ced4 (patch)
tree88eefde6ca7df8c1bb49f289af391d5e113f79ce /src/synth/netlists-folds.adb
parenta0d2fd3cab9360d58cf24474f85c73ca3fd31bdc (diff)
downloadghdl-959f80c052665d07a28e1b1b20e89d6e12d0ced4.tar.gz
ghdl-959f80c052665d07a28e1b1b20e89d6e12d0ced4.tar.bz2
ghdl-959f80c052665d07a28e1b1b20e89d6e12d0ced4.zip
synth: push extract on mux2 for inference. For #1421
Diffstat (limited to 'src/synth/netlists-folds.adb')
-rw-r--r--src/synth/netlists-folds.adb28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/synth/netlists-folds.adb b/src/synth/netlists-folds.adb
index c4138d0cd..411415901 100644
--- a/src/synth/netlists-folds.adb
+++ b/src/synth/netlists-folds.adb
@@ -270,6 +270,34 @@ package body Netlists.Folds is
end if;
end Build2_Extract;
+ function Build2_Extract_Push
+ (Ctxt : Context_Acc; I : Net; Off, W : Width) return Net
+ is
+ Inst : constant Instance := Get_Net_Parent (I);
+ Res : Net;
+ begin
+ if Off = 0 and then W = Get_Width (I) then
+ return I;
+ end if;
+
+ case Get_Id (Inst) is
+ when Id_Extract =>
+ return Build2_Extract_Push
+ (Ctxt, Get_Input_Net (Inst, 0),
+ Off + Get_Param_Uns32 (Inst, 0), W);
+ when Id_Mux2 =>
+ Res := Build_Mux2
+ (Ctxt,
+ Get_Input_Net (Inst, 0),
+ Build2_Extract_Push (Ctxt, Get_Input_Net (Inst, 1), Off, W),
+ Build2_Extract_Push (Ctxt, Get_Input_Net (Inst, 2), Off, W));
+ Set_Location (Res, Get_Location (Inst));
+ return Res;
+ when others =>
+ return Build_Extract (Ctxt, I, Off, W);
+ end case;
+ end Build2_Extract_Push;
+
function Build2_Imp (Ctxt : Context_Acc; A, B : Net; Loc : Location_Type)
return Net
is