diff options
author | Tristan Gingold <tgingold@free.fr> | 2018-12-16 08:03:37 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2018-12-16 14:07:04 +0100 |
commit | 42e2e02a5f0d0e305561b44984a41391b04c157d (patch) | |
tree | 6d5ff943da0e064f41cdecb0214942bbd9978bac | |
parent | b268324b35da6e949c610e9cc3feb56596a8e17b (diff) | |
download | ghdl-42e2e02a5f0d0e305561b44984a41391b04c157d.tar.gz ghdl-42e2e02a5f0d0e305561b44984a41391b04c157d.tar.bz2 ghdl-42e2e02a5f0d0e305561b44984a41391b04c157d.zip |
Extract grt.astdio.vhdl from grt.astdio.
-rw-r--r-- | src/grt/grt-astdio-vhdl.adb | 86 | ||||
-rw-r--r-- | src/grt/grt-astdio-vhdl.ads | 38 | ||||
-rw-r--r-- | src/grt/grt-astdio.adb | 59 | ||||
-rw-r--r-- | src/grt/grt-astdio.ads | 10 | ||||
-rw-r--r-- | src/grt/grt-disp.adb | 1 | ||||
-rw-r--r-- | src/grt/grt-disp_rti.adb | 1 | ||||
-rw-r--r-- | src/grt/grt-disp_signals.adb | 1 | ||||
-rw-r--r-- | src/grt/grt-errors.adb | 1 | ||||
-rw-r--r-- | src/grt/grt-processes.adb | 1 | ||||
-rw-r--r-- | src/grt/grt-vpi.adb | 1 | ||||
-rw-r--r-- | src/vhdl/simulate/simul-debugger.adb | 1 | ||||
-rw-r--r-- | src/vhdl/simulate/simul-execution.adb | 4 |
12 files changed, 133 insertions, 71 deletions
diff --git a/src/grt/grt-astdio-vhdl.adb b/src/grt/grt-astdio-vhdl.adb new file mode 100644 index 000000000..fdc592bdd --- /dev/null +++ b/src/grt/grt-astdio-vhdl.adb @@ -0,0 +1,86 @@ +-- GHDL Run Time (GRT) stdio subprograms for GRT types. +-- Copyright (C) 2002 - 2014 Tristan Gingold +-- +-- GHDL is free software; you can redistribute it and/or modify it under +-- the terms of the GNU General Public License as published by the Free +-- Software Foundation; either version 2, or (at your option) any later +-- version. +-- +-- GHDL is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or +-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +-- for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with GCC; see the file COPYING. If not, write to the Free +-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA +-- 02111-1307, USA. +-- +-- As a special exception, if other files instantiate generics from this +-- unit, or you link this unit with other files to produce an executable, +-- this unit does not by itself cause the resulting executable to be +-- covered by the GNU General Public License. This exception does not +-- however invalidate any other reasons why the executable file might be +-- covered by the GNU Public License. +with Grt.Options; + +package body Grt.Astdio.Vhdl is + procedure Put_Str_Len (Stream : FILEs; Str : Ghdl_Str_Len_Type) + is + S : String (1 .. 3); + begin + if Str.Str = null then + S (1) := '''; + S (2) := Character'Val (Str.Len); + S (3) := '''; + Put (Stream, S); + else + Put (Stream, Str.Str (1 .. Str.Len)); + end if; + end Put_Str_Len; + + procedure Put_Dir (Stream : FILEs; Dir : Ghdl_Dir_Type) is + begin + case Dir is + when Dir_To => + Put (Stream, " to "); + when Dir_Downto => + Put (Stream, " downto "); + end case; + end Put_Dir; + + procedure Put_Time (Stream : FILEs; Time : Std_Time) + is + use Grt.Options; + Unit : Natural_Time_Scale; + T : Std_Time; + begin + if Time = Std_Time'First then + Put (Stream, "-Inf"); + else + -- Do not bother with sec, min, and hr. + Unit := Time_Resolution_Scale; + T := Time; + while Unit > 1 and then (T mod 1_000) = 0 loop + T := T / 1000; + Unit := Unit - 1; + end loop; + Put_I64 (Stream, Ghdl_I64 (T)); + case Unit is + when 0 => + Put (Stream, "sec"); + when 1 => + Put (Stream, "ms"); + when 2 => + Put (Stream, "us"); + when 3 => + Put (Stream, "ns"); + when 4 => + Put (Stream, "ps"); + when 5 => + Put (Stream, "fs"); + end case; + end if; + end Put_Time; + +end Grt.Astdio.Vhdl; diff --git a/src/grt/grt-astdio-vhdl.ads b/src/grt/grt-astdio-vhdl.ads new file mode 100644 index 000000000..e6b20b925 --- /dev/null +++ b/src/grt/grt-astdio-vhdl.ads @@ -0,0 +1,38 @@ +-- GHDL Run Time (GRT) stdio subprograms for GRT types. +-- Copyright (C) 2002 - 2014 Tristan Gingold +-- +-- GHDL is free software; you can redistribute it and/or modify it under +-- the terms of the GNU General Public License as published by the Free +-- Software Foundation; either version 2, or (at your option) any later +-- version. +-- +-- GHDL is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or +-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +-- for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with GCC; see the file COPYING. If not, write to the Free +-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA +-- 02111-1307, USA. +-- +-- As a special exception, if other files instantiate generics from this +-- unit, or you link this unit with other files to produce an executable, +-- this unit does not by itself cause the resulting executable to be +-- covered by the GNU General Public License. This exception does not +-- however invalidate any other reasons why the executable file might be +-- covered by the GNU Public License. + +package Grt.Astdio.Vhdl is + pragma Preelaborate (Grt.Astdio.Vhdl); + + -- Display time with unit, without space. + -- Eg: 10ns, 100ms, 97ps... + procedure Put_Time (Stream : FILEs; Time : Std_Time); + + -- Put STR using put procedures. + procedure Put_Str_Len (Stream : FILEs; Str : Ghdl_Str_Len_Type); + + -- Put " to " or " downto ". + procedure Put_Dir (Stream : FILEs; Dir : Ghdl_Dir_Type); +end Grt.Astdio.Vhdl; diff --git a/src/grt/grt-astdio.adb b/src/grt/grt-astdio.adb index 5fdcd1a64..1bd834d53 100644 --- a/src/grt/grt-astdio.adb +++ b/src/grt/grt-astdio.adb @@ -23,7 +23,6 @@ -- however invalidate any other reasons why the executable file might be -- covered by the GNU Public License. with Grt.C; use Grt.C; -with Grt.Options; package body Grt.Astdio is procedure Put (Stream : FILEs; Str : String) @@ -101,20 +100,6 @@ package body Grt.Astdio is New_Line; end Put_Line; - procedure Put_Str_Len (Stream : FILEs; Str : Ghdl_Str_Len_Type) - is - S : String (1 .. 3); - begin - if Str.Str = null then - S (1) := '''; - S (2) := Character'Val (Str.Len); - S (3) := '''; - Put (Stream, S); - else - Put (Stream, Str.Str (1 .. Str.Len)); - end if; - end Put_Str_Len; - generic type Ntype is range <>; Max_Len : Natural; @@ -200,48 +185,4 @@ package body Grt.Astdio is Put (Stream, Res); end Put; - procedure Put_Dir (Stream : FILEs; Dir : Ghdl_Dir_Type) is - begin - case Dir is - when Dir_To => - Put (Stream, " to "); - when Dir_Downto => - Put (Stream, " downto "); - end case; - end Put_Dir; - - procedure Put_Time (Stream : FILEs; Time : Std_Time) - is - use Grt.Options; - Unit : Natural_Time_Scale; - T : Std_Time; - begin - if Time = Std_Time'First then - Put (Stream, "-Inf"); - else - -- Do not bother with sec, min, and hr. - Unit := Time_Resolution_Scale; - T := Time; - while Unit > 1 and then (T mod 1_000) = 0 loop - T := T / 1000; - Unit := Unit - 1; - end loop; - Put_I64 (Stream, Ghdl_I64 (T)); - case Unit is - when 0 => - Put (Stream, "sec"); - when 1 => - Put (Stream, "ms"); - when 2 => - Put (Stream, "us"); - when 3 => - Put (Stream, "ns"); - when 4 => - Put (Stream, "ps"); - when 5 => - Put (Stream, "fs"); - end case; - end if; - end Put_Time; - end Grt.Astdio; diff --git a/src/grt/grt-astdio.ads b/src/grt/grt-astdio.ads index c496afe07..a465fa51e 100644 --- a/src/grt/grt-astdio.ads +++ b/src/grt/grt-astdio.ads @@ -42,20 +42,10 @@ package Grt.Astdio is procedure Put (Stream : FILEs; C : Character); procedure New_Line (Stream : FILEs); - -- Display time with unit, without space. - -- Eg: 10ns, 100ms, 97ps... - procedure Put_Time (Stream : FILEs; Time : Std_Time); - -- And on stdout. procedure Put (Str : String); procedure Put (C : Character); procedure New_Line; procedure Put_Line (Str : String); procedure Put (Str : Ghdl_C_String); - - -- Put STR using put procedures. - procedure Put_Str_Len (Stream : FILEs; Str : Ghdl_Str_Len_Type); - - -- Put " to " or " downto ". - procedure Put_Dir (Stream : FILEs; Dir : Ghdl_Dir_Type); end Grt.Astdio; diff --git a/src/grt/grt-disp.adb b/src/grt/grt-disp.adb index 36644bf1a..27abcc225 100644 --- a/src/grt/grt-disp.adb +++ b/src/grt/grt-disp.adb @@ -25,6 +25,7 @@ with System.Storage_Elements; -- Work around GNAT bug. pragma Unreferenced (System.Storage_Elements); with Grt.Astdio; use Grt.Astdio; +with Grt.Astdio.Vhdl; use Grt.Astdio.Vhdl; with Grt.Stdio; use Grt.Stdio; --with Grt.Errors; use Grt.Errors; diff --git a/src/grt/grt-disp_rti.adb b/src/grt/grt-disp_rti.adb index 177093747..7aa97d1f8 100644 --- a/src/grt/grt-disp_rti.adb +++ b/src/grt/grt-disp_rti.adb @@ -24,6 +24,7 @@ -- covered by the GNU Public License. with Grt.Astdio; use Grt.Astdio; +with Grt.Astdio.Vhdl; use Grt.Astdio.Vhdl; with Grt.Errors; use Grt.Errors; with Grt.Hooks; use Grt.Hooks; with Grt.Rtis_Utils; use Grt.Rtis_Utils; diff --git a/src/grt/grt-disp_signals.adb b/src/grt/grt-disp_signals.adb index e4dadc578..d3d095657 100644 --- a/src/grt/grt-disp_signals.adb +++ b/src/grt/grt-disp_signals.adb @@ -30,6 +30,7 @@ with Grt.Rtis; use Grt.Rtis; with Grt.Rtis_Addr; use Grt.Rtis_Addr; with Grt.Rtis_Utils; use Grt.Rtis_Utils; with Grt.Astdio; use Grt.Astdio; +with Grt.Astdio.Vhdl; use Grt.Astdio.Vhdl; with Grt.Errors; use Grt.Errors; pragma Elaborate_All (Grt.Rtis_Utils); with Grt.Vstrings; use Grt.Vstrings; diff --git a/src/grt/grt-errors.adb b/src/grt/grt-errors.adb index 11b529014..cdaf48923 100644 --- a/src/grt/grt-errors.adb +++ b/src/grt/grt-errors.adb @@ -24,6 +24,7 @@ -- covered by the GNU Public License. with Grt.Stdio; use Grt.Stdio; with Grt.Astdio; use Grt.Astdio; +with Grt.Astdio.Vhdl; use Grt.Astdio.Vhdl; with Grt.Options; use Grt.Options; with Grt.Hooks; use Grt.Hooks; with Grt.Backtraces; diff --git a/src/grt/grt-processes.adb b/src/grt/grt-processes.adb index 19998abd6..3fe7603c6 100644 --- a/src/grt/grt-processes.adb +++ b/src/grt/grt-processes.adb @@ -28,6 +28,7 @@ with System.Storage_Elements; -- Work around GNAT bug. pragma Unreferenced (System.Storage_Elements); with Grt.Disp; with Grt.Astdio; +with Grt.Astdio.Vhdl; use Grt.Astdio.Vhdl; with Grt.Errors; use Grt.Errors; with Grt.Options; with Grt.Rtis_Addr; use Grt.Rtis_Addr; diff --git a/src/grt/grt-vpi.adb b/src/grt/grt-vpi.adb index ee6a9fdf5..644b155ee 100644 --- a/src/grt/grt-vpi.adb +++ b/src/grt/grt-vpi.adb @@ -45,6 +45,7 @@ with Grt.Stdio; use Grt.Stdio; with Grt.C; use Grt.C; with Grt.Signals; use Grt.Signals; with Grt.Astdio; use Grt.Astdio; +with Grt.Astdio.Vhdl; use Grt.Astdio.Vhdl; with Grt.Strings; use Grt.Strings; with Grt.Hooks; use Grt.Hooks; with Grt.Options; diff --git a/src/vhdl/simulate/simul-debugger.adb b/src/vhdl/simulate/simul-debugger.adb index 6747179e8..ba15bb329 100644 --- a/src/vhdl/simulate/simul-debugger.adb +++ b/src/vhdl/simulate/simul-debugger.adb @@ -50,6 +50,7 @@ with Grt.Processes; with Grt.Options; with Grt.Stdio; use Grt.Stdio; with Grt.Astdio; use Grt.Astdio; +with Grt.Astdio.Vhdl; use Grt.Astdio.Vhdl; package body Simul.Debugger is -- This exception can be raised by a debugger command to directly return diff --git a/src/vhdl/simulate/simul-execution.adb b/src/vhdl/simulate/simul-execution.adb index 451889bc9..fd8e4bdbc 100644 --- a/src/vhdl/simulate/simul-execution.adb +++ b/src/vhdl/simulate/simul-execution.adb @@ -34,7 +34,7 @@ with Str_Table; with Files_Map; with Iir_Chains; use Iir_Chains; with Simul.Simulation; use Simul.Simulation; -with Grt.Astdio; +with Grt.Astdio.Vhdl; with Grt.Stdio; with Grt.Options; with Grt.Vstrings; @@ -4249,7 +4249,7 @@ package body Simul.Execution is Put (Standard_Output, Disp_Location (Stmt)); Put (Standard_Output, ":@"); - Grt.Astdio.Put_Time (Grt.Stdio.stdout, Current_Time); + Grt.Astdio.Vhdl.Put_Time (Grt.Stdio.stdout, Current_Time); -- 1: an indication that this message is from an assertion. Put (Standard_Output, ":("); |