aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-07-20 19:37:51 +0200
committerTristan Gingold <tgingold@free.fr>2022-07-20 19:37:51 +0200
commit4b84d1fe0fd25ebf148218fa18971bdfd591f0c7 (patch)
treea8caa8929d047a7cf54ea6d24d8d11bc208064c3
parent76ce880bef54d80cfd5a55817b203616f50de823 (diff)
downloadghdl-4b84d1fe0fd25ebf148218fa18971bdfd591f0c7.tar.gz
ghdl-4b84d1fe0fd25ebf148218fa18971bdfd591f0c7.tar.bz2
ghdl-4b84d1fe0fd25ebf148218fa18971bdfd591f0c7.zip
elab-vhdl_context: add iterator for top-level packages
-rw-r--r--src/synth/elab-vhdl_context.adb22
-rw-r--r--src/synth/elab-vhdl_context.ads14
2 files changed, 36 insertions, 0 deletions
diff --git a/src/synth/elab-vhdl_context.adb b/src/synth/elab-vhdl_context.adb
index 95b9ddf29..048ac1ae4 100644
--- a/src/synth/elab-vhdl_context.adb
+++ b/src/synth/elab-vhdl_context.adb
@@ -602,4 +602,26 @@ package body Elab.Vhdl_Context is
begin
return Syn_Inst.Caller;
end Get_Caller_Instance;
+
+ procedure Iterate_Top_Level (It : in out Iterator_Top_Level_Type;
+ Res : out Synth_Instance_Acc)
+ is
+ Obj : Obj_Type;
+ begin
+ loop
+ if It.Next_Idx > Root_Instance.Max_Objs then
+ Res := null;
+ exit;
+ end if;
+
+ Obj := Root_Instance.Objects (It.Next_Idx);
+ It.Next_Idx := It.Next_Idx + 1;
+
+ if Obj.Kind = Obj_Instance then
+ Res := Obj.I_Inst;
+ return;
+ end if;
+ end loop;
+ end Iterate_Top_Level;
+
end Elab.Vhdl_Context;
diff --git a/src/synth/elab-vhdl_context.ads b/src/synth/elab-vhdl_context.ads
index 0bf2a4b50..404325742 100644
--- a/src/synth/elab-vhdl_context.ads
+++ b/src/synth/elab-vhdl_context.ads
@@ -178,6 +178,13 @@ package Elab.Vhdl_Context is
Caller : Synth_Instance_Acc);
function Get_Caller_Instance (Syn_Inst : Synth_Instance_Acc)
return Synth_Instance_Acc;
+
+ -- Iterator over top-level packages.
+ type Iterator_Top_Level_Type is private;
+ Iterator_Top_Level_Init : constant Iterator_Top_Level_Type;
+
+ procedure Iterate_Top_Level (It : in out Iterator_Top_Level_Type;
+ Res : out Synth_Instance_Acc);
private
type Destroy_Type is record
Inst : Synth_Instance_Acc;
@@ -252,4 +259,11 @@ private
-- Instance for synthesis.
Objects : Objects_Array (1 .. Max_Objs);
end record;
+
+ type Iterator_Top_Level_Type is record
+ Next_Idx : Object_Slot_Type;
+ end record;
+
+ Iterator_Top_Level_Init : constant Iterator_Top_Level_Type :=
+ (Next_Idx => 1);
end Elab.Vhdl_Context;