aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-12-05 22:30:24 +0100
committerTristan Gingold <tgingold@free.fr>2019-12-05 22:30:24 +0100
commitc9af9906de38d83633ed40b3b0328e116c7bdfb8 (patch)
tree660fdc6fc0f5aa051dd1519d614f66e0c3abffe3 /src
parent2ce7d7b7b5d282ab74e46151c6243344ea587005 (diff)
downloadghdl-c9af9906de38d83633ed40b3b0328e116c7bdfb8.tar.gz
ghdl-c9af9906de38d83633ed40b3b0328e116c7bdfb8.tar.bz2
ghdl-c9af9906de38d83633ed40b3b0328e116c7bdfb8.zip
netlists: add remove_output_gates.
Diffstat (limited to 'src')
-rw-r--r--src/synth/netlists-cleanup.adb27
-rw-r--r--src/synth/netlists-cleanup.ads3
-rw-r--r--src/synth/synth-insts.adb1
3 files changed, 31 insertions, 0 deletions
diff --git a/src/synth/netlists-cleanup.adb b/src/synth/netlists-cleanup.adb
index 54cb6300e..4d2cc40a9 100644
--- a/src/synth/netlists-cleanup.adb
+++ b/src/synth/netlists-cleanup.adb
@@ -19,6 +19,7 @@
-- MA 02110-1301, USA.
with Netlists.Utils; use Netlists.Utils;
+with Netlists.Gates;
package body Netlists.Cleanup is
-- Return False iff INST has no outputs (and INST is not Id_Free).
@@ -112,4 +113,30 @@ package body Netlists.Cleanup is
Free_Instance (Inst);
end loop;
end Remove_Unconnected_Instances;
+
+ procedure Remove_Output_Gates (M : Module)
+ is
+ use Netlists.Gates;
+ Inst : Instance;
+ Next_Inst : Instance;
+ Inp : Input;
+ O : Net;
+ begin
+ Inst := Get_First_Instance (M);
+ while Inst /= No_Instance loop
+ Next_Inst := Get_Next_Instance (Inst);
+
+ if Get_Id (Inst) = Id_Output then
+ Inp := Get_Input (Inst, 0);
+ O := Get_Driver (Inp);
+ Disconnect (Inp);
+
+ Redirect_Inputs (Get_Output (Inst, 0), O);
+ Remove_Instance (Inst);
+ end if;
+
+ Inst := Next_Inst;
+ end loop;
+ end Remove_Output_Gates;
+
end Netlists.Cleanup;
diff --git a/src/synth/netlists-cleanup.ads b/src/synth/netlists-cleanup.ads
index 7f373130d..c4c82addf 100644
--- a/src/synth/netlists-cleanup.ads
+++ b/src/synth/netlists-cleanup.ads
@@ -23,4 +23,7 @@ package Netlists.Cleanup is
-- Their inputs will be deconnected, which can result in new instances
-- that are also removed.
procedure Remove_Unconnected_Instances (M : Module);
+
+ -- Remove Id_Output gates.
+ procedure Remove_Output_Gates (M : Module);
end Netlists.Cleanup;
diff --git a/src/synth/synth-insts.adb b/src/synth/synth-insts.adb
index 8ff6d1d26..ef11a4ccf 100644
--- a/src/synth/synth-insts.adb
+++ b/src/synth/synth-insts.adb
@@ -1326,6 +1326,7 @@ package body Synth.Insts is
-- the one created for 'rising_egde (clk) and not rst'.
if not Synth.Flags.Flag_Debug_Nocleanup then
Netlists.Cleanup.Remove_Unconnected_Instances (Inst.M);
+ Netlists.Cleanup.Remove_Output_Gates (Inst.M);
end if;
if not Synth.Flags.Flag_Debug_Nomemory then