diff options
author | Tristan Gingold <tgingold@free.fr> | 2014-02-23 18:40:53 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2014-02-23 18:40:53 +0100 |
commit | 627f7b8313148cde9c372aca8b6cdc3d4d3dc78f (patch) | |
tree | 5bbfe310b51511a4fa8ca750dd07c9986cb5956c /translate/grt | |
parent | 5c0fbbfeb0ee689e97ca3a78a60d64f59796215e (diff) | |
download | ghdl-627f7b8313148cde9c372aca8b6cdc3d4d3dc78f.tar.gz ghdl-627f7b8313148cde9c372aca8b6cdc3d4d3dc78f.tar.bz2 ghdl-627f7b8313148cde9c372aca8b6cdc3d4d3dc78f.zip |
grt.signals: export Resolver_Acc and use it in interfaces.
Diffstat (limited to 'translate/grt')
-rw-r--r-- | translate/grt/grt-signals.adb | 63 | ||||
-rw-r--r-- | translate/grt/grt-signals.ads | 48 |
2 files changed, 61 insertions, 50 deletions
diff --git a/translate/grt/grt-signals.adb b/translate/grt/grt-signals.adb index 590aced7a..d939a9778 100644 --- a/translate/grt/grt-signals.adb +++ b/translate/grt/grt-signals.adb @@ -84,7 +84,7 @@ package body Grt.Signals is (Mode : Mode_Type; Init_Val : Value_Union; Mode_Sig : Mode_Signal_Type; - Resolv_Proc : System.Address; + Resolv_Proc : Resolver_Acc; Resolv_Inst : System.Address) return Ghdl_Signal_Ptr is @@ -95,7 +95,7 @@ package body Grt.Signals is Sig_Table.Increment_Last; if Current_Resolv = null then - if Resolv_Proc /= Null_Address then + if Resolv_Proc /= null then Resolv := new Resolved_Signal_Type' (Resolv_Proc => Resolv_Proc, Resolv_Inst => Resolv_Inst, @@ -106,7 +106,7 @@ package body Grt.Signals is Resolv := null; end if; else - if Resolv_Proc /= Null_Address then + if Resolv_Proc /= null then -- Only one resolution function is allowed! Internal_Error ("create_signal"); end if; @@ -209,7 +209,7 @@ package body Grt.Signals is end if; end Ghdl_Signal_Merge_Rti; - procedure Ghdl_Signal_Create_Resolution (Proc : System.Address; + procedure Ghdl_Signal_Create_Resolution (Proc : Resolver_Acc; Instance : System.Address; Sig : System.Address; Nbr_Sig : Ghdl_Index_Type) @@ -815,7 +815,7 @@ package body Grt.Signals is function Ghdl_Create_Signal_B2 (Init_Val : Ghdl_B2; - Resolv_Func : System.Address; + Resolv_Func : Resolver_Acc; Resolv_Inst : System.Address) return Ghdl_Signal_Ptr is @@ -886,7 +886,7 @@ package body Grt.Signals is function Ghdl_Create_Signal_E8 (Init_Val : Ghdl_E8; - Resolv_Func : System.Address; + Resolv_Func : Resolver_Acc; Resolv_Inst : System.Address) return Ghdl_Signal_Ptr is @@ -957,7 +957,7 @@ package body Grt.Signals is function Ghdl_Create_Signal_E32 (Init_Val : Ghdl_E32; - Resolv_Func : System.Address; + Resolv_Func : Resolver_Acc; Resolv_Inst : System.Address) return Ghdl_Signal_Ptr is @@ -1030,7 +1030,7 @@ package body Grt.Signals is function Ghdl_Create_Signal_I32 (Init_Val : Ghdl_I32; - Resolv_Func : System.Address; + Resolv_Func : Resolver_Acc; Resolv_Inst : System.Address) return Ghdl_Signal_Ptr is @@ -1103,7 +1103,7 @@ package body Grt.Signals is function Ghdl_Create_Signal_I64 (Init_Val : Ghdl_I64; - Resolv_Func : System.Address; + Resolv_Func : Resolver_Acc; Resolv_Inst : System.Address) return Ghdl_Signal_Ptr is @@ -1176,7 +1176,7 @@ package body Grt.Signals is function Ghdl_Create_Signal_F64 (Init_Val : Ghdl_F64; - Resolv_Func : System.Address; + Resolv_Func : Resolver_Acc; Resolv_Inst : System.Address) return Ghdl_Signal_Ptr is @@ -1330,7 +1330,7 @@ package body Grt.Signals is -- Note: bit and boolean are both mode_b2. Res := Create_Signal (Mode_B2, Value_Union'(Mode => Mode_B2, B2 => True), - Mode, Null_Address, Null_Address); + Mode, null, Null_Address); Last_Implicit_Signal := Res; @@ -1400,7 +1400,7 @@ package body Grt.Signals is (To_Ghdl_Rti_Access (Guard_Rti'Address)); Res := Create_Signal (Mode_B2, Value_Union'(Mode => Mode_B2, B2 => Proc.all (This)), - Mode_Guard, Null_Address, Null_Address); + Mode_Guard, null, Null_Address); Res.S.Guard_Func := Proc; Res.S.Guard_Instance := This; Last_Implicit_Signal := Res; @@ -1420,7 +1420,7 @@ package body Grt.Signals is Res : Ghdl_Signal_Ptr; begin Res := Create_Signal (Sig.Mode, Sig.Value, - Mode_Delayed, Null_Address, Null_Address); + Mode_Delayed, null, Null_Address); Res.S.Time := Val; if Val > 0 then Res.Flink := Future_List; @@ -1744,25 +1744,6 @@ package body Grt.Signals is -- return Length; -- end Get_Nbr_Non_Null_Source; - type Resolver_Acc is access procedure - (Instance : System.Address; - Val : System.Address; - Bool_Vec : System.Address; - Vec_Len : Ghdl_Index_Type; - Nbr_Drv : Ghdl_Index_Type; - Nbr_Ports : Ghdl_Index_Type); - - -- On some platforms, GNAT use a descriptor (instead of a trampoline) for - -- nested subprograms. This descriptor contains the address of the - -- subprogram and the address of the chain. An unaligned pointer to this - -- descriptor (address + 1) is then used for 'Access, and every indirect - -- call check for unaligned address. - -- - -- Disable this feature (as a resolver is never a nested subprogram), so - -- code generated by ghdl is compatible with ghdl runtimes built with - -- gnat. - pragma Convention (C, Resolver_Acc); - function To_Resolver_Acc is new Ada.Unchecked_Conversion (Source => System.Address, Target => Resolver_Acc); @@ -1811,13 +1792,12 @@ package body Grt.Signals is end if; -- Call the procedure. - To_Resolver_Acc (Resolv.Resolv_Proc).all - (Resolv.Resolv_Inst, - Resolv.Resolv_Ptr, - Vec'Address, - Length, - Sig.S.Nbr_Drivers, - Sig.Nbr_Ports); + Resolv.Resolv_Proc.all (Resolv.Resolv_Inst, + Resolv.Resolv_Ptr, + Vec'Address, + Length, + Sig.S.Nbr_Drivers, + Sig.Nbr_Ports); end Compute_Resolved_Signal; type Conversion_Func_Acc is access procedure (Instance : System.Address); @@ -2559,8 +2539,9 @@ package body Grt.Signals is if Resolv /= null and then Resolv.Sig_Range.First = I and then Resolv.Sig_Range.Last = I - and then (Resolv.Resolv_Proc - = Ieee_Std_Logic_1164_Resolved_Resolv_Ptr) + and then + (Resolv.Resolv_Proc + = To_Resolver_Acc (Ieee_Std_Logic_1164_Resolved_Resolv_Ptr)) and then Sig.S.Nbr_Drivers + Sig.Nbr_Ports <= 1 then -- Optimization: remove resolver if there is at most one diff --git a/translate/grt/grt-signals.ads b/translate/grt/grt-signals.ads index 4d24639fc..d61dee3db 100644 --- a/translate/grt/grt-signals.ads +++ b/translate/grt/grt-signals.ads @@ -126,10 +126,38 @@ package Grt.Signals is end case; end record; + -- Resolution function. + -- There is a wrapper around resolution functions to simplify the call + -- from GRT. + -- INSTANCE is the opaque parameter given when the resolver is + -- registers (RESOLV_INST). + -- VAL is the signal (which may be composite). + -- BOOL_VEC is an array of NBR_DRV booleans (bytes) and indicates + -- non-null drivers. There are VEC_LEN non-null drivers. So the number + -- of values is VEC_LEN + NBR_PORTS. This number of values is the length + -- of the array for the resolution function. + type Resolver_Acc is access procedure + (Instance : System.Address; + Val : System.Address; + Bool_Vec : System.Address; + Vec_Len : Ghdl_Index_Type; + Nbr_Drv : Ghdl_Index_Type; + Nbr_Ports : Ghdl_Index_Type); + + -- On some platforms, GNAT use a descriptor (instead of a trampoline) for + -- nested subprograms. This descriptor contains the address of the + -- subprogram and the address of the chain. An unaligned pointer to this + -- descriptor (address + 1) is then used for 'Access, and every indirect + -- call check for unaligned address. + -- + -- Disable this feature (as a resolver is never a nested subprogram), so + -- code generated by ghdl is compatible with ghdl runtimes built with + -- gnat. + pragma Convention (C, Resolver_Acc); -- How to compute resolved signal. type Resolved_Signal_Type is record - Resolv_Proc : System.Address; + Resolv_Proc : Resolver_Acc; Resolv_Inst : System.Address; Resolv_Ptr : System.Address; Sig_Range : Sig_Table_Range; @@ -494,7 +522,7 @@ package Grt.Signals is function Ghdl_Signal_Driving (Sig : Ghdl_Signal_Ptr) return Ghdl_B2; function Ghdl_Create_Signal_B2 (Init_Val : Ghdl_B2; - Resolv_Func : System.Address; + Resolv_Func : Resolver_Acc; Resolv_Inst : System.Address) return Ghdl_Signal_Ptr; procedure Ghdl_Signal_Init_B2 (Sig : Ghdl_Signal_Ptr; Init_Val : Ghdl_B2); @@ -512,7 +540,7 @@ package Grt.Signals is return Ghdl_B2; function Ghdl_Create_Signal_E8 (Init_Val : Ghdl_E8; - Resolv_Func : System.Address; + Resolv_Func : Resolver_Acc; Resolv_Inst : System.Address) return Ghdl_Signal_Ptr; procedure Ghdl_Signal_Init_E8 (Sig : Ghdl_Signal_Ptr; Init_Val : Ghdl_E8); @@ -530,7 +558,7 @@ package Grt.Signals is return Ghdl_E8; function Ghdl_Create_Signal_E32 (Init_Val : Ghdl_E32; - Resolv_Func : System.Address; + Resolv_Func : Resolver_Acc; Resolv_Inst : System.Address) return Ghdl_Signal_Ptr; procedure Ghdl_Signal_Init_E32 (Sig : Ghdl_Signal_Ptr; Init_Val : Ghdl_E32); @@ -548,7 +576,7 @@ package Grt.Signals is return Ghdl_E32; function Ghdl_Create_Signal_I32 (Init_Val : Ghdl_I32; - Resolv_Func : System.Address; + Resolv_Func : Resolver_Acc; Resolv_Inst : System.Address) return Ghdl_Signal_Ptr; procedure Ghdl_Signal_Init_I32 (Sig : Ghdl_Signal_Ptr; Init_Val : Ghdl_I32); @@ -566,7 +594,7 @@ package Grt.Signals is return Ghdl_I32; function Ghdl_Create_Signal_I64 (Init_Val : Ghdl_I64; - Resolv_Func : System.Address; + Resolv_Func : Resolver_Acc; Resolv_Inst : System.Address) return Ghdl_Signal_Ptr; procedure Ghdl_Signal_Init_I64 (Sig : Ghdl_Signal_Ptr; Init_Val : Ghdl_I64); @@ -584,7 +612,7 @@ package Grt.Signals is return Ghdl_I64; function Ghdl_Create_Signal_F64 (Init_Val : Ghdl_F64; - Resolv_Func : System.Address; + Resolv_Func : Resolver_Acc; Resolv_Inst : System.Address) return Ghdl_Signal_Ptr; procedure Ghdl_Signal_Init_F64 (Sig : Ghdl_Signal_Ptr; Init_Val : Ghdl_F64); @@ -627,8 +655,8 @@ package Grt.Signals is Dst : Ghdl_Signal_Ptr; Dst_Len : Ghdl_Index_Type); - -- Mark the next signals as resolved. - procedure Ghdl_Signal_Create_Resolution (Proc : System.Address; + -- Mark the next (and not yet created) NBR_SIG signals as resolved. + procedure Ghdl_Signal_Create_Resolution (Proc : Resolver_Acc; Instance : System.Address; Sig : System.Address; Nbr_Sig : Ghdl_Index_Type); @@ -667,6 +695,8 @@ package Grt.Signals is function Ghdl_Signal_Get_Nbr_Drivers (Sig : Ghdl_Signal_Ptr) return Ghdl_Index_Type; + -- Read a source (port or driver) from a signal. This is used by + -- resolution functions. function Ghdl_Signal_Read_Port (Sig : Ghdl_Signal_Ptr; Index : Ghdl_Index_Type) return Ghdl_Value_Ptr; |