summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--evaluation.adb12
-rw-r--r--iirs.ads9
-rw-r--r--sem_scopes.adb5
-rw-r--r--std_names.adb3
-rw-r--r--std_names.ads15
-rw-r--r--std_package.adb264
6 files changed, 191 insertions, 117 deletions
diff --git a/evaluation.adb b/evaluation.adb
index 0444b0a..52c1af2 100644
--- a/evaluation.adb
+++ b/evaluation.adb
@@ -1239,7 +1239,17 @@ package body Evaluation is
| Iir_Predefined_Std_Ulogic_Match_Greater
| Iir_Predefined_Std_Ulogic_Match_Greater_Equal =>
-- TODO
- raise Program_Error;
+ raise Internal_Error;
+
+ when Iir_Predefined_Enum_To_String
+ | Iir_Predefined_Integer_To_String
+ | Iir_Predefined_Floating_To_String
+ | Iir_Predefined_Real_To_String_Digits
+ | Iir_Predefined_Real_To_String_Format
+ | Iir_Predefined_Physical_To_String
+ | Iir_Predefined_Time_To_String_Unit =>
+ -- TODO
+ raise Internal_Error;
end case;
exception
when Constraint_Error =>
diff --git a/iirs.ads b/iirs.ads
index e6541ac..f2ced23 100644
--- a/iirs.ads
+++ b/iirs.ads
@@ -3109,6 +3109,7 @@ package Iirs is
Iir_Predefined_Enum_Minimum,
Iir_Predefined_Enum_Maximum,
+ Iir_Predefined_Enum_To_String,
-- Predefined operators for BIT type.
Iir_Predefined_Bit_And,
@@ -3152,6 +3153,7 @@ package Iirs is
Iir_Predefined_Integer_Minimum,
Iir_Predefined_Integer_Maximum,
+ Iir_Predefined_Integer_To_String,
-- Predefined operators for any floating type.
Iir_Predefined_Floating_Equality,
@@ -3174,6 +3176,10 @@ package Iirs is
Iir_Predefined_Floating_Minimum,
Iir_Predefined_Floating_Maximum,
+ Iir_Predefined_Floating_To_String,
+
+ Iir_Predefined_Real_To_String_Digits,
+ Iir_Predefined_Real_To_String_Format,
-- Predefined operator for universal types.
Iir_Predefined_Universal_R_I_Mul,
@@ -3205,6 +3211,9 @@ package Iirs is
Iir_Predefined_Physical_Minimum,
Iir_Predefined_Physical_Maximum,
+ Iir_Predefined_Physical_To_String,
+
+ Iir_Predefined_Time_To_String_Unit,
-- Predefined operators for access.
Iir_Predefined_Access_Equality,
diff --git a/sem_scopes.adb b/sem_scopes.adb
index e00ffb8..b50d4c2 100644
--- a/sem_scopes.adb
+++ b/sem_scopes.adb
@@ -925,6 +925,11 @@ package body Sem_Scopes is
when Iir_Kinds_Signal_Attribute =>
null;
+ when Iir_Kind_Protected_Type_Body =>
+ -- FIXME: allowed only in debugger (if the current scope is
+ -- within a package body) ?
+ null;
+
when others =>
Error_Kind ("iterator_decl", Decl);
end case;
diff --git a/std_names.adb b/std_names.adb
index 05f0f8c..67fb47b 100644
--- a/std_names.adb
+++ b/std_names.adb
@@ -160,6 +160,9 @@ package body Std_Names is
Def ("integer_vector", Name_Integer_Vector);
Def ("real_vector", Name_Real_Vector);
Def ("time_vector", Name_Time_Vector);
+ Def ("digits", Name_Digits);
+ Def ("format", Name_Format);
+ Def ("unit", Name_Unit);
Def ("domain_type", Name_Domain_Type);
Def ("quiescent_domain", Name_Quiescent_Domain);
diff --git a/std_names.ads b/std_names.ads
index 4081508..6b87814 100644
--- a/std_names.ads
+++ b/std_names.ads
@@ -348,14 +348,17 @@ package Std_Names is
Name_Integer_Vector : constant Name_Id := Name_First_Standard + 050;
Name_Real_Vector : constant Name_Id := Name_First_Standard + 051;
Name_Time_Vector : constant Name_Id := Name_First_Standard + 052;
+ Name_Digits : constant Name_Id := Name_First_Standard + 053;
+ Name_Format : constant Name_Id := Name_First_Standard + 054;
+ Name_Unit : constant Name_Id := Name_First_Standard + 055;
-- Added by AMS vhdl.
- Name_Domain_Type : constant Name_Id := Name_First_Standard + 053;
- Name_Quiescent_Domain : constant Name_Id := Name_First_Standard + 054;
- Name_Time_Domain : constant Name_Id := Name_First_Standard + 055;
- Name_Frequency_Domain : constant Name_Id := Name_First_Standard + 056;
- Name_Domain : constant Name_Id := Name_First_Standard + 057;
- Name_Frequency : constant Name_Id := Name_First_Standard + 058;
+ Name_Domain_Type : constant Name_Id := Name_First_Standard + 056;
+ Name_Quiescent_Domain : constant Name_Id := Name_First_Standard + 057;
+ Name_Time_Domain : constant Name_Id := Name_First_Standard + 058;
+ Name_Frequency_Domain : constant Name_Id := Name_First_Standard + 059;
+ Name_Domain : constant Name_Id := Name_First_Standard + 060;
+ Name_Frequency : constant Name_Id := Name_First_Standard + 061;
Name_Last_Standard : constant Name_Id := Name_Frequency;
diff --git a/std_package.adb b/std_package.adb
index 2833584..8b6e21b 100644
--- a/std_package.adb
+++ b/std_package.adb
@@ -260,17 +260,20 @@ package body Std_Package is
-- Create:
-- function TO_STRING (VALUE: inter_type) return STRING;
- procedure Create_To_String (Inter_Type : Iir)
+ procedure Create_To_String (Inter_Type : Iir;
+ Imp : Iir_Predefined_Functions;
+ Inter2_Id : Name_Id := Null_Identifier;
+ Inter2_Type : Iir := Null_Iir)
is
Decl : Iir_Implicit_Function_Declaration;
Inter : Iir_Constant_Interface_Declaration;
+ Inter2 : Iir_Constant_Interface_Declaration;
begin
Decl := Create_Std_Decl (Iir_Kind_Implicit_Function_Declaration);
Set_Std_Identifier (Decl, Std_Names.Name_To_String);
Set_Return_Type (Decl, String_Type_Definition);
Set_Pure_Flag (Decl, True);
- -- FIXME!!!
- Set_Implicit_Definition (Decl, Iir_Predefined_Now_Function);
+ Set_Implicit_Definition (Decl, Imp);
Inter := Create_Iir (Iir_Kind_Constant_Interface_Declaration);
Set_Identifier (Inter, Std_Names.Name_Value);
@@ -279,6 +282,15 @@ package body Std_Package is
Set_Base_Name (Inter, Inter);
Set_Interface_Declaration_Chain (Decl, Inter);
+ if Inter2_Id /= Null_Identifier then
+ Inter2 := Create_Iir (Iir_Kind_Constant_Interface_Declaration);
+ Set_Identifier (Inter2, Inter2_Id);
+ Set_Type (Inter2, Inter2_Type);
+ Set_Mode (Inter2, Iir_In_Mode);
+ Set_Base_Name (Inter2, Inter2);
+ Set_Chain (Inter, Inter2);
+ end if;
+
Sem.Compute_Subprogram_Hash (Decl);
Add_Decl (Decl);
end Create_To_String;
@@ -309,16 +321,10 @@ package body Std_Package is
end Create_Edge_Function;
begin
+ -- Create design file.
Std_Standard_File := Create_Std_Iir (Iir_Kind_Design_File);
Set_Parent (Std_Standard_File, Parent);
Set_Design_File_Filename (Std_Standard_File, Std_Filename);
- Std_Standard_Unit := Create_Std_Iir (Iir_Kind_Design_Unit);
- Set_Identifier (Std_Standard_Unit, Name_Standard);
- Set_First_Design_Unit (Std_Standard_File, Std_Standard_Unit);
- Set_Last_Design_Unit (Std_Standard_File, Std_Standard_Unit);
- Set_Design_File (Std_Standard_Unit, Std_Standard_File);
- Set_Date_State (Std_Standard_Unit, Date_Analyze);
- Set_Dependence_List (Std_Standard_Unit, Create_Iir_List);
declare
use Str_Table;
@@ -334,6 +340,15 @@ package body Std_Package is
Set_Analysis_Time_Stamp (Std_Standard_File, Id);
end;
+ -- Create design unit.
+ Std_Standard_Unit := Create_Std_Iir (Iir_Kind_Design_Unit);
+ Set_Identifier (Std_Standard_Unit, Name_Standard);
+ Set_First_Design_Unit (Std_Standard_File, Std_Standard_Unit);
+ Set_Last_Design_Unit (Std_Standard_File, Std_Standard_Unit);
+ Set_Design_File (Std_Standard_Unit, Std_Standard_File);
+ Set_Date_State (Std_Standard_Unit, Date_Analyze);
+ Set_Dependence_List (Std_Standard_Unit, Create_Iir_List);
+
Set_Date (Std_Standard_Unit, Date_Valid'First);
-- Adding "package STANDARD is"
@@ -374,6 +389,7 @@ package body Std_Package is
end;
if Vhdl_Std >= Vhdl_08 then
+ -- Rising_Edge and Falling_Edge
Create_Edge_Function
(Std_Names.Name_Rising_Edge, Iir_Predefined_Boolean_Rising_Edge,
Boolean_Type_Definition);
@@ -413,6 +429,7 @@ package body Std_Package is
end;
if Vhdl_Std >= Vhdl_08 then
+ -- Rising_Edge and Falling_Edge
Create_Edge_Function
(Std_Names.Name_Rising_Edge, Iir_Predefined_Bit_Rising_Edge,
Bit_Type_Definition);
@@ -503,7 +520,7 @@ package body Std_Package is
Add_Implicit_Operations (Severity_Level_Type);
end;
- -- universal types.
+ -- universal integer
begin
Create_Integer_Type (Universal_Integer_Type_Definition,
Universal_Integer_Type,
@@ -664,87 +681,6 @@ package body Std_Package is
Set_Subtype_Definition (Real_Type, Real_Subtype_Definition);
end;
- -- natural subtype
- declare
- Constraint : Iir_Range_Expression;
- begin
- Natural_Subtype_Definition :=
- Create_Std_Iir (Iir_Kind_Integer_Subtype_Definition);
- Set_Base_Type (Natural_Subtype_Definition, Integer_Type_Definition);
- Constraint := Create_Std_Range_Expr
- (Create_Std_Integer (0, Integer_Type_Definition),
- Create_Std_Integer (High_Bound (Flags.Flag_Integer_64),
- Integer_Type_Definition),
- Integer_Type_Definition);
- Set_Range_Constraint (Natural_Subtype_Definition, Constraint);
- Set_Type_Staticness (Natural_Subtype_Definition, Locally);
- Set_Signal_Type_Flag (Natural_Subtype_Definition, True);
- Set_Has_Signal_Flag (Natural_Subtype_Definition,
- not Flags.Flag_Whole_Analyze);
-
- Natural_Subtype := Create_Std_Decl (Iir_Kind_Subtype_Declaration);
- Set_Std_Identifier (Natural_Subtype, Name_Natural);
- Set_Type (Natural_Subtype, Natural_Subtype_Definition);
- Add_Decl (Natural_Subtype);
- Set_Type_Declarator (Natural_Subtype_Definition, Natural_Subtype);
- end;
-
- -- positive subtype
- declare
- Constraint : Iir_Range_Expression;
- begin
- Positive_Subtype_Definition :=
- Create_Std_Iir (Iir_Kind_Integer_Subtype_Definition);
- Set_Base_Type (Positive_Subtype_Definition,
- Integer_Type_Definition);
- Constraint := Create_Std_Range_Expr
- (Create_Std_Integer (1, Integer_Type_Definition),
- Create_Std_Integer (High_Bound (Flags.Flag_Integer_64),
- Integer_Type_Definition),
- Integer_Type_Definition);
- Set_Range_Constraint (Positive_Subtype_Definition, Constraint);
- Set_Type_Staticness (Positive_Subtype_Definition, Locally);
- Set_Signal_Type_Flag (Positive_Subtype_Definition, True);
- Set_Has_Signal_Flag (Positive_Subtype_Definition,
- not Flags.Flag_Whole_Analyze);
-
- Positive_Subtype := Create_Std_Decl (Iir_Kind_Subtype_Declaration);
- Set_Std_Identifier (Positive_Subtype, Name_Positive);
- Set_Type (Positive_Subtype, Positive_Subtype_Definition);
- Add_Decl (Positive_Subtype);
- Set_Type_Declarator (Positive_Subtype_Definition, Positive_Subtype);
- end;
-
- -- string type.
- -- type string is array (positive range <>) of character;
- begin
- String_Type_Definition :=
- Create_Std_Iir (Iir_Kind_Array_Type_Definition);
- Set_Base_Type (String_Type_Definition, String_Type_Definition);
- Set_Index_Subtype_List (String_Type_Definition, Create_Iir_List);
- Append_Element (Get_Index_Subtype_List (String_Type_Definition),
- Positive_Subtype_Definition);
- Set_Element_Subtype (String_Type_Definition,
- Character_Type_Definition);
- Set_Type_Staticness (String_Type_Definition, None);
- Set_Signal_Type_Flag (String_Type_Definition, True);
- Set_Has_Signal_Flag (String_Type_Definition,
- not Flags.Flag_Whole_Analyze);
-
- String_Type := Create_Std_Decl (Iir_Kind_Type_Declaration);
- Set_Std_Identifier (String_Type, Name_String);
- Set_Type (String_Type, String_Type_Definition);
- Add_Decl (String_Type);
- Set_Type_Declarator (String_Type_Definition, String_Type);
-
- Add_Implicit_Operations (String_Type);
- end;
-
- -- bit_vector type.
- -- type bit_vector is array (natural range <>) of bit;
- Create_Array_Type (Bit_Vector_Type_Definition, Bit_Vector_Type,
- Bit_Type_Definition, Name_Bit_Vector);
-
-- time definition
declare
Time_Staticness : Iir_Staticness;
@@ -944,28 +880,111 @@ package body Std_Package is
Add_Decl (Function_Now);
end;
- -- VHDL 2008
- -- Vector types
+ -- natural subtype
+ declare
+ Constraint : Iir_Range_Expression;
+ begin
+ Natural_Subtype_Definition :=
+ Create_Std_Iir (Iir_Kind_Integer_Subtype_Definition);
+ Set_Base_Type (Natural_Subtype_Definition, Integer_Type_Definition);
+ Constraint := Create_Std_Range_Expr
+ (Create_Std_Integer (0, Integer_Type_Definition),
+ Create_Std_Integer (High_Bound (Flags.Flag_Integer_64),
+ Integer_Type_Definition),
+ Integer_Type_Definition);
+ Set_Range_Constraint (Natural_Subtype_Definition, Constraint);
+ Set_Type_Staticness (Natural_Subtype_Definition, Locally);
+ Set_Signal_Type_Flag (Natural_Subtype_Definition, True);
+ Set_Has_Signal_Flag (Natural_Subtype_Definition,
+ not Flags.Flag_Whole_Analyze);
+
+ Natural_Subtype := Create_Std_Decl (Iir_Kind_Subtype_Declaration);
+ Set_Std_Identifier (Natural_Subtype, Name_Natural);
+ Set_Type (Natural_Subtype, Natural_Subtype_Definition);
+ Add_Decl (Natural_Subtype);
+ Set_Type_Declarator (Natural_Subtype_Definition, Natural_Subtype);
+ end;
+
+ -- positive subtype
+ declare
+ Constraint : Iir_Range_Expression;
+ begin
+ Positive_Subtype_Definition :=
+ Create_Std_Iir (Iir_Kind_Integer_Subtype_Definition);
+ Set_Base_Type (Positive_Subtype_Definition,
+ Integer_Type_Definition);
+ Constraint := Create_Std_Range_Expr
+ (Create_Std_Integer (1, Integer_Type_Definition),
+ Create_Std_Integer (High_Bound (Flags.Flag_Integer_64),
+ Integer_Type_Definition),
+ Integer_Type_Definition);
+ Set_Range_Constraint (Positive_Subtype_Definition, Constraint);
+ Set_Type_Staticness (Positive_Subtype_Definition, Locally);
+ Set_Signal_Type_Flag (Positive_Subtype_Definition, True);
+ Set_Has_Signal_Flag (Positive_Subtype_Definition,
+ not Flags.Flag_Whole_Analyze);
+
+ Positive_Subtype := Create_Std_Decl (Iir_Kind_Subtype_Declaration);
+ Set_Std_Identifier (Positive_Subtype, Name_Positive);
+ Set_Type (Positive_Subtype, Positive_Subtype_Definition);
+ Add_Decl (Positive_Subtype);
+ Set_Type_Declarator (Positive_Subtype_Definition, Positive_Subtype);
+ end;
+
+ -- string type.
+ -- type string is array (positive range <>) of character;
+ begin
+ String_Type_Definition :=
+ Create_Std_Iir (Iir_Kind_Array_Type_Definition);
+ Set_Base_Type (String_Type_Definition, String_Type_Definition);
+ Set_Index_Subtype_List (String_Type_Definition, Create_Iir_List);
+ Append_Element (Get_Index_Subtype_List (String_Type_Definition),
+ Positive_Subtype_Definition);
+ Set_Element_Subtype (String_Type_Definition,
+ Character_Type_Definition);
+ Set_Type_Staticness (String_Type_Definition, None);
+ Set_Signal_Type_Flag (String_Type_Definition, True);
+ Set_Has_Signal_Flag (String_Type_Definition,
+ not Flags.Flag_Whole_Analyze);
+
+ String_Type := Create_Std_Decl (Iir_Kind_Type_Declaration);
+ Set_Std_Identifier (String_Type, Name_String);
+ Set_Type (String_Type, String_Type_Definition);
+ Add_Decl (String_Type);
+ Set_Type_Declarator (String_Type_Definition, String_Type);
+
+ Add_Implicit_Operations (String_Type);
+ end;
+
if Vhdl_Std >= Vhdl_08 then
-- type Boolean_Vector is array (Natural range <>) of Boolean;
Create_Array_Type
(Boolean_Vector_Type_Definition, Boolean_Vector_Type,
- Integer_Type_Definition, Name_Boolean_Vector);
+ Boolean_Type_Definition, Name_Boolean_Vector);
+ end if;
+
+ -- bit_vector type.
+ -- type bit_vector is array (natural range <>) of bit;
+ Create_Array_Type (Bit_Vector_Type_Definition, Bit_Vector_Type,
+ Bit_Type_Definition, Name_Bit_Vector);
+ -- VHDL 2008
+ -- Vector types
+ if Vhdl_Std >= Vhdl_08 then
-- type integer_vector is array (natural range <>) of Integer;
Create_Array_Type
(Integer_Vector_Type_Definition, Integer_Vector_Type,
- Integer_Type_Definition, Name_Integer_Vector);
+ Integer_Subtype_Definition, Name_Integer_Vector);
-- type Real_vector is array (natural range <>) of Real;
Create_Array_Type
(Real_Vector_Type_Definition, Real_Vector_Type,
- Real_Type_Definition, Name_Real_Vector);
+ Real_Subtype_Definition, Name_Real_Vector);
- -- type Real_vector is array (natural range <>) of Real;
+ -- type Time_vector is array (natural range <>) of Time;
Create_Array_Type
(Time_Vector_Type_Definition, Time_Vector_Type,
- Time_Type_Definition, Name_Time_Vector);
+ Time_Subtype_Definition, Name_Time_Vector);
end if;
-- VHDL93:
@@ -1062,17 +1081,42 @@ package body Std_Package is
end if;
if Vhdl_Std >= Vhdl_08 then
- Create_To_String (Boolean_Type_Definition);
- Create_To_String (Bit_Type_Definition);
- Create_To_String (Character_Type_Definition);
- Create_To_String (Severity_Level_Type_Definition);
- Create_To_String (Universal_Integer_Type_Definition);
- Create_To_String (Universal_Real_Type_Definition);
- Create_To_String (Integer_Type_Definition);
- Create_To_String (Real_Type_Definition);
- Create_To_String (Time_Type_Definition);
- Create_To_String (File_Open_Kind_Type_Definition);
- Create_To_String (File_Open_Status_Type_Definition);
+ Create_To_String (Boolean_Type_Definition,
+ Iir_Predefined_Enum_To_String);
+ Create_To_String (Bit_Type_Definition,
+ Iir_Predefined_Enum_To_String);
+ Create_To_String (Character_Type_Definition,
+ Iir_Predefined_Enum_To_String);
+ Create_To_String (Severity_Level_Type_Definition,
+ Iir_Predefined_Enum_To_String);
+ Create_To_String (Universal_Integer_Type_Definition,
+ Iir_Predefined_Integer_To_String);
+ Create_To_String (Universal_Real_Type_Definition,
+ Iir_Predefined_Floating_To_String);
+ Create_To_String (Integer_Type_Definition,
+ Iir_Predefined_Integer_To_String);
+ Create_To_String (Real_Type_Definition,
+ Iir_Predefined_Floating_To_String);
+ Create_To_String (Time_Type_Definition,
+ Iir_Predefined_Physical_To_String);
+ Create_To_String (File_Open_Kind_Type_Definition,
+ Iir_Predefined_Enum_To_String);
+ Create_To_String (File_Open_Status_Type_Definition,
+ Iir_Predefined_Enum_To_String);
+
+ -- Predefined overload TO_STRING operations
+ Create_To_String (Real_Type_Definition,
+ Iir_Predefined_Real_To_String_Digits,
+ Name_Digits,
+ Natural_Subtype_Definition);
+ Create_To_String (Real_Type_Definition,
+ Iir_Predefined_Real_To_String_Format,
+ Name_Format,
+ String_Type_Definition);
+ Create_To_String (Time_Type_Definition,
+ Iir_Predefined_Time_To_String_Unit,
+ Name_Unit,
+ Time_Subtype_Definition);
end if;
end Create_Std_Standard_Package;