diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ghdldrv/ghdlprint.adb | 1 | ||||
-rw-r--r-- | src/ghdldrv/ghdlsynth.adb | 1 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap4.adb | 17 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap8.adb | 8 | ||||
-rw-r--r-- | src/vhdl/translate/trans-chap9.adb | 24 | ||||
-rw-r--r-- | src/vhdl/translate/trans-rtis.adb | 4 | ||||
-rw-r--r-- | src/vhdl/translate/trans.adb | 5 | ||||
-rw-r--r-- | src/vhdl/translate/trans.ads | 5 | ||||
-rw-r--r-- | src/vhdl/vhdl-canon.adb | 5 | ||||
-rw-r--r-- | src/vhdl/vhdl-canon.ads | 2 |
10 files changed, 56 insertions, 16 deletions
diff --git a/src/ghdldrv/ghdlprint.adb b/src/ghdldrv/ghdlprint.adb index a95e456cd..53f6f07be 100644 --- a/src/ghdldrv/ghdlprint.adb +++ b/src/ghdldrv/ghdlprint.adb @@ -1123,6 +1123,7 @@ package body Ghdlprint is Vhdl.Canon.Canon_Flag_Configurations := False; Vhdl.Canon.Canon_Flag_Specification_Lists := False; Vhdl.Canon.Canon_Flag_Associations := False; + Vhdl.Canon.Canon_Flag_Add_Suspend_State := False; Flags.Flag_Gather_Comments := Cmd.Flag_Comments; diff --git a/src/ghdldrv/ghdlsynth.adb b/src/ghdldrv/ghdlsynth.adb index 44d553150..6e2871afa 100644 --- a/src/ghdldrv/ghdlsynth.adb +++ b/src/ghdldrv/ghdlsynth.adb @@ -279,6 +279,7 @@ package body Ghdlsynth is -- Do not canon concurrent statements. Vhdl.Canon.Canon_Flag_Concurrent_Stmts := False; + Vhdl.Canon.Canon_Flag_Add_Suspend_State := False; if Ghdlcomp.Init_Verilog_Options /= null then Ghdlcomp.Init_Verilog_Options.all (False); diff --git a/src/vhdl/translate/trans-chap4.adb b/src/vhdl/translate/trans-chap4.adb index 0f455a83d..198bcbe62 100644 --- a/src/vhdl/translate/trans-chap4.adb +++ b/src/vhdl/translate/trans-chap4.adb @@ -1890,8 +1890,17 @@ package body Trans.Chap4 is Pop_Identifier_Prefix (Mark); end Translate_Component_Declaration; - procedure Translate_Declaration (Decl : Iir) + procedure Create_Suspend_State (Decl : Iir) is + Info : Object_Info_Acc; + begin + Info := Add_Info (Decl, Kind_Object); + + Info.Object_Var := Create_Var (Create_Var_Identifier ("STATE"), + Ghdl_Index_Type, O_Storage_Local); + end Create_Suspend_State; + + procedure Translate_Declaration (Decl : Iir) is begin case Get_Kind (Decl) is when Iir_Kind_Use_Clause => @@ -1931,6 +1940,9 @@ package body Trans.Chap4 is -- | Iir_Kind_Interface_Signal_Declaration => -- Chap4.Create_Object (Decl); + when Iir_Kind_Suspend_State_Declaration => + Create_Suspend_State (Decl); + when Iir_Kind_Variable_Declaration | Iir_Kind_Constant_Declaration => Create_Object (Decl); @@ -2676,6 +2688,9 @@ package body Trans.Chap4 is when Iir_Kind_Disconnection_Specification => Chap5.Elab_Disconnection_Specification (Decl); + when Iir_Kind_Suspend_State_Declaration => + null; + when Iir_Kind_Type_Declaration | Iir_Kind_Anonymous_Type_Declaration => Chap3.Elab_Type_Declaration (Decl); diff --git a/src/vhdl/translate/trans-chap8.adb b/src/vhdl/translate/trans-chap8.adb index 050e19620..00505e33d 100644 --- a/src/vhdl/translate/trans-chap8.adb +++ b/src/vhdl/translate/trans-chap8.adb @@ -74,8 +74,8 @@ package body Trans.Chap8 is function Get_State_Var (Info : Ortho_Info_Acc) return O_Lnode is begin case Info.Kind is - when Kind_Process => - return Get_Var (Info.Process_State); + when Kind_Object => + return Get_Var (Info.Object_Var); when Kind_Subprg => return New_Selected_Acc_Value (New_Obj (Info.Res_Interface), Info.Subprg_State_Field); @@ -109,7 +109,6 @@ package body Trans.Chap8 is procedure State_Leave (Parent : Iir) is begin pragma Assert (State_Enabled); - pragma Assert (Get_Info (Parent) = State_Info); if State_Debug then Start_Choice (State_Case); @@ -4988,6 +4987,9 @@ package body Trans.Chap8 is New_Debug_Line_Stmt (Get_Line_Number (Stmt)); Open_Temp; case Get_Kind (Stmt) is + when Iir_Kind_Suspend_State_Statement => + null; + when Iir_Kind_Return_Statement => Translate_Return_Statement (Stmt); diff --git a/src/vhdl/translate/trans-chap9.adb b/src/vhdl/translate/trans-chap9.adb index 7dcec16a3..95c8db11c 100644 --- a/src/vhdl/translate/trans-chap9.adb +++ b/src/vhdl/translate/trans-chap9.adb @@ -102,6 +102,15 @@ package body Trans.Chap9 is end loop; end Reset_Direct_Drivers; + function Get_Suspend_State_Info (Proc : Iir) return Object_Info_Acc + is + State_Decl : constant Iir := Get_Declaration_Chain (Proc); + begin + pragma Assert + (Get_Kind (State_Decl) = Iir_Kind_Suspend_State_Declaration); + return Get_Info (State_Decl); + end Get_Suspend_State_Info; + procedure Translate_Process_Statement (Proc : Iir; Base : Block_Info_Acc) is use Trans.Chap8; @@ -123,7 +132,7 @@ package body Trans.Chap9 is Set_Scope_Via_Param_Ptr (Base.Block_Scope, Instance); if Is_Non_Sensitized then - Chap8.State_Entry (Info); + Chap8.State_Entry (Get_Suspend_State_Info (Proc)); end if; Chap8.Translate_Statements_Chain @@ -278,10 +287,6 @@ package body Trans.Chap9 is Chap4.Translate_Declaration_Chain (Proc); if Get_Kind (Proc) = Iir_Kind_Process_Statement then - -- The state variable. - Info.Process_State := Create_Var (Create_Var_Identifier ("STATE"), - Ghdl_Index_Type, O_Storage_Local); - -- Add declarations for statements (iterator, call) and state. Chap4.Translate_Statements_Chain_State_Declaration (Get_Sequential_Statement_Chain (Proc), @@ -1993,8 +1998,13 @@ package body Trans.Chap9 is end if; else -- Initialize state. - New_Assign_Stmt - (Get_Var (Info.Process_State), New_Lit (Ghdl_Index_0)); + declare + State_Info : constant Object_Info_Acc := + Get_Suspend_State_Info (Proc); + begin + New_Assign_Stmt + (Get_Var (State_Info.Object_Var), New_Lit (Ghdl_Index_0)); + end; end if; end Elab_Process; diff --git a/src/vhdl/translate/trans-rtis.adb b/src/vhdl/translate/trans-rtis.adb index b56364e2e..8b3c2cd04 100644 --- a/src/vhdl/translate/trans-rtis.adb +++ b/src/vhdl/translate/trans-rtis.adb @@ -2179,6 +2179,8 @@ package body Trans.Rtis is case Get_Kind (Decl) is when Iir_Kind_Use_Clause => null; + when Iir_Kind_Suspend_State_Declaration => + null; when Iir_Kind_Type_Declaration => -- FIXME: physicals ? if Get_Kind (Get_Type_Definition (Decl)) @@ -2303,6 +2305,8 @@ package body Trans.Rtis is when Iir_Kind_Type_Declaration | Iir_Kind_Subtype_Declaration => Add_Rti_Node (Generate_Type_Decl (Decl)); + when Iir_Kind_Suspend_State_Declaration => + null; when Iir_Kind_Constant_Declaration => -- Do not generate RTIs for full declarations. -- (RTI will be generated for the deferred declaration). diff --git a/src/vhdl/translate/trans.adb b/src/vhdl/translate/trans.adb index de7fd3995..f2744897c 100644 --- a/src/vhdl/translate/trans.adb +++ b/src/vhdl/translate/trans.adb @@ -681,6 +681,11 @@ package body Trans is Var.I_Field, Otype); end Get_Var_Offset; + function Get_Var_Field (Var : Var_Type) return O_Fnode is + begin + return Var.I_Field; + end Get_Var_Field; + function Get_Var_Label (Var : Var_Type) return O_Dnode is begin case Var.Kind is diff --git a/src/vhdl/translate/trans.ads b/src/vhdl/translate/trans.ads index 3f385abe6..68e3a79b8 100644 --- a/src/vhdl/translate/trans.ads +++ b/src/vhdl/translate/trans.ads @@ -444,6 +444,7 @@ package Trans is -- Used only to generate RTI. function Is_Var_Field (Var : Var_Type) return Boolean; function Get_Var_Offset (Var : Var_Type; Otype : O_Tnode) return O_Cnode; + function Get_Var_Field (Var : Var_Type) return O_Fnode; function Get_Var_Label (Var : Var_Type) return O_Dnode; -- For package instantiation. @@ -1922,10 +1923,6 @@ package Trans is -- Subprogram for the process. Process_Subprg : O_Dnode; - -- Variable (in the frame) containing the current state (a - -- number) used to resume the process. - Process_State : Var_Type := Null_Var; - -- Union containing local declarations for statements. Process_Locvar_Scope : aliased Var_Scope_Type; diff --git a/src/vhdl/vhdl-canon.adb b/src/vhdl/vhdl-canon.adb index c8e71807e..d5d65a157 100644 --- a/src/vhdl/vhdl-canon.adb +++ b/src/vhdl/vhdl-canon.adb @@ -2296,6 +2296,11 @@ package body Vhdl.Canon is if Canon_Flag_Concurrent_Stmts then Stmt := Canon_Concurrent_Procedure_Call (Stmt); + if Canon_Flag_Add_Suspend_State + and then Get_Kind (Stmt) = Iir_Kind_Process_Statement + then + Canon_Add_Suspend_State (Stmt); + end if; end if; when Iir_Kind_Sensitized_Process_Statement diff --git a/src/vhdl/vhdl-canon.ads b/src/vhdl/vhdl-canon.ads index 65620339d..145014b86 100644 --- a/src/vhdl/vhdl-canon.ads +++ b/src/vhdl/vhdl-canon.ads @@ -43,7 +43,7 @@ package Vhdl.Canon is Canon_Flag_All_Sensitivity : Boolean := False; -- Add suspend state variables and statements. - Canon_Flag_Add_Suspend_State : Boolean := False; + Canon_Flag_Add_Suspend_State : Boolean := True; -- Do canonicalization: -- Transforms concurrent statements into sensitized process statements |