aboutsummaryrefslogtreecommitdiffstats
path: root/src/simul/simul-vhdl_simul.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-12-26 17:31:38 +0100
committerTristan Gingold <tgingold@free.fr>2022-12-26 17:33:38 +0100
commit0f348cb94e9f7bd83f52c0317bb7f858b87ece05 (patch)
treea2305ebc04b749ca2ff6d28bee393b2e5def2475 /src/simul/simul-vhdl_simul.adb
parentb458a7644447bb440ce4be6aa8458c71d54d8044 (diff)
downloadghdl-0f348cb94e9f7bd83f52c0317bb7f858b87ece05.tar.gz
ghdl-0f348cb94e9f7bd83f52c0317bb7f858b87ece05.tar.bz2
ghdl-0f348cb94e9f7bd83f52c0317bb7f858b87ece05.zip
simul: handle driving and driving_value attributes
Diffstat (limited to 'src/simul/simul-vhdl_simul.adb')
-rw-r--r--src/simul/simul-vhdl_simul.adb45
1 files changed, 39 insertions, 6 deletions
diff --git a/src/simul/simul-vhdl_simul.adb b/src/simul/simul-vhdl_simul.adb
index 8ee08d1a0..354ca062f 100644
--- a/src/simul/simul-vhdl_simul.adb
+++ b/src/simul/simul-vhdl_simul.adb
@@ -446,6 +446,9 @@ package body Simul.Vhdl_Simul is
and then Pfx.Obj.Val.Kind = Value_Signal);
E := Read_Signal_Flag
((Pfx.Targ_Type, Get_Sig_Mem (Pfx.Obj.Val, Pfx.Off.Net_Off)), Kind);
+ if Kind = Read_Signal_Not_Driving then
+ E := not E;
+ end if;
Res := Create_Value_Memory (Boolean_Type, Expr_Pool'Access);
Write_U8 (Res.Val.Mem, Boolean'Pos (E));
return Res;
@@ -463,6 +466,12 @@ package body Simul.Vhdl_Simul is
return Exec_Signal_Flag_Attribute (Inst, Expr, Read_Signal_Active);
end Exec_Active_Attribute;
+ function Exec_Driving_Attribute (Inst : Synth_Instance_Acc;
+ Expr : Node) return Valtyp is
+ begin
+ return Exec_Signal_Flag_Attribute (Inst, Expr, Read_Signal_Not_Driving);
+ end Exec_Driving_Attribute;
+
function Exec_Dot_Attribute (Inst : Synth_Instance_Acc;
Expr : Node) return Valtyp
is
@@ -2123,10 +2132,10 @@ package body Simul.Vhdl_Simul is
-- For conversion functions.
Read_Signal_Driving_Value,
- Read_Signal_Effective_Value --,
+ Read_Signal_Effective_Value,
-- 'Driving_Value
--- Read_Signal_Driver_Value
+ Read_Signal_Driver_Value
);
procedure Exec_Read_Signal (Sig: Memory_Ptr;
@@ -2145,6 +2154,8 @@ package body Simul.Vhdl_Simul is
Write_Ghdl_Value (Val, S.Value_Ptr.all);
when Read_Signal_Last_Value =>
Write_Ghdl_Value (Val, S.Last_Value);
+ when Read_Signal_Driver_Value =>
+ Write_Ghdl_Value (Val, Ghdl_Signal_Driving_Value (S));
end case;
when Type_Vector
| Type_Array =>
@@ -2174,24 +2185,38 @@ package body Simul.Vhdl_Simul is
end case;
end Exec_Read_Signal;
- function Exec_Last_Value_Attribute (Inst : Synth_Instance_Acc;
- Expr : Node) return Valtyp
+ function Exec_Signal_Value_Attribute (Inst : Synth_Instance_Acc;
+ Attr : Node;
+ Kind : Read_Signal_Enum) return Valtyp
is
Pfx : Target_Info;
Res : Valtyp;
S : Memory_Ptr;
begin
- Pfx := Synth_Target (Inst, Get_Prefix (Expr));
+ Pfx := Synth_Target (Inst, Get_Prefix (Attr));
Res := Create_Value_Memory (Pfx.Targ_Type, Expr_Pool'Access);
S := Sig_Index (Signals_Table.Table (Pfx.Obj.Val.S).Sig,
Pfx.Off.Net_Off);
- Exec_Read_Signal (S, Get_Memtyp (Res), Read_Signal_Last_Value);
+ Exec_Read_Signal (S, Get_Memtyp (Res), Kind);
return Res;
+ end Exec_Signal_Value_Attribute;
+
+ function Exec_Last_Value_Attribute (Inst : Synth_Instance_Acc;
+ Expr : Node) return Valtyp is
+ begin
+ return Exec_Signal_Value_Attribute (Inst, Expr, Read_Signal_Last_Value);
end Exec_Last_Value_Attribute;
+ function Exec_Driving_Value_Attribute (Inst : Synth_Instance_Acc;
+ Expr : Node) return Valtyp is
+ begin
+ return Exec_Signal_Value_Attribute
+ (Inst, Expr, Read_Signal_Driver_Value);
+ end Exec_Driving_Value_Attribute;
+
type Read_Signal_Last_Enum is
(
Read_Signal_Last_Event,
@@ -2269,6 +2294,11 @@ package body Simul.Vhdl_Simul is
Pfx.Off.Net_Off);
T := Exec_Read_Signal_Last (S, Get_Memtyp (Res), Attr);
+ if T < 0 then
+ T := Std_Time'Last;
+ else
+ T := Current_Time - T;
+ end if;
Write_I64 (Res.Val.Mem, Ghdl_I64 (T));
return Res;
end Exec_Signal_Last_Attribute;
@@ -3751,6 +3781,9 @@ package body Simul.Vhdl_Simul is
Synth.Vhdl_Expr.Hook_Signal_Expr := Hook_Signal_Expr'Access;
Synth.Vhdl_Expr.Hook_Event_Attribute := Exec_Event_Attribute'Access;
Synth.Vhdl_Expr.Hook_Active_Attribute := Exec_Active_Attribute'Access;
+ Synth.Vhdl_Expr.Hook_Driving_Attribute := Exec_Driving_Attribute'Access;
+ Synth.Vhdl_Expr.Hook_Driving_Value_Attribute :=
+ Exec_Driving_Value_Attribute'Access;
Synth.Vhdl_Expr.Hook_Last_Value_Attribute :=
Exec_Last_Value_Attribute'Access;
Synth.Vhdl_Expr.Hook_Last_Event_Attribute :=