aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth/netlists-cleanup.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-06-27 19:28:01 +0200
committerTristan Gingold <tgingold@free.fr>2022-06-27 19:37:33 +0200
commita036958a9adc31011729aab02af9eec48f80bc8a (patch)
tree2534000aaa570fde4d0359cf0c969f0d8a7a44cd /src/synth/netlists-cleanup.adb
parent060840d4176d7e5b775616e8a702bd751765c753 (diff)
downloadghdl-a036958a9adc31011729aab02af9eec48f80bc8a.tar.gz
ghdl-a036958a9adc31011729aab02af9eec48f80bc8a.tar.bz2
ghdl-a036958a9adc31011729aab02af9eec48f80bc8a.zip
synth: rework #2109 - remove null wires
Diffstat (limited to 'src/synth/netlists-cleanup.adb')
-rw-r--r--src/synth/netlists-cleanup.adb27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/synth/netlists-cleanup.adb b/src/synth/netlists-cleanup.adb
index c2fc603b4..52b3c87e0 100644
--- a/src/synth/netlists-cleanup.adb
+++ b/src/synth/netlists-cleanup.adb
@@ -385,4 +385,31 @@ package body Netlists.Cleanup is
end;
end Mark_And_Sweep;
+ procedure Replace_Null_Inputs (Ctxt : Context_Acc; M : Module)
+ is
+ Inst : Instance;
+ Drv : Net;
+ Inp : Input;
+ Null_X : Net;
+ begin
+ Null_X := No_Net;
+
+ Inst := Get_First_Instance (M);
+ while Inst /= No_Instance loop
+ for I in 1 .. Get_Nbr_Inputs (Inst) loop
+ Inp := Get_Input (Inst, I - 1);
+ Drv := Get_Driver (Inp);
+ if Drv /= No_Net and then Get_Width (Drv) = 0 then
+ if Null_X = No_Net then
+ Null_X := Build_Const_X (Ctxt, 0);
+ end if;
+ Disconnect (Inp);
+ Connect (Inp, Null_X);
+ end if;
+ end loop;
+
+ Inst := Get_Next_Instance (Inst);
+ end loop;
+ end Replace_Null_Inputs;
+
end Netlists.Cleanup;