aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/vhdl-std_package.ads
blob: 5779282f1f3384f6628739351e1e97988d193a06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
--  std.standard package declarations.
--  Copyright (C) 2002, 2003, 2004, 2005 Tristan Gingold
--
--  This program 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 of the License, or
--  (at your option) any later version.
--
--  This program 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 this program.  If not, see <gnu.org/licenses>.

with Types; use Types;
with Vhdl.Nodes; use Vhdl.Nodes;

package Vhdl.Std_Package is

   --  This is a special node, not really declared in the STANDARD package,
   --  used to mark a node as erroneous.
   --  Its kind is Iir_Kind_Error.
   Error_Mark : constant Iir;

   --  Virtual file and location for the standard package.
   Std_Source_File : Source_File_Entry := No_Source_File_Entry;
   Std_Location: Location_Type := Location_Nil;

   -- Some well known values declared in the STANDARD package.
   -- These values (except time_base) *must* not be modified, and are set by
   -- create_std_standard_package.

   Std_Standard_File: Iir_Design_File := Null_Iir;
   Std_Standard_Unit : Iir_Design_Unit := Null_Iir;
   Standard_Package : Iir_Package_Declaration := Null_Iir;

   -- Boolean values.
   Boolean_Type_Declaration : Iir_Type_Declaration := Null_Iir;
   Boolean_Type_Definition : Iir_Enumeration_Type_Definition;
   Boolean_False : Iir_Enumeration_Literal;
   Boolean_True : Iir_Enumeration_Literal;

   -- Bit values.
   Bit_Type_Declaration : Iir_Type_Declaration := Null_Iir;
   Bit_Type_Definition : Iir_Enumeration_Type_Definition;
   Bit_0 : Iir_Enumeration_Literal;
   Bit_1 : Iir_Enumeration_Literal;

   -- Predefined character.
   Character_Type_Declaration : Iir_Type_Declaration;
   Character_Type_Definition : Iir_Enumeration_Type_Definition;

   -- severity level.
   Severity_Level_Type_Declaration : Iir_Type_Declaration;
   Severity_Level_Type_Definition : Iir_Enumeration_Type_Definition;
   Severity_Level_Note : Iir_Enumeration_Literal;
   Severity_Level_Warning : Iir_Enumeration_Literal;
   Severity_Level_Error : Iir_Enumeration_Literal;
   Severity_Level_Failure : Iir_Enumeration_Literal;

   -- Universal types.
   Universal_Integer_Type_Declaration : Iir_Anonymous_Type_Declaration;
   Universal_Integer_Type_Definition : constant Iir_Integer_Type_Definition;
   Universal_Integer_Subtype_Declaration : Iir_Subtype_Declaration;
   Universal_Integer_Subtype_Definition : Iir_Integer_Subtype_Definition;

   Universal_Integer_One : Iir_Integer_Literal;

   Universal_Real_Type_Declaration : Iir_Anonymous_Type_Declaration;
   Universal_Real_Type_Definition : constant Iir_Floating_Type_Definition;
   Universal_Real_Subtype_Declaration : Iir_Subtype_Declaration;
   Universal_Real_Subtype_Definition : Iir_Floating_Subtype_Definition;

   -- Predefined integer type.
   Integer_Type_Declaration : Iir_Anonymous_Type_Declaration;
   Integer_Type_Definition : Iir_Integer_Type_Definition;
   Integer_Subtype_Declaration : Iir_Subtype_Declaration;
   Integer_Subtype_Definition : Iir_Integer_Subtype_Definition;

   --  Type used when the type of an expression is incorrect.
   Error_Type : Iir;

   -- Predefined real type.
   Real_Type_Declaration : Iir_Anonymous_Type_Declaration;
   Real_Type_Definition : Iir_Floating_Type_Definition;
   Real_Subtype_Declaration : Iir_Subtype_Declaration;
   Real_Subtype_Definition : Iir_Floating_Subtype_Definition;

   -- Predefined natural subtype.
   Natural_Subtype_Declaration : Iir_Subtype_Declaration;
   Natural_Subtype_Definition : Iir_Integer_Subtype_Definition;

   -- Predefined positive subtype.
   Positive_Subtype_Declaration : Iir_Subtype_Declaration;
   Positive_Subtype_Definition : Iir_Integer_Subtype_Definition;

   -- Predefined positive subtype.
   String_Type_Declaration : Iir_Type_Declaration;
   String_Type_Definition : Iir_Array_Type_Definition;

   -- Predefined positive subtype.
   Bit_Vector_Type_Declaration : Iir_Type_Declaration;
   Bit_Vector_Type_Definition : Iir_Array_Type_Definition;

   -- predefined time subtype
   Time_Type_Declaration : Iir_Anonymous_Type_Declaration;
   Time_Type_Definition: Iir_Physical_Type_Definition;
   Time_Subtype_Definition: Iir_Physical_Subtype_Definition;
   Time_Subtype_Declaration : Iir_Subtype_Declaration;

   --  For AMS-VHDL
   Domain_Type_Type_Declaration : Iir_Type_Declaration;
   Domain_Type_Type_Definition : Iir_Enumeration_Type_Definition;
   Domain_Type_Quiescent_Domain : Iir_Enumeration_Literal;
   Domain_Type_Time_Domain : Iir_Enumeration_Literal;
   Domain_Type_Frequency_Domain : Iir_Enumeration_Literal;

   Domain_Signal : Iir_Signal_Declaration;

   --  For VHDL-93
   Delay_Length_Subtype_Definition : Iir_Physical_Subtype_Definition;
   Delay_Length_Subtype_Declaration : Iir_Subtype_Declaration;

   --  For VHDL-93:
   --  type File_Open_Kind
   File_Open_Kind_Type_Declaration : Iir_Type_Declaration;
   File_Open_Kind_Type_Definition : Iir_Enumeration_Type_Definition;
   File_Open_Kind_Read_Mode : Iir_Enumeration_Literal;
   File_Open_Kind_Write_Mode : Iir_Enumeration_Literal;
   File_Open_Kind_Append_Mode : Iir_Enumeration_Literal;

   --  For VHDL-93:
   --  type File_Open_Status
   File_Open_Status_Type_Declaration : Iir_Type_Declaration;
   File_Open_Status_Type_Definition : Iir_Enumeration_Type_Definition;
   File_Open_Status_Open_Ok : Iir_Enumeration_Literal;
   File_Open_Status_Status_Error : Iir_Enumeration_Literal;
   File_Open_Status_Name_Error : Iir_Enumeration_Literal;
   File_Open_Status_Mode_Error : Iir_Enumeration_Literal;

   --  For VHDL-93:
   --    atribute foreign : string;
   Foreign_Attribute : Iir_Attribute_Declaration;

   --  For VHDL-08
   Boolean_Vector_Type_Definition : Iir_Array_Type_Definition;
   Boolean_Vector_Type_Declaration : Iir_Type_Declaration;

   Integer_Vector_Type_Definition : Iir_Array_Type_Definition;
   Integer_Vector_Type_Declaration : Iir_Type_Declaration;

   Real_Vector_Type_Definition : Iir_Array_Type_Definition;
   Real_Vector_Type_Declaration : Iir_Type_Declaration;

   Time_Vector_Type_Definition : Iir_Array_Type_Definition;
   Time_Vector_Type_Declaration : Iir_Type_Declaration;

   --  Internal use only.
   --  These types should be considered like universal types, but
   --  furthermore, they can be converted to any integer/real types while
   --  universal cannot.
   Convertible_Integer_Type_Definition : constant Iir_Integer_Type_Definition;
   Convertible_Real_Type_Definition : constant Iir_Floating_Type_Definition;
   Convertible_Integer_Type_Declaration : Iir_Anonymous_Type_Declaration;
   Convertible_Real_Type_Declaration : Iir_Anonymous_Type_Declaration;

   Convertible_Integer_Subtype_Definition : Iir_Integer_Subtype_Definition;
   Convertible_Integer_Subtype_Declaration : Iir_Subtype_Declaration;

   --  Wilcard types.
   --  Err, we break privacy for iir numbers, but this allow use of them in
   --  case statements.
   Wildcard_Any_Type           : constant Iir := 7;
   Wildcard_Any_Aggregate_Type : constant Iir := 8;
   Wildcard_Any_String_Type    : constant Iir := 9;
   Wildcard_Any_Access_Type    : constant Iir := 10;
   Wildcard_Any_Integer_Type   : constant Iir := 11;
   Wildcard_Psl_Bit_Type       : constant Iir := 12;
   Wildcard_Psl_Bitvector_Type : constant Iir := 13;
   Wildcard_Psl_Boolean_Type   : constant Iir := 14;

   --  Subtype for all wildcard types, so that missing choice can be detected
   --  at compilation time.
   subtype Iir_Wildcard_Types is Iir range 7 .. 14;

   --  Chain of wildcard declarations, to own the nodes.
   Wildcard_Type_Declaration_Chain : Iir;

   --  Create the first well-known nodes.
   procedure Create_First_Nodes;

   --  Create the node for the standard package.
   procedure Create_Std_Standard_Package (Parent : Iir_Library_Declaration);

   procedure Set_Time_Resolution (Resolution : Character);

   --  Return the minimal time resolution according to use of time units.
   function Get_Minimal_Time_Resolution return Character;
private
   --  For speed reasons, some often used nodes are hard-coded.
   Error_Mark : constant Iir := 2;
   Universal_Integer_Type_Definition : constant Iir_Integer_Type_Definition
     := 3;
   Universal_Real_Type_Definition : constant Iir_Floating_Type_Definition
     := 4;

   Convertible_Integer_Type_Definition : constant Iir_Integer_Type_Definition
     := 5;
   Convertible_Real_Type_Definition : constant Iir_Floating_Type_Definition
     := 6;
end Vhdl.Std_Package;