diff options
author | Tristan Gingold <tgingold@free.fr> | 2023-01-09 07:51:05 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2023-01-09 07:52:18 +0100 |
commit | ebb526e2ec4187c1463b87c9db5b2417c6399793 (patch) | |
tree | b76c47198301a9ba6251858527b00204b1612d8f /src/synth | |
parent | 3049de704edfc40c539896b6e6416fa1ce4c9cd9 (diff) | |
download | ghdl-ebb526e2ec4187c1463b87c9db5b2417c6399793.tar.gz ghdl-ebb526e2ec4187c1463b87c9db5b2417c6399793.tar.bz2 ghdl-ebb526e2ec4187c1463b87c9db5b2417c6399793.zip |
synth: always create shared variables
Diffstat (limited to 'src/synth')
-rw-r--r-- | src/synth/elab-vhdl_decls.adb | 18 | ||||
-rw-r--r-- | src/synth/synth-vhdl_decls.adb | 15 |
2 files changed, 20 insertions, 13 deletions
diff --git a/src/synth/elab-vhdl_decls.adb b/src/synth/elab-vhdl_decls.adb index 33aa08560..6839ed123 100644 --- a/src/synth/elab-vhdl_decls.adb +++ b/src/synth/elab-vhdl_decls.adb @@ -100,13 +100,19 @@ package body Elab.Vhdl_Decls is -- Note: Obj_Typ is bounded. Init.Typ := Obj_Typ; else - if Force_Init then - Current_Pool := Instance_Pool; - Init := Create_Value_Default (Obj_Typ); - Current_Pool := Expr_Pool'Access; + -- Always create shared variables, as they might be referenced + -- during elaboration. + if (Force_Init or else Get_Shared_Flag (Decl)) then + if Obj_Typ.Kind /= Type_Protected then + Current_Pool := Instance_Pool; + Init := Create_Value_Default (Obj_Typ); + Current_Pool := Expr_Pool'Access; + else + Init := Synth.Vhdl_Decls.Create_Protected_Object + (Syn_Inst, Decl, Obj_Typ); + Init := Unshare (Init, Instance_Pool); + end if; else - -- For synthesis, no need to set a value for a shared variable - -- (they will certainly become a memory). Init := (Typ => Obj_Typ, Val => null); end if; end if; diff --git a/src/synth/synth-vhdl_decls.adb b/src/synth/synth-vhdl_decls.adb index ed0a62ace..5c9e62f37 100644 --- a/src/synth/synth-vhdl_decls.adb +++ b/src/synth/synth-vhdl_decls.adb @@ -534,13 +534,14 @@ package body Synth.Vhdl_Decls is if Init.Typ.Kind = Type_Protected then Error_Msg_Synth (Syn_Inst, Decl, "protected type not supported"); Set_Error (Syn_Inst); - else - if Init.Val = null then - Mark_Expr_Pool (Marker); - Init := Create_Value_Default (Init.Typ); - Init := Unshare (Init, Instance_Pool); - Release_Expr_Pool (Marker); - end if; + return; + end if; + + if Init.Val = null then + Mark_Expr_Pool (Marker); + Init := Create_Value_Default (Init.Typ); + Init := Unshare (Init, Instance_Pool); + Release_Expr_Pool (Marker); end if; Val := Create_Var_Wire (Syn_Inst, Decl, Wire_Variable, Init); |