aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth/netlists.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-10-10 18:29:07 +0200
committerTristan Gingold <tgingold@free.fr>2019-10-10 18:29:07 +0200
commitbb55e3201f211ed7176993cbf1622ad4592f95e0 (patch)
tree2f2f2e75d58f6ebd7b5ad8bd021dc7bc59918791 /src/synth/netlists.adb
parent5d43f82f6afe21cc874309e280e31a4f51439502 (diff)
downloadghdl-bb55e3201f211ed7176993cbf1622ad4592f95e0.tar.gz
ghdl-bb55e3201f211ed7176993cbf1622ad4592f95e0.tar.bz2
ghdl-bb55e3201f211ed7176993cbf1622ad4592f95e0.zip
synth: rewrite cleanup pass.
Diffstat (limited to 'src/synth/netlists.adb')
-rw-r--r--src/synth/netlists.adb40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/synth/netlists.adb b/src/synth/netlists.adb
index 6597be8ed..b152dccd5 100644
--- a/src/synth/netlists.adb
+++ b/src/synth/netlists.adb
@@ -322,9 +322,35 @@ package body Netlists is
else
Instances_Table.Table (M_Ent.Last_Instance).Next_Instance := Inst;
end if;
+ Instances_Table.Table (Inst).Prev_Instance := M_Ent.Last_Instance;
M_Ent.Last_Instance := Inst;
end Append_Instance;
+ procedure Extract_Instance (Inst : Instance)
+ is
+ pragma Assert (Is_Valid (Inst));
+ Inst_Ent : Instance_Record renames Instances_Table.Table (Inst);
+ M : constant Module := Inst_Ent.Parent;
+ M_Ent : Module_Record renames Modules_Table.Table (M);
+ begin
+ if Inst_Ent.Prev_Instance /= No_Instance then
+ Set_Next_Instance (Inst_Ent.Prev_Instance, Inst_Ent.Next_Instance);
+ else
+ pragma Assert (M_Ent.First_Instance = Inst);
+ M_Ent.First_Instance := Inst_Ent.Next_Instance;
+ end if;
+
+ if Inst_Ent.Next_Instance /= No_Instance then
+ Set_Prev_Instance (Inst_Ent.Next_Instance, Inst_Ent.Prev_Instance);
+ else
+ pragma Assert (M_Ent.Last_Instance = Inst);
+ M_Ent.Last_Instance := Inst_Ent.Prev_Instance;
+ end if;
+
+ Inst_Ent.Prev_Instance := No_Instance;
+ Inst_Ent.Next_Instance := No_Instance;
+ end Extract_Instance;
+
function New_Instance_Internal (Parent : Module;
M : Module;
Name : Sname;
@@ -343,6 +369,7 @@ package body Netlists is
begin
Instances_Table.Append ((Parent => Parent,
Next_Instance => No_Instance,
+ Prev_Instance => No_Instance,
Klass => M,
Name => Name,
First_Param => Params,
@@ -491,6 +518,18 @@ package body Netlists is
return Instances_Table.Table (Inst).Next_Instance;
end Get_Next_Instance;
+ procedure Set_Next_Instance (Inst : Instance; Next : Instance) is
+ begin
+ pragma Assert (Is_Valid (Inst));
+ Instances_Table.Table (Inst).Next_Instance := Next;
+ end Set_Next_Instance;
+
+ procedure Set_Prev_Instance (Inst : Instance; Prev : Instance) is
+ begin
+ pragma Assert (Is_Valid (Inst));
+ Instances_Table.Table (Inst).Prev_Instance := Prev;
+ end Set_Prev_Instance;
+
function Get_First_Output (Inst : Instance) return Net is
begin
pragma Assert (Is_Valid (Inst));
@@ -831,6 +870,7 @@ begin
Instances_Table.Append ((Parent => No_Module,
Next_Instance => No_Instance,
+ Prev_Instance => No_Instance,
Klass => No_Module,
Name => No_Sname,
First_Param => No_Param_Idx,