From 99443212bf78a5d36b693abab225a160a92d097a Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Wed, 7 Jan 2015 08:07:42 +0100 Subject: Handle vhdl08 if generate statements --- src/vhdl/translate/trans-chap1.adb | 40 +++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'src/vhdl/translate/trans-chap1.adb') diff --git a/src/vhdl/translate/trans-chap1.adb b/src/vhdl/translate/trans-chap1.adb index ae2b10699..1f0e7d3e7 100644 --- a/src/vhdl/translate/trans-chap1.adb +++ b/src/vhdl/translate/trans-chap1.adb @@ -727,31 +727,39 @@ package body Trans.Chap1 is Parent_Info : Block_Info_Acc) is Spec : constant Iir := Get_Block_Specification (Block_Config); - Block : constant Iir := Get_Block_From_Block_Specification (Spec); - Info : constant Block_Info_Acc := Get_Info (Block); + Bod : constant Iir := Get_Block_From_Block_Specification (Spec); + Gen : constant Iir := Get_Parent (Bod); + Gen_Info : constant Generate_Info_Acc := Get_Info (Gen); + Bod_Info : constant Block_Info_Acc := Get_Info (Bod); Var : O_Dnode; If_Blk : O_If_Block; begin - -- Configure the block only if it was created. - Open_Temp; - Var := Create_Temp_Init - (Info.Block_Decls_Ptr_Type, - New_Value (New_Selected_Element - (Get_Instance_Ref (Parent_Info.Block_Scope), - Info.Block_Parent_Field))); + -- Configure the block only if block id matches. Start_If_Stmt (If_Blk, New_Compare_Op - (ON_Neq, - New_Obj_Value (Var), - New_Lit (New_Null_Access (Info.Block_Decls_Ptr_Type)), + (ON_Eq, + New_Value (New_Selected_Element + (Get_Instance_Ref (Parent_Info.Block_Scope), + Gen_Info.Generate_Body_Id)), + New_Lit (New_Index_Lit (Unsigned_64 (Bod_Info.Block_Id))), Ghdl_Bool_Type)); - Set_Scope_Via_Param_Ptr (Info.Block_Scope, Var); - Translate_Block_Configuration_Calls (Block_Config, Block, Info); - Clear_Scope (Info.Block_Scope); - Finish_If_Stmt (If_Blk); + + Open_Temp; + Var := Create_Temp_Init + (Bod_Info.Block_Decls_Ptr_Type, + New_Convert_Ov + (New_Value (New_Selected_Element + (Get_Instance_Ref (Parent_Info.Block_Scope), + Gen_Info.Generate_Parent_Field)), + Bod_Info.Block_Decls_Ptr_Type)); + Set_Scope_Via_Param_Ptr (Bod_Info.Block_Scope, Var); + Translate_Block_Configuration_Calls (Block_Config, Bod, Bod_Info); + Clear_Scope (Bod_Info.Block_Scope); Close_Temp; + + Finish_If_Stmt (If_Blk); end Translate_If_Generate_Block_Configuration_Calls; procedure Translate_Block_Configuration_Calls -- cgit v1.2.3