diff options
-rw-r--r-- | src/ghdldrv/ghdlrun.adb | 3 | ||||
-rw-r--r-- | src/grt/grt-main.adb | 5 | ||||
-rw-r--r-- | src/grt/grt-main.ads | 5 | ||||
-rw-r--r-- | src/ortho/llvm/ortho_code_main.adb | 12 | ||||
-rw-r--r-- | src/vhdl/translate/ortho_front.adb | 2 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap1.adb | 37 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap1.ads | 5 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap12.adb | 23 | ||||
-rw-r--r-- | src/vhdl/translate/trans_decls.ads | 2 | ||||
-rw-r--r-- | src/vhdl/translate/translation.adb | 6 |
10 files changed, 58 insertions, 42 deletions
diff --git a/src/ghdldrv/ghdlrun.adb b/src/ghdldrv/ghdlrun.adb index d927b4d16..32e85a0f7 100644 --- a/src/ghdldrv/ghdlrun.adb +++ b/src/ghdldrv/ghdlrun.adb @@ -437,6 +437,9 @@ package body Ghdlrun is Def (Trans_Decls.Ghdl_Rti_Add_Top, Grt.Rtis.Ghdl_Rti_Add_Top'Address); + Def (Trans_Decls.Ghdl_Init_Top_Generics, + Grt.Main.Ghdl_Init_Top_Generics'Address); + Def (Trans_Decls.Ghdl_Protected_Enter, Grt.Processes.Ghdl_Protected_Enter'Address); Def (Trans_Decls.Ghdl_Protected_Leave, diff --git a/src/grt/grt-main.adb b/src/grt/grt-main.adb index 116ea7b2e..32547774b 100644 --- a/src/grt/grt-main.adb +++ b/src/grt/grt-main.adb @@ -60,6 +60,11 @@ package body Grt.Main is return 0; end Ghdl_Elaborate_Wrapper; + procedure Ghdl_Init_Top_Generics is + begin + null; + end Ghdl_Init_Top_Generics; + procedure Disp_Stats_Hook (Code : Integer); pragma Convention (C, Disp_Stats_Hook); diff --git a/src/grt/grt-main.ads b/src/grt/grt-main.ads index 4f78477f2..6dd774197 100644 --- a/src/grt/grt-main.ads +++ b/src/grt/grt-main.ads @@ -26,4 +26,9 @@ package Grt.Main is -- Elaborate and simulate the design. procedure Run; + + -- This function is called by elaboration code once default values have + -- been assigned to generics, but before being used. + procedure Ghdl_Init_Top_Generics; + pragma Export (C, Ghdl_Init_Top_Generics, "__ghdl_init_top_generics"); end Grt.Main; diff --git a/src/ortho/llvm/ortho_code_main.adb b/src/ortho/llvm/ortho_code_main.adb index f80979fc7..8d7ba8289 100644 --- a/src/ortho/llvm/ortho_code_main.adb +++ b/src/ortho/llvm/ortho_code_main.adb @@ -169,11 +169,17 @@ begin Opt_Arg : String_Acc; Res : Natural; begin + Opt_Arg := null; if Optind < Argument_Count then - Opt_Arg := new String'(Argument (Optind + 1)); - else - Opt_Arg := null; + declare + Arg1 : constant String := Argument (Optind + 1); + begin + if Arg1 (Arg1'First) /= '-' then + Opt_Arg := new String'(Arg1); + end if; + end; end if; + Res := Ortho_Front.Decode_Option (Opt, Opt_Arg); case Res is when 0 => diff --git a/src/vhdl/translate/ortho_front.adb b/src/vhdl/translate/ortho_front.adb index 0473899af..e17b1a7d8 100644 --- a/src/vhdl/translate/ortho_front.adb +++ b/src/vhdl/translate/ortho_front.adb @@ -189,7 +189,7 @@ package body Ortho_Front is end if; Anaelab_Files_Last := L; end; - return 2; + return 1; elsif Opt.all = "-l" then if Arg = null then Error_Msg_Option ("filename required after -l"); diff --git a/src/vhdl/translate/trans-chap1.adb b/src/vhdl/translate/trans-chap1.adb index ac64e6523..8d6099295 100644 --- a/src/vhdl/translate/trans-chap1.adb +++ b/src/vhdl/translate/trans-chap1.adb @@ -39,14 +39,12 @@ package body Trans.Chap1 is (Info.Block_Scope'Access, Info.Block_Decls_Ptr_Type); end Start_Block_Decl; - procedure Translate_Entity_Init (Entity : Iir) + procedure Translate_Entity_Init_Generics (Entity : Iir) is El : Iir; - El_Type : Iir; begin Push_Local_Factory; - -- Generics. El := Get_Generic_Chain (Entity); while El /= Null_Iir loop Open_Temp; @@ -55,7 +53,16 @@ package body Trans.Chap1 is El := Get_Chain (El); end loop; - -- Ports. + Pop_Local_Factory; + end Translate_Entity_Init_Generics; + + procedure Translate_Entity_Init_Ports (Entity : Iir) + is + El : Iir; + El_Type : Iir; + begin + Push_Local_Factory; + El := Get_Port_Chain (Entity); while El /= Null_Iir loop Open_Temp; @@ -71,7 +78,7 @@ package body Trans.Chap1 is end loop; Pop_Local_Factory; - end Translate_Entity_Init; + end Translate_Entity_Init_Ports; procedure Translate_Entity_Declaration (Entity : Iir_Entity_Declaration) is @@ -142,26 +149,6 @@ package body Trans.Chap1 is Subprgs.Finish_Subprg_Instance_Use (Instance); Pop_Local_Factory; Finish_Subprogram_Body; - - -- Default value if any. - if False then --Is_Entity_Declaration_Top (Entity) then - declare - Init_Subprg : O_Dnode; - begin - Start_Procedure_Decl - (Interface_List, Create_Identifier ("_INIT"), - Global_Storage); - Subprgs.Add_Subprg_Instance_Interfaces - (Interface_List, Instance); - Finish_Subprogram_Decl (Interface_List, Init_Subprg); - - Start_Subprogram_Body (Init_Subprg); - Subprgs.Start_Subprg_Instance_Use (Instance); - Translate_Entity_Init (Entity); - Subprgs.Finish_Subprg_Instance_Use (Instance); - Finish_Subprogram_Body; - end; - end if; end if; Subprgs.Pop_Subprg_Instance (Wki_Instance, Prev_Subprg_Instance); end Translate_Entity_Declaration; diff --git a/src/vhdl/translate/trans-chap1.ads b/src/vhdl/translate/trans-chap1.ads index 1b4b11691..005363a66 100644 --- a/src/vhdl/translate/trans-chap1.ads +++ b/src/vhdl/translate/trans-chap1.ads @@ -25,7 +25,10 @@ package Trans.Chap1 is -- Generate code to initialize generics of instance INSTANCE of ENTITY -- using the default values. -- This is used when ENTITY is at the top of a design hierarchy. - procedure Translate_Entity_Init (Entity : Iir); + procedure Translate_Entity_Init_Generics (Entity : Iir); + + -- Likewise, but for ports. + procedure Translate_Entity_Init_Ports (Entity : Iir); procedure Translate_Architecture_Body (Arch : Iir); diff --git a/src/vhdl/translate/trans-chap12.adb b/src/vhdl/translate/trans-chap12.adb index 5c314f69a..0861852b8 100644 --- a/src/vhdl/translate/trans-chap12.adb +++ b/src/vhdl/translate/trans-chap12.adb @@ -42,8 +42,8 @@ package body Trans.Chap12 is Config_Subprg : O_Dnode; Nbr_Pkgs : Natural) is - Entity_Info : Block_Info_Acc; - Arch_Info : Block_Info_Acc; + Entity_Info : constant Block_Info_Acc := Get_Info (Entity); + Arch_Info : constant Block_Info_Acc := Get_Info (Arch); Inter_List : O_Inter_List; Assoc : O_Assoc_List; Instance : O_Dnode; @@ -52,9 +52,6 @@ package body Trans.Chap12 is Arr_Type : O_Tnode; Arr : O_Dnode; begin - Arch_Info := Get_Info (Arch); - Entity_Info := Get_Info (Entity); - -- We need to create code. Set_Global_Storage (O_Storage_Private); @@ -78,7 +75,7 @@ package body Trans.Chap12 is New_Var_Decl (Instance, Wki_Instance, O_Storage_Local, Entity_Info.Block_Decls_Ptr_Type); - -- Create instance for the architecture. + -- Allocate instance for the architecture. New_Assign_Stmt (New_Obj (Arch_Instance), Gen_Alloc (Alloc_System, @@ -132,19 +129,21 @@ package body Trans.Chap12 is Start_Association (Assoc, Entity_Info.Block_Elab_Pkg_Subprg); New_Procedure_Call (Assoc); - -- init instance + -- Init instance: assign default values to generic and create ports. + -- Allow user override of generics. Set_Scope_Via_Param_Ptr (Entity_Info.Block_Scope, Instance); Push_Identifier_Prefix (Mark, ""); - Chap1.Translate_Entity_Init (Entity); + Chap1.Translate_Entity_Init_Generics (Entity); + Start_Association (Assoc, Ghdl_Init_Top_Generics); + New_Procedure_Call (Assoc); + Chap1.Translate_Entity_Init_Ports (Entity); - -- elab instance + -- Elab instance. Start_Association (Assoc, Arch_Info.Block_Elab_Subprg); New_Association (Assoc, New_Obj_Value (Instance)); New_Procedure_Call (Assoc); - --Chap6.Link_Instance_Name (Null_Iir, Entity); - - -- configure instance. + -- Configure instance. Start_Association (Assoc, Config_Subprg); New_Association (Assoc, New_Obj_Value (Arch_Instance)); New_Procedure_Call (Assoc); diff --git a/src/vhdl/translate/trans_decls.ads b/src/vhdl/translate/trans_decls.ads index e104c71c4..50f49cf5c 100644 --- a/src/vhdl/translate/trans_decls.ads +++ b/src/vhdl/translate/trans_decls.ads @@ -253,5 +253,7 @@ package Trans_Decls is Ghdl_Rti_Add_Package : O_Dnode; Ghdl_Rti_Add_Top : O_Dnode; + Ghdl_Init_Top_Generics : O_Dnode; + Ghdl_Elaborate : O_Dnode; end Trans_Decls; diff --git a/src/vhdl/translate/translation.adb b/src/vhdl/translate/translation.adb index 9037f169c..4ef0bcb61 100644 --- a/src/vhdl/translate/translation.adb +++ b/src/vhdl/translate/translation.adb @@ -1734,6 +1734,12 @@ package body Translation is (Interfaces, Param, Wki_Instance, Ghdl_Ptr_Type); Finish_Subprogram_Decl (Interfaces, Ghdl_Rti_Add_Top); + -- procedure __ghdl_init_top_generics(); + Start_Procedure_Decl + (Interfaces, Get_Identifier ("__ghdl_init_top_generics"), + O_Storage_External); + Finish_Subprogram_Decl (Interfaces, Ghdl_Init_Top_Generics); + -- Create match subprograms for std_ulogic type. Create_Std_Ulogic_Match_Subprogram ("eq", Ghdl_Std_Ulogic_Match_Eq); Create_Std_Ulogic_Match_Subprogram ("ne", Ghdl_Std_Ulogic_Match_Ne); |