1--  GHDL Run Time (GRT) -  command line options.
2--  Copyright (C) 2002 - 2014 Tristan Gingold
3--
4--  This program is free software: you can redistribute it and/or modify
5--  it under the terms of the GNU General Public License as published by
6--  the Free Software Foundation, either version 2 of the License, or
7--  (at your option) any later version.
8--
9--  This program is distributed in the hope that it will be useful,
10--  but WITHOUT ANY WARRANTY; without even the implied warranty of
11--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12--  GNU General Public License for more details.
13--
14--  You should have received a copy of the GNU General Public License
15--  along with this program.  If not, see <gnu.org/licenses>.
16--
17--  As a special exception, if other files instantiate generics from this
18--  unit, or you link this unit with other files to produce an executable,
19--  this unit does not by itself cause the resulting executable to be
20--  covered by the GNU General Public License. This exception does not
21--  however invalidate any other reasons why the executable file might be
22--  covered by the GNU Public License.
23with Grt.Types; use Grt.Types;
24with Grt.Severity;
25
26package Grt.Options is
27   pragma Preelaborate (Grt.Options);
28
29   --  Name of the program, set by argv[0].
30   --  Must be set before calling DECODE.
31   Progname : Ghdl_C_String;
32
33   --  Arguments.
34   --  This mimics argc/argv of 'main'.
35   --  These must be set before calling DECODE.
36   Argc : Integer;
37
38   type Argv_Array_Type is array (Natural) of Ghdl_C_String;
39   type Argv_Type is access Argv_Array_Type;
40
41   Argv : Argv_Type;
42
43   --  Last option decoded.
44   --  Following arguments are reserved for the program.
45   Last_Opt : Integer;
46
47   --  Consistent flags used for analysis.
48   --  Format is "VVitr", where:
49   --    'VV' is the version (87, 93 or 08).
50   --    'i' is the integer size ('i' for 32 bits, 'I' for 64 bits).
51   --    't' is the time size ('t' for 32 bits, 'T' for 64 bits).
52   --    'r' is the resolution ('?' for to be set by the user, '-' for any).
53   Flag_String : constant String (1 .. 5);
54   pragma Import (C, Flag_String, "__ghdl_flag_string");
55
56   --  Time resolution extracted from Flag_String, in multiple of -3:
57   --  0: sec
58   --  1: ms
59   --  2: us
60   --  3: ns
61   --  4: ps
62   --  5: fs
63   subtype Natural_Time_Scale is Natural range 0 .. 5;
64   Time_Resolution_Scale : Natural_Time_Scale;
65
66   --  Set Time_Resolution_Scale from Flag_String.
67   procedure Set_Time_Resolution;
68
69   --  Display options help.
70   --  Should not be called directly.
71   procedure Help;
72
73   --  Status from Decode_Option.
74   type Decode_Option_Status is
75     (
76      --  Last option, next arguments aren't options.
77      Decode_Option_Last,
78
79      --  For options like --help: program shouldn't run.
80      Decode_Option_Stop,
81
82      --  Option was successfuly decoded.
83      Decode_Option_Ok);
84
85   --  Decode option Option and set Status.
86   procedure Decode_Option
87     (Option : String; Status : out Decode_Option_Status);
88
89   --  Decode command line options.
90   --  If STOP is true, there nothing must happen (set by --help).
91   procedure Decode (Stop : out Boolean);
92
93   --  Set by --disp-time (and --trace-signals, --trace-processes) to display
94   --  time and deltas.
95   Disp_Time : Boolean := False;
96
97   --  Set by --trace-signals, to display signals after each cycle.
98   Trace_Signals : Boolean := False;
99
100   --  Set by --trace-processes, to display process name before being run.
101   Trace_Processes : Boolean := False;
102
103   --  Set by --disp-sig-types, to display signals and they types.
104   Disp_Sig_Types : Boolean := False;
105
106   Disp_Sources : Boolean := False;
107   Disp_Signals_Map : Boolean := False;
108   Disp_Signals_Table : Boolean := False;
109   Disp_Sensitivity : Boolean := False;
110
111   --  Set by --disp-order to diplay evaluation order of signals.
112   Disp_Signals_Order : Boolean := False;
113
114   --  Set by --stats to display statistics.
115   Flag_Stats : Boolean := False;
116
117   --  Set by --checks to do internal checks.
118   Checks : Boolean := False;
119
120   --  For --assert-level
121   --  Level at which an assert stop the simulation.
122   Severity_Level : Integer := Grt.Severity.Failure_Severity;
123
124   --  Level at which an assert displays a backtrace.
125   Backtrace_Severity : Integer := Grt.Severity.None_Severity;
126
127   --  How assertions are handled.
128   type Assert_Handling is
129     (Enable_Asserts,
130      Disable_Asserts_At_Time_0,
131      Disable_Asserts);
132
133   --  Handling of assertions from IEEE library.
134   Ieee_Asserts : Assert_Handling := Enable_Asserts;
135
136   --  Handling of assertions (except from IEEE library).
137   Asserts_Policy : Assert_Handling := Enable_Asserts;
138
139   --  Set by --stop-delta=XXX to stop the simulation after XXX delta cycles.
140   Stop_Delta : Natural := 5000;
141
142   --  Set by --stop-time=X to stop the simulation at time X.
143   Stop_Time : Std_Time := Std_Time'Last;
144
145   --  Set by --no-run
146   --  If set, do not simulate, only elaborate.
147   Flag_No_Run : Boolean := False;
148
149   type Activity_Mode is (Activity_All, Activity_Minimal, Activity_None);
150   Flag_Activity : Activity_Mode := Activity_Minimal;
151
152   --  If true, the simulation should be stopped.
153   Break_Simulation : Boolean;
154
155   --  Set by --thread=
156   --  Number of threads used to do the simulation.
157   --  1 mean no additionnal threads, 0 means as many threads as number of
158   --  CPUs.
159   Nbr_Threads : Natural := 1;
160
161   -- If true, writes are made without buffering on a file opened in write_mode
162   -- or append_mode (TEXTIO)
163   Unbuffered_Writes : Boolean := False;
164
165   --  Set maximum dynamic stack allocation.
166   Max_Stack_Allocation : Ghdl_Index_Type := 128 * 1024;
167
168   --  Helper: extract time from STR (a number followed by a unit, without
169   --  spaces; the number is optionnal).  In case of error, display an error
170   --  message and returns -1.
171   function Parse_Time (Str : String) return Std_Time;
172
173   --  Simply linked list of generic override (option -gIDENT=VALUE).
174   type Generic_Override_Type;
175   type Generic_Override_Acc is access Generic_Override_Type;
176
177   type Generic_Override_Type is record
178      --  Name of the generic (lower case).
179      Name : String_Access;
180
181      --  Value.
182      Value : String_Access;
183
184      --  Simply linked list.
185      Next : Generic_Override_Acc;
186   end record;
187
188   First_Generic_Override : Generic_Override_Acc;
189   Last_Generic_Override : Generic_Override_Acc;
190private
191   pragma Export (C, Nbr_Threads, "grt_nbr_threads");
192end Grt.Options;
193