aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth/netlists-cleanup.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-02-18 19:38:27 +0100
committerTristan Gingold <tgingold@free.fr>2020-02-18 19:38:27 +0100
commit922c301a8d6ecfd02950db5cde9f1dde4218455e (patch)
tree8be0c926d885ff7628cfdfda720dd415c254501c /src/synth/netlists-cleanup.adb
parentec2e697a0082f5c08621e9118917105472bce718 (diff)
downloadghdl-922c301a8d6ecfd02950db5cde9f1dde4218455e.tar.gz
ghdl-922c301a8d6ecfd02950db5cde9f1dde4218455e.tar.bz2
ghdl-922c301a8d6ecfd02950db5cde9f1dde4218455e.zip
netlists-cleanup: refactoring.
Diffstat (limited to 'src/synth/netlists-cleanup.adb')
-rw-r--r--src/synth/netlists-cleanup.adb29
1 files changed, 17 insertions, 12 deletions
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;