diff options
author | Tristan Gingold <tgingold@free.fr> | 2017-04-27 04:45:49 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2017-05-09 21:16:25 +0200 |
commit | c00e693a478890068c90804e0e64d79f14f5c2aa (patch) | |
tree | c1934ca103d954124a74d379b8e61e9ada8fdffd /src/grt | |
parent | 47b7ace6a702830d33fb1a26bc49e9362147aa4b (diff) | |
download | ghdl-c00e693a478890068c90804e0e64d79f14f5c2aa.tar.gz ghdl-c00e693a478890068c90804e0e64d79f14f5c2aa.tar.bz2 ghdl-c00e693a478890068c90804e0e64d79f14f5c2aa.zip |
Create default value for ports.
Fix #328
Diffstat (limited to 'src/grt')
-rw-r--r-- | src/grt/grt-signals.adb | 82 | ||||
-rw-r--r-- | src/grt/grt-signals.ads | 24 |
2 files changed, 96 insertions, 10 deletions
diff --git a/src/grt/grt-signals.adb b/src/grt/grt-signals.adb index e5afe588a..a681e1360 100644 --- a/src/grt/grt-signals.adb +++ b/src/grt/grt-signals.adb @@ -289,7 +289,6 @@ package body Grt.Signals is procedure Ghdl_Signal_Init (Sig : Ghdl_Signal_Ptr; Val : Value_Union) is begin - Assign (Sig.Value_Ptr, Val, Sig.Mode); Sig.Driving_Value := Val; Sig.Last_Value := Val; end Ghdl_Signal_Init; @@ -297,9 +296,8 @@ package body Grt.Signals is procedure Ghdl_Signal_Merge_Rti (Sig : Ghdl_Signal_Ptr; Rti : Ghdl_Rti_Access) is - S_Rti : Ghdl_Rtin_Object_Acc; + S_Rti : constant Ghdl_Rtin_Object_Acc := To_Ghdl_Rtin_Object_Acc (Rti); begin - S_Rti := To_Ghdl_Rtin_Object_Acc (Rti); if Flag_Activity = Activity_Minimal then if (S_Rti.Common.Mode and Ghdl_Rti_Signal_Has_Active) /= 0 then Sig.Has_Active := True; @@ -409,6 +407,21 @@ package body Grt.Signals is end if; end Ghdl_Process_Add_Driver; + procedure Ghdl_Process_Add_Port_Driver + (Sign : Ghdl_Signal_Ptr; Val : Value_Union) + is + Trans : Transaction_Acc; + begin + Trans := new Transaction'(Kind => Trans_Value, + Line => 0, + Time => 0, + Next => null, + Val => Val); + if Ghdl_Signal_Add_Driver (Sign, Trans) then + Free (Trans); + end if; + end Ghdl_Process_Add_Port_Driver; + procedure Ghdl_Signal_Add_Direct_Driver (Sign : Ghdl_Signal_Ptr; Drv : Ghdl_Value_Ptr) is @@ -420,7 +433,7 @@ package body Grt.Signals is Line => 0, Time => 0, Next => null, - Val => Read_Value (Sign.Value_Ptr, Sign.Mode)); + Val => Read_Value (Drv, Sign.Mode)); if Ghdl_Signal_Add_Driver (Sign, Trans) then Free (Trans); return; @@ -433,9 +446,6 @@ package body Grt.Signals is Val_Ptr => Drv); Sign.S.Drivers (Sign.S.Nbr_Drivers - 1).Last_Trans := Trans1; Trans.Next := Trans1; - - -- Initialize driver value. - Assign (Drv, Sign.Value_Ptr, Sign.Mode); end Ghdl_Signal_Add_Direct_Driver; procedure Append_Port (Targ : Ghdl_Signal_Ptr; Src : Ghdl_Signal_Ptr) @@ -975,6 +985,13 @@ package body Grt.Signals is Ghdl_Signal_Associate (Sig, Value_Union'(Mode => Mode_B1, B1 => Val)); end Ghdl_Signal_Associate_B1; + procedure Ghdl_Signal_Add_Port_Driver_B1 + (Sig : Ghdl_Signal_Ptr; Val : Ghdl_B1) is + begin + Ghdl_Process_Add_Port_Driver + (Sig, Value_Union'(Mode => Mode_B1, B1 => Val)); + end Ghdl_Signal_Add_Port_Driver_B1; + procedure Ghdl_Signal_Simple_Assign_B1 (Sign : Ghdl_Signal_Ptr; Val : Ghdl_B1) is @@ -1044,6 +1061,13 @@ package body Grt.Signals is Ghdl_Signal_Associate (Sig, Value_Union'(Mode => Mode_E8, E8 => Val)); end Ghdl_Signal_Associate_E8; + procedure Ghdl_Signal_Add_Port_Driver_E8 + (Sig : Ghdl_Signal_Ptr; Val : Ghdl_E8) is + begin + Ghdl_Process_Add_Port_Driver + (Sig, Value_Union'(Mode => Mode_E8, E8 => Val)); + end Ghdl_Signal_Add_Port_Driver_E8; + procedure Ghdl_Signal_Simple_Assign_E8 (Sign : Ghdl_Signal_Ptr; Val : Ghdl_E8) is @@ -1115,6 +1139,13 @@ package body Grt.Signals is Ghdl_Signal_Associate (Sig, Value_Union'(Mode => Mode_E32, E32 => Val)); end Ghdl_Signal_Associate_E32; + procedure Ghdl_Signal_Add_Port_Driver_E32 + (Sig : Ghdl_Signal_Ptr; Val : Ghdl_E32) is + begin + Ghdl_Process_Add_Port_Driver + (Sig, Value_Union'(Mode => Mode_E32, E32 => Val)); + end Ghdl_Signal_Add_Port_Driver_E32; + procedure Ghdl_Signal_Simple_Assign_E32 (Sign : Ghdl_Signal_Ptr; Val : Ghdl_E32) is @@ -1186,6 +1217,13 @@ package body Grt.Signals is Ghdl_Signal_Associate (Sig, Value_Union'(Mode => Mode_I32, I32 => Val)); end Ghdl_Signal_Associate_I32; + procedure Ghdl_Signal_Add_Port_Driver_I32 + (Sig : Ghdl_Signal_Ptr; Val : Ghdl_I32) is + begin + Ghdl_Process_Add_Port_Driver + (Sig, Value_Union'(Mode => Mode_I32, I32 => Val)); + end Ghdl_Signal_Add_Port_Driver_I32; + procedure Ghdl_Signal_Simple_Assign_I32 (Sign : Ghdl_Signal_Ptr; Val : Ghdl_I32) is @@ -1257,6 +1295,13 @@ package body Grt.Signals is Ghdl_Signal_Associate (Sig, Value_Union'(Mode => Mode_I64, I64 => Val)); end Ghdl_Signal_Associate_I64; + procedure Ghdl_Signal_Add_Port_Driver_I64 + (Sig : Ghdl_Signal_Ptr; Val : Ghdl_I64) is + begin + Ghdl_Process_Add_Port_Driver + (Sig, Value_Union'(Mode => Mode_I64, I64 => Val)); + end Ghdl_Signal_Add_Port_Driver_I64; + procedure Ghdl_Signal_Simple_Assign_I64 (Sign : Ghdl_Signal_Ptr; Val : Ghdl_I64) is @@ -1328,6 +1373,13 @@ package body Grt.Signals is Ghdl_Signal_Associate (Sig, Value_Union'(Mode => Mode_F64, F64 => Val)); end Ghdl_Signal_Associate_F64; + procedure Ghdl_Signal_Add_Port_Driver_F64 + (Sig : Ghdl_Signal_Ptr; Val : Ghdl_F64) is + begin + Ghdl_Process_Add_Port_Driver + (Sig, Value_Union'(Mode => Mode_F64, F64 => Val)); + end Ghdl_Signal_Add_Port_Driver_F64; + procedure Ghdl_Signal_Simple_Assign_F64 (Sign : Ghdl_Signal_Ptr; Val : Ghdl_F64) is @@ -3478,6 +3530,13 @@ package body Grt.Signals is end loop; end Run_Propagation_Init; + -- LRM93 12.6.4 The simulation cycle + -- The initialization phase consists of the following steps: + -- - The driving value and the effective value of each explicitly + -- declared signal are computed, and the current value of the signal + -- is set to the effective value. This value is assumed to have been + -- the value of the signal for an infinite length of time prior to + -- the start of the simulation. procedure Init_Signals is Sig : Ghdl_Signal_Ptr; @@ -3488,8 +3547,11 @@ package body Grt.Signals is case Sig.Net is when Net_One_Driver | Net_One_Direct => - -- Nothing to do: drivers were already created. - null; + -- Use the current value of the transaction for the current + -- value of the signal. + Assign (Sig.Driving_Value, + Sig.S.Drivers (0).First_Trans.Val, Sig.Mode); + Assign (Sig.Value_Ptr, Sig.Driving_Value, Sig.Mode); when Net_One_Resolved => Sig.Has_Active := True; @@ -3499,7 +3561,7 @@ package body Grt.Signals is end if; when No_Signal_Net => - null; + Assign (Sig.Value_Ptr, Sig.Driving_Value, Sig.Mode); when others => if Propagation.Table (Sig.Net).Updated then diff --git a/src/grt/grt-signals.ads b/src/grt/grt-signals.ads index eaecdd0be..1c27789c6 100644 --- a/src/grt/grt-signals.ads +++ b/src/grt/grt-signals.ads @@ -585,6 +585,8 @@ package Grt.Signals is procedure Ghdl_Signal_Next_Assign_B1 (Sign : Ghdl_Signal_Ptr; Val : Ghdl_B1; After : Std_Time); + procedure Ghdl_Signal_Add_Port_Driver_B1 (Sig : Ghdl_Signal_Ptr; + Val : Ghdl_B1); function Ghdl_Signal_Driving_Value_B1 (Sig : Ghdl_Signal_Ptr) return Ghdl_B1; procedure Ghdl_Signal_Force_Driving_B1 (Sig : Ghdl_Signal_Ptr; @@ -607,6 +609,8 @@ package Grt.Signals is procedure Ghdl_Signal_Next_Assign_E8 (Sign : Ghdl_Signal_Ptr; Val : Ghdl_E8; After : Std_Time); + procedure Ghdl_Signal_Add_Port_Driver_E8 (Sig : Ghdl_Signal_Ptr; + Val : Ghdl_E8); function Ghdl_Signal_Driving_Value_E8 (Sig : Ghdl_Signal_Ptr) return Ghdl_E8; procedure Ghdl_Signal_Force_Driving_E8 (Sig : Ghdl_Signal_Ptr; @@ -629,6 +633,8 @@ package Grt.Signals is procedure Ghdl_Signal_Next_Assign_E32 (Sign : Ghdl_Signal_Ptr; Val : Ghdl_E32; After : Std_Time); + procedure Ghdl_Signal_Add_Port_Driver_E32 (Sig : Ghdl_Signal_Ptr; + Val : Ghdl_E32); function Ghdl_Signal_Driving_Value_E32 (Sig : Ghdl_Signal_Ptr) return Ghdl_E32; @@ -647,6 +653,8 @@ package Grt.Signals is procedure Ghdl_Signal_Next_Assign_I32 (Sign : Ghdl_Signal_Ptr; Val : Ghdl_I32; After : Std_Time); + procedure Ghdl_Signal_Add_Port_Driver_I32 (Sig : Ghdl_Signal_Ptr; + Val : Ghdl_I32); function Ghdl_Signal_Driving_Value_I32 (Sig : Ghdl_Signal_Ptr) return Ghdl_I32; @@ -665,6 +673,8 @@ package Grt.Signals is procedure Ghdl_Signal_Next_Assign_I64 (Sign : Ghdl_Signal_Ptr; Val : Ghdl_I64; After : Std_Time); + procedure Ghdl_Signal_Add_Port_Driver_I64 (Sig : Ghdl_Signal_Ptr; + Val : Ghdl_I64); function Ghdl_Signal_Driving_Value_I64 (Sig : Ghdl_Signal_Ptr) return Ghdl_I64; @@ -683,6 +693,8 @@ package Grt.Signals is procedure Ghdl_Signal_Next_Assign_F64 (Sign : Ghdl_Signal_Ptr; Val : Ghdl_F64; After : Std_Time); + procedure Ghdl_Signal_Add_Port_Driver_F64 (Sig : Ghdl_Signal_Ptr; + Val : Ghdl_F64); function Ghdl_Signal_Driving_Value_F64 (Sig : Ghdl_Signal_Ptr) return Ghdl_F64; @@ -827,6 +839,8 @@ private "__ghdl_signal_start_assign_b1"); pragma Export (Ada, Ghdl_Signal_Next_Assign_B1, "__ghdl_signal_next_assign_b1"); + pragma Export (Ada, Ghdl_Signal_Add_Port_Driver_B1, + "__ghdl_signal_add_port_driver_b1"); pragma Export (Ada, Ghdl_Signal_Driving_Value_B1, "__ghdl_signal_driving_value_b1"); @@ -842,6 +856,8 @@ private "__ghdl_signal_start_assign_e8"); pragma Export (C, Ghdl_Signal_Next_Assign_E8, "__ghdl_signal_next_assign_e8"); + pragma Export (C, Ghdl_Signal_Add_Port_Driver_E8, + "__ghdl_signal_add_port_driver_e8"); pragma Export (C, Ghdl_Signal_Driving_Value_E8, "__ghdl_signal_driving_value_e8"); @@ -857,6 +873,8 @@ private "__ghdl_signal_start_assign_e32"); pragma Export (C, Ghdl_Signal_Next_Assign_E32, "__ghdl_signal_next_assign_e32"); + pragma Export (C, Ghdl_Signal_Add_Port_Driver_E32, + "__ghdl_signal_add_port_driver_e32"); pragma Export (C, Ghdl_Signal_Driving_Value_E32, "__ghdl_signal_driving_value_e32"); @@ -872,6 +890,8 @@ private "__ghdl_signal_start_assign_i32"); pragma Export (C, Ghdl_Signal_Next_Assign_I32, "__ghdl_signal_next_assign_i32"); + pragma Export (C, Ghdl_Signal_Add_Port_Driver_I32, + "__ghdl_signal_add_port_driver_i32"); pragma Export (C, Ghdl_Signal_Driving_Value_I32, "__ghdl_signal_driving_value_i32"); @@ -887,6 +907,8 @@ private "__ghdl_signal_start_assign_i64"); pragma Export (C, Ghdl_Signal_Next_Assign_I64, "__ghdl_signal_next_assign_i64"); + pragma Export (C, Ghdl_Signal_Add_Port_Driver_I64, + "__ghdl_signal_add_port_driver_i64"); pragma Export (C, Ghdl_Signal_Driving_Value_I64, "__ghdl_signal_driving_value_i64"); @@ -902,6 +924,8 @@ private "__ghdl_signal_start_assign_f64"); pragma Export (C, Ghdl_Signal_Next_Assign_F64, "__ghdl_signal_next_assign_f64"); + pragma Export (C, Ghdl_Signal_Add_Port_Driver_F64, + "__ghdl_signal_add_port_driver_f64"); pragma Export (C, Ghdl_Signal_Driving_Value_F64, "__ghdl_signal_driving_value_f64"); |