aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vhdl/translate/trans-chap1.adb129
-rw-r--r--src/vhdl/translate/trans-chap12.adb47
-rw-r--r--src/vhdl/translate/trans-chap9.adb217
-rw-r--r--src/vhdl/translate/trans-chap9.ads3
-rw-r--r--src/vhdl/translate/trans.adb10
-rw-r--r--src/vhdl/translate/trans.ads9
6 files changed, 319 insertions, 96 deletions
diff --git a/src/vhdl/translate/trans-chap1.adb b/src/vhdl/translate/trans-chap1.adb
index a7c598c01..ff72300ef 100644
--- a/src/vhdl/translate/trans-chap1.adb
+++ b/src/vhdl/translate/trans-chap1.adb
@@ -104,7 +104,9 @@ package body Trans.Chap1 is
is
Info : Block_Info_Acc;
Interface_List : O_Inter_List;
- Instance : Subprgs.Subprg_Instance_Type;
+ type Subprg_Instance_Array is
+ array (Elab_Kind) of Subprgs.Subprg_Instance_Type;
+ Instance : Subprg_Instance_Array;
Prev_Subprg_Instance : Subprgs.Subprg_Instance_Stack;
begin
Info := Add_Info (Entity, Kind_Block);
@@ -129,10 +131,12 @@ package body Trans.Chap1 is
Prev_Subprg_Instance);
-- Entity elaborator.
- Start_Procedure_Decl (Interface_List, Create_Identifier ("ELAB"),
- Global_Storage);
- Subprgs.Add_Subprg_Instance_Interfaces (Interface_List, Instance);
- Finish_Subprogram_Decl (Interface_List, Info.Block_Elab_Subprg);
+ for K in Elab_Kind loop
+ Start_Procedure_Decl
+ (Interface_List, Create_Elab_Identifier (K), Global_Storage);
+ Subprgs.Add_Subprg_Instance_Interfaces (Interface_List, Instance (K));
+ Finish_Subprogram_Decl (Interface_List, Info.Block_Elab_Subprg (K));
+ end loop;
-- Entity dependences elaborator.
Start_Procedure_Decl (Interface_List, Create_Identifier ("PKG_ELAB"),
@@ -160,15 +164,22 @@ package body Trans.Chap1 is
Finish_Subprogram_Body;
-- Elaborator Body.
- Start_Subprogram_Body (Info.Block_Elab_Subprg);
- Push_Local_Factory;
- Subprgs.Start_Subprg_Instance_Use (Instance);
- New_Debug_Line_Stmt (Get_Line_Number (Entity));
-
- Chap9.Elab_Block_Declarations (Entity, Entity);
- Subprgs.Finish_Subprg_Instance_Use (Instance);
- Pop_Local_Factory;
- Finish_Subprogram_Body;
+ for K in Elab_Kind loop
+ Start_Subprogram_Body (Info.Block_Elab_Subprg (K));
+ Push_Local_Factory;
+ Subprgs.Start_Subprg_Instance_Use (Instance (K));
+ New_Debug_Line_Stmt (Get_Line_Number (Entity));
+
+ case K is
+ when Elab_Decls =>
+ Chap9.Elab_Block_Declarations (Entity, Entity);
+ when Elab_Stmts =>
+ Chap9.Elab_Block_Statements (Entity, Entity);
+ end case;
+ Subprgs.Finish_Subprg_Instance_Use (Instance (K));
+ Pop_Local_Factory;
+ Finish_Subprogram_Body;
+ end loop;
end if;
Subprgs.Pop_Subprg_Instance (Wki_Instance, Prev_Subprg_Instance);
end Translate_Entity_Declaration;
@@ -205,7 +216,7 @@ package body Trans.Chap1 is
Info : Block_Info_Acc;
Interface_List : O_Inter_List;
Constr : O_Assoc_List;
- Instance : O_Dnode;
+ Instance : O_Dnode_Elab;
Var_Arch_Instance : O_Dnode;
Prev_Subprg_Instance : Subprgs.Subprg_Instance_Stack;
begin
@@ -238,12 +249,14 @@ package body Trans.Chap1 is
end if;
-- Elaborator.
- Start_Procedure_Decl
- (Interface_List, Create_Identifier ("ELAB"), Global_Storage);
- New_Interface_Decl
- (Interface_List, Instance, Wki_Instance,
- Entity_Info.Block_Decls_Ptr_Type);
- Finish_Subprogram_Decl (Interface_List, Info.Block_Elab_Subprg);
+ for K in Elab_Kind loop
+ Start_Procedure_Decl
+ (Interface_List, Create_Elab_Identifier (K), Global_Storage);
+ New_Interface_Decl
+ (Interface_List, Instance (K), Wki_Instance,
+ Entity_Info.Block_Decls_Ptr_Type);
+ Finish_Subprogram_Decl (Interface_List, Info.Block_Elab_Subprg (K));
+ end loop;
-- Generate RTI.
if Flag_Rti then
@@ -269,45 +282,57 @@ package body Trans.Chap1 is
Subprgs.Pop_Subprg_Instance (Wki_Instance, Prev_Subprg_Instance);
-- Elaborator body.
- Start_Subprogram_Body (Info.Block_Elab_Subprg);
- Push_Local_Factory;
-
- -- Create a variable for the architecture instance (with the right
- -- type, instead of the entity instance type).
- New_Var_Decl (Var_Arch_Instance, Wki_Arch_Instance,
- O_Storage_Local, Info.Block_Decls_Ptr_Type);
- New_Assign_Stmt
- (New_Obj (Var_Arch_Instance),
- New_Convert_Ov (New_Value (New_Obj (Instance)),
- Info.Block_Decls_Ptr_Type));
+ for K in Elab_Kind loop
+ Start_Subprogram_Body (Info.Block_Elab_Subprg (K));
+ Push_Local_Factory;
- -- Set RTI.
- if Flag_Rti then
+ -- Create a variable for the architecture instance (with the right
+ -- type, instead of the entity instance type).
+ New_Var_Decl (Var_Arch_Instance, Wki_Arch_Instance,
+ O_Storage_Local, Info.Block_Decls_Ptr_Type);
New_Assign_Stmt
- (New_Selected_Element
- (New_Selected_Acc_Value (New_Obj (Instance),
- Entity_Info.Block_Link_Field),
- Rtis.Ghdl_Entity_Link_Rti),
- New_Unchecked_Address (New_Obj (Info.Block_Rti_Const),
- Rtis.Ghdl_Rti_Access));
- end if;
+ (New_Obj (Var_Arch_Instance),
+ New_Convert_Ov (New_Value (New_Obj (Instance (K))),
+ Info.Block_Decls_Ptr_Type));
+
+ case K is
+ when Elab_Decls =>
+ -- Set RTI.
+ if Flag_Rti then
+ New_Assign_Stmt
+ (New_Selected_Element
+ (New_Selected_Acc_Value (New_Obj (Instance (K)),
+ Entity_Info.Block_Link_Field),
+ Rtis.Ghdl_Entity_Link_Rti),
+ New_Unchecked_Address (New_Obj (Info.Block_Rti_Const),
+ Rtis.Ghdl_Rti_Access));
+ end if;
+ when Elab_Stmts =>
+ null;
+ end case;
- -- Call entity elaborators.
- Start_Association (Constr, Entity_Info.Block_Elab_Subprg);
- New_Association (Constr, New_Value (New_Obj (Instance)));
- New_Procedure_Call (Constr);
+ -- Call entity elaborators.
+ Start_Association (Constr, Entity_Info.Block_Elab_Subprg (K));
+ New_Association (Constr, New_Value (New_Obj (Instance (K))));
+ New_Procedure_Call (Constr);
- Push_Architecture_Scope (Arch, Var_Arch_Instance);
+ Push_Architecture_Scope (Arch, Var_Arch_Instance);
- New_Debug_Line_Stmt (Get_Line_Number (Arch));
- Chap2.Elab_Dependence (Get_Design_Unit (Arch));
+ New_Debug_Line_Stmt (Get_Line_Number (Arch));
- Chap9.Elab_Block_Declarations (Arch, Arch);
+ case K is
+ when Elab_Decls =>
+ Chap2.Elab_Dependence (Get_Design_Unit (Arch));
+ Chap9.Elab_Block_Declarations (Arch, Arch);
+ when Elab_Stmts =>
+ Chap9.Elab_Block_Statements (Arch, Arch);
+ end case;
- Pop_Architecture_Scope (Arch);
+ Pop_Architecture_Scope (Arch);
- Pop_Local_Factory;
- Finish_Subprogram_Body;
+ Pop_Local_Factory;
+ Finish_Subprogram_Body;
+ end loop;
end Translate_Architecture_Body;
procedure Translate_Component_Configuration_Decl
diff --git a/src/vhdl/translate/trans-chap12.adb b/src/vhdl/translate/trans-chap12.adb
index 185a01e8f..779ad97ab 100644
--- a/src/vhdl/translate/trans-chap12.adb
+++ b/src/vhdl/translate/trans-chap12.adb
@@ -139,9 +139,11 @@ package body Trans.Chap12 is
Chap1.Translate_Entity_Init_Ports (Entity);
-- Elab instance.
- Start_Association (Assoc, Arch_Info.Block_Elab_Subprg);
- New_Association (Assoc, New_Obj_Value (Instance));
- New_Procedure_Call (Assoc);
+ for K in Elab_Kind loop
+ Start_Association (Assoc, Arch_Info.Block_Elab_Subprg (K));
+ New_Association (Assoc, New_Obj_Value (Instance));
+ New_Procedure_Call (Assoc);
+ end loop;
-- Configure instance.
Start_Association (Assoc, Config_Subprg);
@@ -211,18 +213,20 @@ package body Trans.Chap12 is
Finish_Init_Value (Const, Get_Scope_Size (Arch_Info.Block_Scope));
-- Elaborator.
- Start_Procedure_Decl
- (Inter_List, Create_Identifier ("ELAB"), O_Storage_Public);
- New_Interface_Decl
- (Inter_List, Instance, Wki_Instance,
- Entity_Info.Block_Decls_Ptr_Type);
- Finish_Subprogram_Decl (Inter_List, Subprg);
+ for K in Elab_Kind loop
+ Start_Procedure_Decl
+ (Inter_List, Create_Elab_Identifier (K), O_Storage_Public);
+ New_Interface_Decl
+ (Inter_List, Instance, Wki_Instance,
+ Entity_Info.Block_Decls_Ptr_Type);
+ Finish_Subprogram_Decl (Inter_List, Subprg);
- Start_Subprogram_Body (Subprg);
- Start_Association (Constr, Arch_Info.Block_Elab_Subprg);
- New_Association (Constr, New_Obj_Value (Instance));
- New_Procedure_Call (Constr);
- Finish_Subprogram_Body;
+ Start_Subprogram_Body (Subprg);
+ Start_Association (Constr, Arch_Info.Block_Elab_Subprg (K));
+ New_Association (Constr, New_Obj_Value (Instance));
+ New_Procedure_Call (Constr);
+ Finish_Subprogram_Body;
+ end loop;
-- Default config.
Config := Get_Library_Unit
@@ -310,13 +314,16 @@ package body Trans.Chap12 is
Finish_Init_Value (Const, Ghdl_Index_0);
-- Elaborator.
- Start_Procedure_Decl
- (Inter_List, Create_Identifier ("ELAB"), O_Storage_Public);
- New_Interface_Decl (Inter_List, Instance, Wki_Instance, Ghdl_Ptr_Type);
- Finish_Subprogram_Decl (Inter_List, Subprg);
+ for K in Elab_Kind loop
+ Start_Procedure_Decl
+ (Inter_List, Create_Elab_Identifier (K), O_Storage_Public);
+ New_Interface_Decl
+ (Inter_List, Instance, Wki_Instance, Ghdl_Ptr_Type);
+ Finish_Subprogram_Decl (Inter_List, Subprg);
- Start_Subprogram_Body (Subprg);
- Finish_Subprogram_Body;
+ Start_Subprogram_Body (Subprg);
+ Finish_Subprogram_Body;
+ end loop;
-- Default config.
Start_Procedure_Decl
diff --git a/src/vhdl/translate/trans-chap9.adb b/src/vhdl/translate/trans-chap9.adb
index 2e515b9d6..1bc8aa5a3 100644
--- a/src/vhdl/translate/trans-chap9.adb
+++ b/src/vhdl/translate/trans-chap9.adb
@@ -849,13 +849,13 @@ package body Trans.Chap9 is
Instance : O_Dnode;
begin
-- Create the elaborator for the instantiation.
- Start_Procedure_Decl (Inter_List, Create_Identifier ("ELAB"),
+ Start_Procedure_Decl (Inter_List, Create_Identifier ("COMP_ELAB"),
O_Storage_Private);
New_Interface_Decl (Inter_List, Instance, Wki_Instance,
Base.Block_Decls_Ptr_Type);
- Finish_Subprogram_Decl (Inter_List, Info.Block_Elab_Subprg);
+ Finish_Subprogram_Decl (Inter_List, Info.Block_Elab_Subprg (Elab_Decls));
- Start_Subprogram_Body (Info.Block_Elab_Subprg);
+ Start_Subprogram_Body (Info.Block_Elab_Subprg (Elab_Decls));
Push_Local_Factory;
Set_Scope_Via_Param_Ptr (Base.Block_Scope, Instance);
@@ -1444,7 +1444,7 @@ package body Trans.Chap9 is
Arch_Info : Block_Info_Acc;
Instance_Size : O_Dnode;
- Arch_Elab : O_Dnode;
+ Arch_Elab : O_Dnode_Elab;
Arch_Config : O_Dnode;
Arch_Config_Type : O_Tnode;
@@ -1514,18 +1514,25 @@ package body Trans.Chap9 is
& Get_Arch_Name & "__";
Sub_Inter : O_Inter_List;
Arg : O_Dnode;
+ Id : O_Ident;
begin
if Arch_Info = null then
New_Const_Decl
(Instance_Size, Get_Identifier (Str & "INSTSIZE"),
O_Storage_External, Ghdl_Index_Type);
- Start_Procedure_Decl
- (Sub_Inter, Get_Identifier (Str & "ELAB"),
- O_Storage_External);
- New_Interface_Decl (Sub_Inter, Arg, Wki_Instance,
- Entity_Info.Block_Decls_Ptr_Type);
- Finish_Subprogram_Decl (Sub_Inter, Arch_Elab);
+ for K in Elab_Kind loop
+ case K is
+ when Elab_Decls =>
+ Id := Get_Identifier (Str & "DECL_ELAB");
+ when Elab_Stmts =>
+ Id := Get_Identifier (Str & "STMT_ELAB");
+ end case;
+ Start_Procedure_Decl (Sub_Inter, Id, O_Storage_External);
+ New_Interface_Decl (Sub_Inter, Arg, Wki_Instance,
+ Entity_Info.Block_Decls_Ptr_Type);
+ Finish_Subprogram_Decl (Sub_Inter, Arch_Elab (K));
+ end loop;
end if;
if Config = Null_Iir then
@@ -1632,9 +1639,11 @@ package body Trans.Chap9 is
declare
Assoc : O_Assoc_List;
begin
- Start_Association (Assoc, Arch_Elab);
- New_Association (Assoc, New_Obj_Value (Var_Sub));
- New_Procedure_Call (Assoc);
+ for K in Elab_Kind loop
+ Start_Association (Assoc, Arch_Elab (K));
+ New_Association (Assoc, New_Obj_Value (Var_Sub));
+ New_Procedure_Call (Assoc);
+ end loop;
end;
-- 5) Configure
@@ -1648,7 +1657,7 @@ package body Trans.Chap9 is
end;
end Translate_Entity_Instantiation;
- procedure Elab_If_Generate_Statement
+ procedure Elab_Decl_If_Generate_Statement
(Stmt : Iir_Generate_Statement; Parent : Iir; Base_Block : Iir)
is
Parent_Info : constant Block_Info_Acc := Get_Info (Parent);
@@ -1723,9 +1732,60 @@ package body Trans.Chap9 is
end Elab_If_Clause;
begin
Elab_If_Clause (Stmt);
- end Elab_If_Generate_Statement;
+ end Elab_Decl_If_Generate_Statement;
+
+ procedure Elab_Stmt_If_Generate_Statement
+ (Stmt : Iir_Generate_Statement; Parent : Iir)
+ is
+ Parent_Info : constant Block_Info_Acc := Get_Info (Parent);
+
+ -- Used to get Block_Parent_Field, set in the first generate statement
+ -- body.
+ Stmt_Info : constant Generate_Info_Acc := Get_Info (Stmt);
- procedure Elab_For_Generate_Statement
+ Case_Blk : O_Case_Block;
+ Clause : Iir;
+ Var : O_Dnode;
+ begin
+ Start_Case_Stmt
+ (Case_Blk, New_Value (New_Selected_Element
+ (Get_Instance_Ref (Parent_Info.Block_Scope),
+ Stmt_Info.Generate_Body_Id)));
+
+ Clause := Stmt;
+ while Clause /= Null_Iir loop
+ declare
+ Bod : constant Iir := Get_Generate_Statement_Body (Clause);
+ Info : constant Block_Info_Acc := Get_Info (Bod);
+ begin
+ Start_Choice (Case_Blk);
+ New_Expr_Choice
+ (Case_Blk, New_Index_Lit (Unsigned_64 (Info.Block_Id)));
+ Finish_Choice (Case_Blk);
+
+ Open_Temp;
+ Var := Create_Temp_Init
+ (Info.Block_Decls_Ptr_Type,
+ New_Convert_Ov
+ (New_Value (New_Selected_Element
+ (Get_Instance_Ref (Parent_Info.Block_Scope),
+ Stmt_Info.Generate_Parent_Field)),
+ Info.Block_Decls_Ptr_Type));
+
+ Set_Scope_Via_Param_Ptr (Info.Block_Scope, Var);
+ Elab_Block_Statements (Bod, Bod);
+ Clear_Scope (Info.Block_Scope);
+ Close_Temp;
+ end;
+ Clause := Get_Generate_Else_Clause (Clause);
+ end loop;
+ Start_Choice (Case_Blk);
+ New_Default_Choice (Case_Blk);
+ Finish_Choice (Case_Blk);
+ Finish_Case_Stmt (Case_Blk);
+ end Elab_Stmt_If_Generate_Statement;
+
+ procedure Elab_Decl_For_Generate_Statement
(Stmt : Iir_Generate_Statement; Parent : Iir; Base_Block : Iir)
is
Iter : constant Iir := Get_Parameter_Specification (Stmt);
@@ -1840,7 +1900,68 @@ package body Trans.Chap9 is
Inc_Var (Var_I);
Finish_Loop_Stmt (Label);
Close_Temp;
- end Elab_For_Generate_Statement;
+ end Elab_Decl_For_Generate_Statement;
+
+ procedure Elab_Stmt_For_Generate_Statement
+ (Stmt : Iir_Generate_Statement; Parent : Iir)
+ is
+ Iter : constant Iir := Get_Parameter_Specification (Stmt);
+ Iter_Type : constant Iir := Get_Type (Iter);
+ Iter_Base_Type : constant Iir := Get_Base_Type (Iter_Type);
+ Iter_Type_Info : constant Type_Info_Acc := Get_Info (Iter_Base_Type);
+ Bod : constant Iir := Get_Generate_Statement_Body (Stmt);
+ Info : constant Block_Info_Acc := Get_Info (Bod);
+ Parent_Info : constant Block_Info_Acc := Get_Info (Parent);
+ Var_Inst : O_Dnode;
+ Var_I : O_Dnode;
+ Label : O_Snode;
+ Var : O_Dnode;
+ Var_Len : O_Dnode;
+ begin
+ Open_Temp;
+
+ -- Evaluate iterator range.
+ Chap3.Elab_Object_Subtype (Iter_Type);
+
+ -- Allocate instances.
+ Var_Inst := Create_Temp_Init
+ (Info.Block_Decls_Array_Ptr_Type,
+ New_Value (New_Selected_Element
+ (Get_Instance_Ref (Parent_Info.Block_Scope),
+ Info.Block_Parent_Field)));
+ Var_Len := Create_Temp_Init
+ (Ghdl_Index_Type,
+ New_Value (New_Selected_Element
+ (Get_Var (Get_Info (Iter_Type).T.Range_Var),
+ Iter_Type_Info.T.Range_Length)));
+
+ -- Start loop.
+ Var_I := Create_Temp (Ghdl_Index_Type);
+ Init_Var (Var_I);
+ Start_Loop_Stmt (Label);
+ Gen_Exit_When
+ (Label, New_Compare_Op (ON_Eq,
+ New_Obj_Value (Var_I),
+ New_Obj_Value (Var_Len),
+ Ghdl_Bool_Type));
+
+ Var := Create_Temp_Ptr
+ (Info.Block_Decls_Ptr_Type,
+ New_Indexed_Element (New_Acc_Value (New_Obj (Var_Inst)),
+ New_Obj_Value (Var_I)));
+
+ -- Elaborate block
+ Set_Scope_Via_Param_Ptr (Info.Block_Scope, Var);
+
+ -- Elaboration.
+ Elab_Block_Statements (Bod, Bod);
+
+ Clear_Scope (Info.Block_Scope);
+
+ Inc_Var (Var_I);
+ Finish_Loop_Stmt (Label);
+ Close_Temp;
+ end Elab_Stmt_For_Generate_Statement;
type Merge_Signals_Data is record
Sig : Iir;
@@ -2082,20 +2203,21 @@ package body Trans.Chap9 is
case Get_Kind (Stmt) is
when Iir_Kind_Process_Statement
| Iir_Kind_Sensitized_Process_Statement =>
- Elab_Process (Stmt, Base_Info);
+ null;
when Iir_Kind_Psl_Default_Clock =>
null;
when Iir_Kind_Psl_Declaration =>
null;
when Iir_Kind_Psl_Assert_Statement
| Iir_Kind_Psl_Cover_Statement =>
- Elab_Psl_Directive (Stmt, Base_Info);
+ null;
when Iir_Kind_Component_Instantiation_Statement =>
declare
Info : constant Block_Info_Acc := Get_Info (Stmt);
Constr : O_Assoc_List;
begin
- Start_Association (Constr, Info.Block_Elab_Subprg);
+ Start_Association
+ (Constr, Info.Block_Elab_Subprg (Elab_Decls));
New_Association
(Constr, Get_Instance_Access (Base_Block));
New_Procedure_Call (Constr);
@@ -2113,7 +2235,7 @@ package body Trans.Chap9 is
Mark : Id_Mark_Type;
begin
Push_Identifier_Prefix (Mark, Get_Identifier (Stmt));
- Elab_If_Generate_Statement (Stmt, Block, Base_Block);
+ Elab_Decl_If_Generate_Statement (Stmt, Block, Base_Block);
Pop_Identifier_Prefix (Mark);
end;
when Iir_Kind_For_Generate_Statement =>
@@ -2121,7 +2243,7 @@ package body Trans.Chap9 is
Mark : Id_Mark_Type;
begin
Push_Identifier_Prefix (Mark, Get_Identifier (Stmt));
- Elab_For_Generate_Statement (Stmt, Block, Base_Block);
+ Elab_Decl_For_Generate_Statement (Stmt, Block, Base_Block);
Pop_Identifier_Prefix (Mark);
end;
when others =>
@@ -2130,4 +2252,55 @@ package body Trans.Chap9 is
Stmt := Get_Chain (Stmt);
end loop;
end Elab_Block_Declarations;
+
+ procedure Elab_Block_Statements (Block : Iir; Base_Block : Iir)
+ is
+ Base_Info : constant Block_Info_Acc := Get_Info (Base_Block);
+ Stmt : Iir;
+ begin
+ Stmt := Get_Concurrent_Statement_Chain (Block);
+ while Stmt /= Null_Iir loop
+ case Get_Kind (Stmt) is
+ when Iir_Kind_Process_Statement
+ | Iir_Kind_Sensitized_Process_Statement =>
+ Elab_Process (Stmt, Base_Info);
+ when Iir_Kind_Psl_Default_Clock =>
+ null;
+ when Iir_Kind_Psl_Declaration =>
+ null;
+ when Iir_Kind_Psl_Assert_Statement
+ | Iir_Kind_Psl_Cover_Statement =>
+ Elab_Psl_Directive (Stmt, Base_Info);
+ when Iir_Kind_Component_Instantiation_Statement =>
+ null;
+ when Iir_Kind_Block_Statement =>
+ declare
+ Mark : Id_Mark_Type;
+ begin
+ Push_Identifier_Prefix (Mark, Get_Identifier (Stmt));
+ Elab_Block_Statements (Stmt, Base_Block);
+ Pop_Identifier_Prefix (Mark);
+ end;
+ when Iir_Kind_If_Generate_Statement =>
+ declare
+ Mark : Id_Mark_Type;
+ begin
+ Push_Identifier_Prefix (Mark, Get_Identifier (Stmt));
+ Elab_Stmt_If_Generate_Statement (Stmt, Block);
+ Pop_Identifier_Prefix (Mark);
+ end;
+ when Iir_Kind_For_Generate_Statement =>
+ declare
+ Mark : Id_Mark_Type;
+ begin
+ Push_Identifier_Prefix (Mark, Get_Identifier (Stmt));
+ Elab_Stmt_For_Generate_Statement (Stmt, Block);
+ Pop_Identifier_Prefix (Mark);
+ end;
+ when others =>
+ Error_Kind ("elab_block_statements", Stmt);
+ end case;
+ Stmt := Get_Chain (Stmt);
+ end loop;
+ end Elab_Block_Statements;
end Trans.Chap9;
diff --git a/src/vhdl/translate/trans-chap9.ads b/src/vhdl/translate/trans-chap9.ads
index 61b1f9c9a..1a94c01b8 100644
--- a/src/vhdl/translate/trans-chap9.ads
+++ b/src/vhdl/translate/trans-chap9.ads
@@ -19,7 +19,9 @@
package Trans.Chap9 is
procedure Translate_Block_Declarations (Block : Iir; Origin : Iir);
procedure Translate_Block_Subprograms (Block : Iir; Base_Block : Iir);
+
procedure Elab_Block_Declarations (Block : Iir; Base_Block : Iir);
+ procedure Elab_Block_Statements (Block : Iir; Base_Block : Iir);
-- Generate code to instantiate an entity.
-- ASPECT must be an entity_aspect.
@@ -39,4 +41,3 @@ package Trans.Chap9 is
procedure Destroy_Types (N : Iir);
procedure Destroy_Types_In_List (L : Iir_List);
end Trans.Chap9;
-
diff --git a/src/vhdl/translate/trans.adb b/src/vhdl/translate/trans.adb
index 481870f89..6efa94701 100644
--- a/src/vhdl/translate/trans.adb
+++ b/src/vhdl/translate/trans.adb
@@ -889,6 +889,16 @@ package body Trans is
return Get_Identifier (Identifier_Buffer (1 .. Identifier_Len - 2));
end Create_Identifier;
+ function Create_Elab_Identifier (Kind : Elab_Kind) return O_Ident is
+ begin
+ case Kind is
+ when Elab_Decls =>
+ return Create_Identifier ("DECL_ELAB");
+ when Elab_Stmts =>
+ return Create_Identifier ("STMT_ELAB");
+ end case;
+ end Create_Elab_Identifier;
+
function Create_Var_Identifier_From_Buffer (L : Natural)
return Var_Ident_Type
is
diff --git a/src/vhdl/translate/trans.ads b/src/vhdl/translate/trans.ads
index 63db84bd8..e97d6a0c3 100644
--- a/src/vhdl/translate/trans.ads
+++ b/src/vhdl/translate/trans.ads
@@ -192,6 +192,9 @@ package Trans is
function Add_Pointer
(Ptr : O_Enode; Offset : O_Enode; Res_Ptr : O_Tnode) return O_Enode;
+ type Elab_Kind is (Elab_Decls, Elab_Stmts);
+ type O_Dnode_Elab is array (Elab_Kind) of O_Dnode;
+
package Chap10 is
-- There are three data storage kind: global, local or instance.
-- For example, a constant can have:
@@ -349,6 +352,9 @@ package Trans is
-- Create a prefixed identifier from a string.
function Create_Identifier (Str : String) return O_Ident;
+ -- Create an identifier for an elaboration procedure.
+ function Create_Elab_Identifier (Kind : Elab_Kind) return O_Ident;
+
-- Create an identifier for a variable.
-- IE, if the variable is global, prepend the prefix,
-- if the variable belong to an instance, no prefix is added.
@@ -1380,7 +1386,8 @@ package Trans is
Block_Id : Nat32;
-- Subprogram which elaborates the block (for entity or arch).
- Block_Elab_Subprg : O_Dnode;
+ Block_Elab_Subprg : O_Dnode_Elab;
+
-- Size of the block instance.
Block_Instance_Size : O_Dnode;