aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2023-01-02 09:43:04 +0100
committerTristan Gingold <tgingold@free.fr>2023-01-02 09:43:04 +0100
commit49705e73b9907b2fe3ea1de8e9ad406892ceaf4b (patch)
treec061f8af59320aba6f0638182556f44791c59cfb /src
parentddf587a71472a8740b044c976b8f67c537ab0c06 (diff)
downloadghdl-49705e73b9907b2fe3ea1de8e9ad406892ceaf4b.tar.gz
ghdl-49705e73b9907b2fe3ea1de8e9ad406892ceaf4b.tar.bz2
ghdl-49705e73b9907b2fe3ea1de8e9ad406892ceaf4b.zip
synth: add support for nested packages
Diffstat (limited to 'src')
-rw-r--r--src/synth/synth-vhdl_decls.adb77
-rw-r--r--src/synth/synth-vhdl_decls.ads20
-rw-r--r--src/synth/synth-vhdl_insts.adb9
3 files changed, 87 insertions, 19 deletions
diff --git a/src/synth/synth-vhdl_decls.adb b/src/synth/synth-vhdl_decls.adb
index fd0e9b5f5..35ed61a86 100644
--- a/src/synth/synth-vhdl_decls.adb
+++ b/src/synth/synth-vhdl_decls.adb
@@ -331,7 +331,7 @@ package body Synth.Vhdl_Decls is
end loop;
end Synth_Concurrent_Attribute_Specification;
- procedure Synth_Package_Declaration
+ procedure Synth_Concurrent_Package_Declaration
(Parent_Inst : Synth_Instance_Acc; Pkg : Node)
is
Syn_Inst : Synth_Instance_Acc;
@@ -345,9 +345,9 @@ package body Synth.Vhdl_Decls is
Set_Extra (Syn_Inst, Parent_Inst, No_Sname);
Synth_Concurrent_Declarations (Syn_Inst, Get_Declaration_Chain (Pkg));
- end Synth_Package_Declaration;
+ end Synth_Concurrent_Package_Declaration;
- procedure Synth_Package_Body
+ procedure Synth_Concurrent_Package_Body
(Parent_Inst : Synth_Instance_Acc; Pkg : Node; Bod : Node)
is
Pkg_Inst : Synth_Instance_Acc;
@@ -360,9 +360,9 @@ package body Synth.Vhdl_Decls is
Pkg_Inst := Get_Package_Object (Parent_Inst, Pkg);
Synth_Concurrent_Declarations (Pkg_Inst, Get_Declaration_Chain (Bod));
- end Synth_Package_Body;
+ end Synth_Concurrent_Package_Body;
- procedure Synth_Package_Instantiation
+ procedure Synth_Concurrent_Package_Instantiation
(Parent_Inst : Synth_Instance_Acc; Pkg : Node)
is
Bod : constant Node := Get_Instance_Package_Body (Pkg);
@@ -390,7 +390,7 @@ package body Synth.Vhdl_Decls is
end if;
end;
end if;
- end Synth_Package_Instantiation;
+ end Synth_Concurrent_Package_Instantiation;
function Create_Protected_Object (Inst : Synth_Instance_Acc;
Decl : Node;
@@ -721,6 +721,37 @@ package body Synth.Vhdl_Decls is
| Iir_Kind_Group_Declaration =>
null;
+ when Iir_Kind_Package_Declaration =>
+ declare
+ Pkg_Inst : Synth_Instance_Acc;
+ begin
+ if Is_Uninstantiated_Package (Decl) then
+ -- Nothing to do (yet) for uninstantiated packages.
+ return;
+ end if;
+
+ Pkg_Inst := Create_Package_Instance (Syn_Inst, Decl);
+
+ Synth_Declarations
+ (Pkg_Inst, Get_Declaration_Chain (Decl), Is_Subprg);
+ end;
+
+ when Iir_Kind_Package_Body =>
+ declare
+ Spec : constant Node := Get_Package (Decl);
+ Pkg_Inst : Synth_Instance_Acc;
+ begin
+ if Is_Uninstantiated_Package (Spec) then
+ -- Nothing to do (yet) for uninstantiated packages.
+ return;
+ end if;
+
+ Pkg_Inst := Get_Package_Object (Syn_Inst, Spec);
+
+ Synth_Declarations
+ (Pkg_Inst, Get_Declaration_Chain (Decl), Is_Subprg);
+ end;
+
when Iir_Kind_Suspend_State_Declaration =>
declare
Val : Valtyp;
@@ -873,6 +904,38 @@ package body Synth.Vhdl_Decls is
when Iir_Kind_Attribute_Implicit_Declaration =>
-- Not supported by synthesis.
null;
+
+ when Iir_Kind_Package_Declaration =>
+ declare
+ Pkg_Inst : Synth_Instance_Acc;
+ begin
+ if Is_Uninstantiated_Package (Decl) then
+ -- Nothing to do (yet) for uninstantiated packages.
+ return;
+ end if;
+
+ Pkg_Inst := Get_Package_Object (Syn_Inst, Decl);
+
+ Finalize_Declarations
+ (Pkg_Inst, Get_Declaration_Chain (Decl), Is_Subprg);
+ end;
+
+ when Iir_Kind_Package_Body =>
+ declare
+ Spec : constant Node := Get_Package (Decl);
+ Pkg_Inst : Synth_Instance_Acc;
+ begin
+ if Is_Uninstantiated_Package (Spec) then
+ -- Nothing to do (yet) for uninstantiated packages.
+ return;
+ end if;
+
+ Pkg_Inst := Get_Package_Object (Syn_Inst, Spec);
+
+ Finalize_Declarations
+ (Pkg_Inst, Get_Declaration_Chain (Decl), Is_Subprg);
+ end;
+
when Iir_Kind_Package_Instantiation_Declaration =>
-- TODO: also finalize ?
null;
@@ -930,7 +993,7 @@ package body Synth.Vhdl_Decls is
when Iir_Kind_Attribute_Specification =>
Synth_Concurrent_Attribute_Specification (Syn_Inst, Decl);
when Iir_Kind_Package_Instantiation_Declaration =>
- Synth_Package_Instantiation (Syn_Inst, Decl);
+ Synth_Concurrent_Package_Instantiation (Syn_Inst, Decl);
when Iir_Kind_Attribute_Implicit_Declaration =>
-- Error will be printed when the attribute is used.
null;
diff --git a/src/synth/synth-vhdl_decls.ads b/src/synth/synth-vhdl_decls.ads
index 4f099ff88..06cc9f4c9 100644
--- a/src/synth/synth-vhdl_decls.ads
+++ b/src/synth/synth-vhdl_decls.ads
@@ -48,11 +48,6 @@ package Synth.Vhdl_Decls is
Decls : Node;
Is_Subprg : Boolean := False);
- procedure Synth_Concurrent_Declaration (Syn_Inst : Synth_Instance_Acc;
- Decl : Node);
- procedure Synth_Concurrent_Declarations (Syn_Inst : Synth_Instance_Acc;
- Decls : Node);
-
procedure Finalize_Declaration (Syn_Inst : Synth_Instance_Acc;
Decl : Node;
Is_Subprg : Boolean);
@@ -64,11 +59,18 @@ package Synth.Vhdl_Decls is
Decl : Node;
Typ : Type_Acc) return Valtyp;
- procedure Synth_Package_Declaration
+ -- For declarations in architectural statements (top-level, entities,
+ -- architecture, blocks...)
+
+ procedure Synth_Concurrent_Declaration (Syn_Inst : Synth_Instance_Acc;
+ Decl : Node);
+ procedure Synth_Concurrent_Declarations (Syn_Inst : Synth_Instance_Acc;
+ Decls : Node);
+
+ procedure Synth_Concurrent_Package_Declaration
(Parent_Inst : Synth_Instance_Acc; Pkg : Node);
- procedure Synth_Package_Body
+ procedure Synth_Concurrent_Package_Body
(Parent_Inst : Synth_Instance_Acc; Pkg : Node; Bod : Node);
-
- procedure Synth_Package_Instantiation
+ procedure Synth_Concurrent_Package_Instantiation
(Parent_Inst : Synth_Instance_Acc; Pkg : Node);
end Synth.Vhdl_Decls;
diff --git a/src/synth/synth-vhdl_insts.adb b/src/synth/synth-vhdl_insts.adb
index 88f023354..dbecfe0ab 100644
--- a/src/synth/synth-vhdl_insts.adb
+++ b/src/synth/synth-vhdl_insts.adb
@@ -1334,7 +1334,8 @@ package body Synth.Vhdl_Insts is
Bod : constant Node := Get_Package_Body (Dep_Unit);
Bod_Unit : Node;
begin
- Synth_Package_Declaration (Parent_Inst, Dep_Unit);
+ Synth_Concurrent_Package_Declaration
+ (Parent_Inst, Dep_Unit);
-- Do not try to elaborate math_real body: there are
-- functions with loop. Currently, try create signals,
-- which is not possible during package elaboration.
@@ -1343,11 +1344,13 @@ package body Synth.Vhdl_Insts is
then
Bod_Unit := Get_Design_Unit (Bod);
Synth_Dependencies (Parent_Inst, Bod_Unit);
- Synth_Package_Body (Parent_Inst, Dep_Unit, Bod);
+ Synth_Concurrent_Package_Body
+ (Parent_Inst, Dep_Unit, Bod);
end if;
end;
when Iir_Kind_Package_Instantiation_Declaration =>
- Synth_Package_Instantiation (Parent_Inst, Dep_Unit);
+ Synth_Concurrent_Package_Instantiation
+ (Parent_Inst, Dep_Unit);
when Iir_Kind_Package_Body =>
null;
when Iir_Kind_Architecture_Body =>