diff options
author | Tristan Gingold <tgingold@free.fr> | 2022-07-20 19:37:51 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2022-07-20 19:37:51 +0200 |
commit | 4b84d1fe0fd25ebf148218fa18971bdfd591f0c7 (patch) | |
tree | a8caa8929d047a7cf54ea6d24d8d11bc208064c3 /src | |
parent | 76ce880bef54d80cfd5a55817b203616f50de823 (diff) | |
download | ghdl-4b84d1fe0fd25ebf148218fa18971bdfd591f0c7.tar.gz ghdl-4b84d1fe0fd25ebf148218fa18971bdfd591f0c7.tar.bz2 ghdl-4b84d1fe0fd25ebf148218fa18971bdfd591f0c7.zip |
elab-vhdl_context: add iterator for top-level packages
Diffstat (limited to 'src')
-rw-r--r-- | src/synth/elab-vhdl_context.adb | 22 | ||||
-rw-r--r-- | src/synth/elab-vhdl_context.ads | 14 |
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; |