From 922c301a8d6ecfd02950db5cde9f1dde4218455e Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Tue, 18 Feb 2020 19:38:27 +0100 Subject: netlists-cleanup: refactoring. --- src/synth/netlists-cleanup.adb | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'src/synth/netlists-cleanup.adb') diff --git a/src/synth/netlists-cleanup.adb b/src/synth/netlists-cleanup.adb index 0a4fb3dc1..d95267c88 100644 --- a/src/synth/netlists-cleanup.adb +++ b/src/synth/netlists-cleanup.adb @@ -119,8 +119,6 @@ package body Netlists.Cleanup is use Netlists.Gates; Inst : Instance; Next_Inst : Instance; - Inp : Input; - O : Net; begin Inst := Get_First_Instance (M); while Inst /= No_Instance loop @@ -129,16 +127,23 @@ package body Netlists.Cleanup is case Get_Id (Inst) is when Id_Output | Id_Port => - Inp := Get_Input (Inst, 0); - O := Get_Driver (Inp); - if O /= No_Net then - -- Only when the output is driven. - Disconnect (Inp); - Redirect_Inputs (Get_Output (Inst, 0), O); - else - Disconnect (Get_First_Sink (Get_Output (Inst, 0))); - end if; - Remove_Instance (Inst); + declare + Inp : Input; + In_Drv : Net; + O : Net; + begin + Inp := Get_Input (Inst, 0); + In_Drv := Get_Driver (Inp); + O := Get_Output (Inst, 0); + if In_Drv /= No_Net then + -- Only when the output is driven. + Disconnect (Inp); + Redirect_Inputs (O, In_Drv); + else + Disconnect (Get_First_Sink (O)); + end if; + Remove_Instance (Inst); + end; when others => null; end case; -- cgit v1.2.3