1--  std.standard package declarations.
2--  Copyright (C) 2002, 2003, 2004, 2005 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
17with Types; use Types;
18with Vhdl.Nodes; use Vhdl.Nodes;
19
20package Vhdl.Std_Package is
21
22   --  This is a special node, not really declared in the STANDARD package,
23   --  used to mark a node as erroneous.
24   --  Its kind is Iir_Kind_Error.
25   Error_Mark : constant Iir;
26
27   --  Virtual file and location for the standard package.
28   Std_Source_File : Source_File_Entry := No_Source_File_Entry;
29   Std_Location: Location_Type := Location_Nil;
30
31   -- Some well known values declared in the STANDARD package.
32   -- These values (except time_base) *must* not be modified, and are set by
33   -- create_std_standard_package.
34
35   Std_Standard_File: Iir_Design_File := Null_Iir;
36   Std_Standard_Unit : Iir_Design_Unit := Null_Iir;
37   Standard_Package : Iir_Package_Declaration := Null_Iir;
38
39   -- Boolean values.
40   Boolean_Type_Declaration : Iir_Type_Declaration := Null_Iir;
41   Boolean_Type_Definition : Iir_Enumeration_Type_Definition;
42   Boolean_False : Iir_Enumeration_Literal;
43   Boolean_True : Iir_Enumeration_Literal;
44
45   -- Bit values.
46   Bit_Type_Declaration : Iir_Type_Declaration := Null_Iir;
47   Bit_Type_Definition : Iir_Enumeration_Type_Definition;
48   Bit_0 : Iir_Enumeration_Literal;
49   Bit_1 : Iir_Enumeration_Literal;
50
51   -- Predefined character.
52   Character_Type_Declaration : Iir_Type_Declaration;
53   Character_Type_Definition : Iir_Enumeration_Type_Definition;
54
55   -- severity level.
56   Severity_Level_Type_Declaration : Iir_Type_Declaration;
57   Severity_Level_Type_Definition : Iir_Enumeration_Type_Definition;
58   Severity_Level_Note : Iir_Enumeration_Literal;
59   Severity_Level_Warning : Iir_Enumeration_Literal;
60   Severity_Level_Error : Iir_Enumeration_Literal;
61   Severity_Level_Failure : Iir_Enumeration_Literal;
62
63   -- Universal types.
64   Universal_Integer_Type_Declaration : Iir_Anonymous_Type_Declaration;
65   Universal_Integer_Type_Definition : constant Iir_Integer_Type_Definition;
66   Universal_Integer_Subtype_Declaration : Iir_Subtype_Declaration;
67   Universal_Integer_Subtype_Definition : Iir_Integer_Subtype_Definition;
68
69   Universal_Integer_One : Iir_Integer_Literal;
70
71   Universal_Real_Type_Declaration : Iir_Anonymous_Type_Declaration;
72   Universal_Real_Type_Definition : constant Iir_Floating_Type_Definition;
73   Universal_Real_Subtype_Declaration : Iir_Subtype_Declaration;
74   Universal_Real_Subtype_Definition : Iir_Floating_Subtype_Definition;
75
76   -- Predefined integer type.
77   Integer_Type_Declaration : Iir_Anonymous_Type_Declaration;
78   Integer_Type_Definition : Iir_Integer_Type_Definition;
79   Integer_Subtype_Declaration : Iir_Subtype_Declaration;
80   Integer_Subtype_Definition : Iir_Integer_Subtype_Definition;
81
82   --  Type used when the type of an expression is incorrect.
83   Error_Type : Iir;
84
85   -- Predefined real type.
86   Real_Type_Declaration : Iir_Anonymous_Type_Declaration;
87   Real_Type_Definition : Iir_Floating_Type_Definition;
88   Real_Subtype_Declaration : Iir_Subtype_Declaration;
89   Real_Subtype_Definition : Iir_Floating_Subtype_Definition;
90
91   -- Predefined natural subtype.
92   Natural_Subtype_Declaration : Iir_Subtype_Declaration;
93   Natural_Subtype_Definition : Iir_Integer_Subtype_Definition;
94
95   -- Predefined positive subtype.
96   Positive_Subtype_Declaration : Iir_Subtype_Declaration;
97   Positive_Subtype_Definition : Iir_Integer_Subtype_Definition;
98
99   -- Predefined positive subtype.
100   String_Type_Declaration : Iir_Type_Declaration;
101   String_Type_Definition : Iir_Array_Type_Definition;
102
103   -- Predefined positive subtype.
104   Bit_Vector_Type_Declaration : Iir_Type_Declaration;
105   Bit_Vector_Type_Definition : Iir_Array_Type_Definition;
106
107   -- predefined time subtype
108   Time_Type_Declaration : Iir_Anonymous_Type_Declaration;
109   Time_Type_Definition: Iir_Physical_Type_Definition;
110   Time_Subtype_Definition: Iir_Physical_Subtype_Definition;
111   Time_Subtype_Declaration : Iir_Subtype_Declaration;
112
113   --  For AMS-VHDL
114   Domain_Type_Type_Declaration : Iir_Type_Declaration;
115   Domain_Type_Type_Definition : Iir_Enumeration_Type_Definition;
116   Domain_Type_Quiescent_Domain : Iir_Enumeration_Literal;
117   Domain_Type_Time_Domain : Iir_Enumeration_Literal;
118   Domain_Type_Frequency_Domain : Iir_Enumeration_Literal;
119
120   Domain_Signal : Iir_Signal_Declaration;
121
122   --  For VHDL-93
123   Delay_Length_Subtype_Definition : Iir_Physical_Subtype_Definition;
124   Delay_Length_Subtype_Declaration : Iir_Subtype_Declaration;
125
126   --  For VHDL-93:
127   --  type File_Open_Kind
128   File_Open_Kind_Type_Declaration : Iir_Type_Declaration;
129   File_Open_Kind_Type_Definition : Iir_Enumeration_Type_Definition;
130   File_Open_Kind_Read_Mode : Iir_Enumeration_Literal;
131   File_Open_Kind_Write_Mode : Iir_Enumeration_Literal;
132   File_Open_Kind_Append_Mode : Iir_Enumeration_Literal;
133
134   --  For VHDL-93:
135   --  type File_Open_Status
136   File_Open_Status_Type_Declaration : Iir_Type_Declaration;
137   File_Open_Status_Type_Definition : Iir_Enumeration_Type_Definition;
138   File_Open_Status_Open_Ok : Iir_Enumeration_Literal;
139   File_Open_Status_Status_Error : Iir_Enumeration_Literal;
140   File_Open_Status_Name_Error : Iir_Enumeration_Literal;
141   File_Open_Status_Mode_Error : Iir_Enumeration_Literal;
142
143   --  For VHDL-93:
144   --    atribute foreign : string;
145   Foreign_Attribute : Iir_Attribute_Declaration;
146
147   --  For VHDL-08
148   Boolean_Vector_Type_Definition : Iir_Array_Type_Definition;
149   Boolean_Vector_Type_Declaration : Iir_Type_Declaration;
150
151   Integer_Vector_Type_Definition : Iir_Array_Type_Definition;
152   Integer_Vector_Type_Declaration : Iir_Type_Declaration;
153
154   Real_Vector_Type_Definition : Iir_Array_Type_Definition;
155   Real_Vector_Type_Declaration : Iir_Type_Declaration;
156
157   Time_Vector_Type_Definition : Iir_Array_Type_Definition;
158   Time_Vector_Type_Declaration : Iir_Type_Declaration;
159
160   --  Internal use only.
161   --  These types should be considered like universal types, but
162   --  furthermore, they can be converted to any integer/real types while
163   --  universal cannot.
164   Convertible_Integer_Type_Definition : constant Iir_Integer_Type_Definition;
165   Convertible_Real_Type_Definition : constant Iir_Floating_Type_Definition;
166   Convertible_Integer_Type_Declaration : Iir_Anonymous_Type_Declaration;
167   Convertible_Real_Type_Declaration : Iir_Anonymous_Type_Declaration;
168
169   Convertible_Integer_Subtype_Definition : Iir_Integer_Subtype_Definition;
170   Convertible_Integer_Subtype_Declaration : Iir_Subtype_Declaration;
171
172   --  Wilcard types.
173   --  Err, we break privacy for iir numbers, but this allow use of them in
174   --  case statements.
175   Wildcard_Any_Type           : constant Iir := 7;
176   Wildcard_Any_Aggregate_Type : constant Iir := 8;
177   Wildcard_Any_String_Type    : constant Iir := 9;
178   Wildcard_Any_Access_Type    : constant Iir := 10;
179   Wildcard_Any_Integer_Type   : constant Iir := 11;
180   Wildcard_Psl_Bit_Type       : constant Iir := 12;
181   Wildcard_Psl_Bitvector_Type : constant Iir := 13;
182   Wildcard_Psl_Boolean_Type   : constant Iir := 14;
183
184   --  Subtype for all wildcard types, so that missing choice can be detected
185   --  at compilation time.
186   subtype Iir_Wildcard_Types is Iir range 7 .. 14;
187
188   --  Chain of wildcard declarations, to own the nodes.
189   Wildcard_Type_Declaration_Chain : Iir;
190
191   --  Create the first well-known nodes.
192   procedure Create_First_Nodes;
193
194   --  Create the node for the standard package.
195   procedure Create_Std_Standard_Package (Parent : Iir_Library_Declaration);
196
197   procedure Set_Time_Resolution (Resolution : Character);
198
199   --  Return the minimal time resolution according to use of time units.
200   function Get_Minimal_Time_Resolution return Character;
201private
202   --  For speed reasons, some often used nodes are hard-coded.
203   Error_Mark : constant Iir := 2;
204   Universal_Integer_Type_Definition : constant Iir_Integer_Type_Definition
205     := 3;
206   Universal_Real_Type_Definition : constant Iir_Floating_Type_Definition
207     := 4;
208
209   Convertible_Integer_Type_Definition : constant Iir_Integer_Type_Definition
210     := 5;
211   Convertible_Real_Type_Definition : constant Iir_Floating_Type_Definition
212     := 6;
213end Vhdl.Std_Package;
214