aboutsummaryrefslogtreecommitdiffstats
path: root/src/simul/simul-vhdl_simul.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-09-28 07:41:07 +0200
committerTristan Gingold <tgingold@free.fr>2022-09-28 07:41:07 +0200
commitfe07ef095be4c8bc0e1f6e6d8eb94692c27445c7 (patch)
tree573746d8b6418e3ba7d8c1869085bcb03f24c014 /src/simul/simul-vhdl_simul.adb
parent8c367d78bc621b9f339042f5d456da94dd0b7861 (diff)
downloadghdl-fe07ef095be4c8bc0e1f6e6d8eb94692c27445c7.tar.gz
ghdl-fe07ef095be4c8bc0e1f6e6d8eb94692c27445c7.tar.bz2
ghdl-fe07ef095be4c8bc0e1f6e6d8eb94692c27445c7.zip
simul: handle last_value attribute
Diffstat (limited to 'src/simul/simul-vhdl_simul.adb')
-rw-r--r--src/simul/simul-vhdl_simul.adb24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/simul/simul-vhdl_simul.adb b/src/simul/simul-vhdl_simul.adb
index cba9520c4..6b78d4ab8 100644
--- a/src/simul/simul-vhdl_simul.adb
+++ b/src/simul/simul-vhdl_simul.adb
@@ -1905,7 +1905,7 @@ package body Simul.Vhdl_Simul is
type Read_Signal_Enum is
(
--- Read_Signal_Last_Value,
+ Read_Signal_Last_Value,
-- For conversion functions.
Read_Signal_Driving_Value,
@@ -1932,6 +1932,8 @@ package body Simul.Vhdl_Simul is
Write_Ghdl_Value (Val, S.Driving_Value);
when Read_Signal_Effective_Value =>
Write_Ghdl_Value (Val, S.Value_Ptr.all);
+ when Read_Signal_Last_Value =>
+ Write_Ghdl_Value (Val, S.Last_Value);
end case;
when Type_Vector
| Type_Array =>
@@ -1961,6 +1963,24 @@ 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
+ is
+ Pfx : Target_Info;
+ Res : Valtyp;
+ S : Memory_Ptr;
+ begin
+ Pfx := Synth_Target (Inst, Get_Prefix (Expr));
+
+ 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);
+ return Res;
+ end Exec_Last_Value_Attribute;
+
type Write_Signal_Enum is
(Write_Signal_Driving_Value,
Write_Signal_Effective_Value);
@@ -3198,6 +3218,8 @@ 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_Last_Value_Attribute :=
+ Exec_Last_Value_Attribute'Access;
Synth.Vhdl_Oper.Hook_Bit_Rising_Edge := Exec_Bit_Rising_Edge'Access;
Synth.Vhdl_Oper.Hook_Bit_Falling_Edge := Exec_Bit_Falling_Edge'Access;