From 8277f9c4a938c84558fd5d234e2707bd88afb770 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Wed, 20 Jul 2022 19:43:00 +0200 Subject: grt: add real now variable. --- src/grt/grt-options.adb | 8 ++++++++ src/grt/grt-options.ads | 4 ++++ src/grt/grt-vhdl_types.ads | 4 ++++ 3 files changed, 16 insertions(+) (limited to 'src/grt') diff --git a/src/grt/grt-options.adb b/src/grt/grt-options.adb index bf29c1a5e..2b07278b1 100644 --- a/src/grt/grt-options.adb +++ b/src/grt/grt-options.adb @@ -49,6 +49,14 @@ package body Grt.Options is when others => Error ("unhandled time resolution"); end case; + + -- For AMS. + -- (Don't use **, as it requires the runtime). + Time_Real_To_Phys := 1.0; + for I in 1 .. Time_Resolution_Scale loop + Time_Real_To_Phys := Time_Real_To_Phys * 1000.0; + end loop; + Time_Phys_To_Real := 1.0 / Time_Real_To_Phys; end Set_Time_Resolution; procedure Help diff --git a/src/grt/grt-options.ads b/src/grt/grt-options.ads index fa29cc85f..d9ea57bc5 100644 --- a/src/grt/grt-options.ads +++ b/src/grt/grt-options.ads @@ -64,6 +64,10 @@ package Grt.Options is subtype Natural_Time_Scale is Natural range 0 .. 5; Time_Resolution_Scale : Natural_Time_Scale; + -- For AMS, conversion factors. + Time_Phys_To_Real : Ghdl_F64; + Time_Real_To_Phys : Ghdl_F64; + -- Set Time_Resolution_Scale from Flag_String. procedure Set_Time_Resolution; diff --git a/src/grt/grt-vhdl_types.ads b/src/grt/grt-vhdl_types.ads index 42db6b9dd..34366161e 100644 --- a/src/grt/grt-vhdl_types.ads +++ b/src/grt/grt-vhdl_types.ads @@ -158,6 +158,10 @@ package Grt.Vhdl_Types is Current_Time : Std_Time; -- The current delta cycle number. Current_Delta : Integer; + + -- For AMS + Current_Time_AMS : Ghdl_F64; private pragma Export (C, Current_Time, "__ghdl_now"); + pragma Export (C, Current_Time_AMS, "__ghdl_now_ams"); end Grt.Vhdl_Types; -- cgit v1.2.3