aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth/netlists-cleanup.adb
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/synth/netlists-cleanup.adb
parent2ce7d7b7b5d282ab74e46151c6243344ea587005 (diff)
downloadghdl-c9af9906de38d83633ed40b3b0328e116c7bdfb8.tar.gz
ghdl-c9af9906de38d83633ed40b3b0328e116c7bdfb8.tar.bz2
ghdl-c9af9906de38d83633ed40b3b0328e116c7bdfb8.zip
netlists: add remove_output_gates.
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 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;