diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-08-16 22:31:06 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-08-17 21:40:42 +0200 |
commit | 7d034fc52f6b15e743ca91e7b1a4314bf31623b9 (patch) | |
tree | 60c6c4deb857b89e5d9f86b55d9fee8160313545 /src | |
parent | 60b4bf2b63cdad9cfd36106f084fcbe94d01d4d5 (diff) | |
download | ghdl-7d034fc52f6b15e743ca91e7b1a4314bf31623b9.tar.gz ghdl-7d034fc52f6b15e743ca91e7b1a4314bf31623b9.tar.bz2 ghdl-7d034fc52f6b15e743ca91e7b1a4314bf31623b9.zip |
vhdl: parse verification unit (WIP).
Diffstat (limited to 'src')
-rw-r--r-- | src/libraries.adb | 34 | ||||
-rw-r--r-- | src/vhdl/vhdl-canon.adb | 2 | ||||
-rw-r--r-- | src/vhdl/vhdl-elocations.adb | 1 | ||||
-rw-r--r-- | src/vhdl/vhdl-elocations.ads | 2 | ||||
-rw-r--r-- | src/vhdl/vhdl-errors.adb | 2 | ||||
-rw-r--r-- | src/vhdl/vhdl-nodes.adb | 5 | ||||
-rw-r--r-- | src/vhdl/vhdl-nodes.ads | 53 | ||||
-rw-r--r-- | src/vhdl/vhdl-nodes_meta.adb | 499 | ||||
-rw-r--r-- | src/vhdl/vhdl-parse.adb | 201 | ||||
-rw-r--r-- | src/vhdl/vhdl-post_sems.adb | 3 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem.adb | 14 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_psl.adb | 85 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_psl.ads | 8 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_stmts.adb | 2 | ||||
-rw-r--r-- | src/vhdl/vhdl-utils.adb | 1 |
15 files changed, 549 insertions, 363 deletions
diff --git a/src/libraries.adb b/src/libraries.adb index 8dba5683d..cbdca93c0 100644 --- a/src/libraries.adb +++ b/src/libraries.adb @@ -507,21 +507,17 @@ package body Libraries is else Library_Unit := Create_Iir (Iir_Kind_Package_Declaration); end if; - when Tok_With => - if Library_Unit = Null_Iir - or else - Get_Kind (Library_Unit) /= Iir_Kind_Architecture_Body - then - Log_Line ("load_library: invalid use of 'with'"); - raise Internal_Error; - end if; - Scan_Expect (Tok_Configuration); - Scan_Expect (Tok_Colon); - Scan; - goto Next_Line; when Tok_Context => - Library_Unit := - Create_Iir (Iir_Kind_Context_Declaration); + Library_Unit := Create_Iir (Iir_Kind_Context_Declaration); + Scan; + when Tok_Vunit => + Library_Unit := Create_Iir (Iir_Kind_Vunit_Declaration); + Scan; + when Tok_Vmode => + Library_Unit := Create_Iir (Iir_Kind_Vmode_Declaration); + Scan; + when Tok_Vprop => + Library_Unit := Create_Iir (Iir_Kind_Vprop_Declaration); Scan; when others => Log_Line @@ -606,7 +602,6 @@ package body Libraries is Last_Design_Unit := Design_Unit; Set_Last_Design_Unit (Design_File, Design_Unit); end if; - << Next_Line >> null; end loop; Set_Date (Library, Max_Date); @@ -1402,6 +1397,15 @@ package body Libraries is when Iir_Kind_Context_Declaration => WR ("context "); WR (Image_Identifier (Library_Unit)); + when Iir_Kind_Vunit_Declaration => + WR ("vunit "); + WR (Image_Identifier (Library_Unit)); + when Iir_Kind_Vprop_Declaration => + WR ("vprop "); + WR (Image_Identifier (Library_Unit)); + when Iir_Kind_Vmode_Declaration => + WR ("vmode "); + WR (Image_Identifier (Library_Unit)); when others => Error_Kind ("save_library", Library_Unit); end case; diff --git a/src/vhdl/vhdl-canon.adb b/src/vhdl/vhdl-canon.adb index c1cd2d13f..1ee405a1f 100644 --- a/src/vhdl/vhdl-canon.adb +++ b/src/vhdl/vhdl-canon.adb @@ -3267,6 +3267,8 @@ package body Vhdl.Canon is Set_Library_Unit (Unit, El); when Iir_Kind_Context_Declaration => null; + when Iir_Kinds_Verification_Unit => + null; when others => Error_Kind ("canonicalize2", El); end case; diff --git a/src/vhdl/vhdl-elocations.adb b/src/vhdl/vhdl-elocations.adb index a42d5e009..bd831b56f 100644 --- a/src/vhdl/vhdl-elocations.adb +++ b/src/vhdl/vhdl-elocations.adb @@ -231,6 +231,7 @@ package body Vhdl.Elocations is | Iir_Kind_Entity_Aspect_Entity | Iir_Kind_Entity_Aspect_Configuration | Iir_Kind_Entity_Aspect_Open + | Iir_Kind_Psl_Hierarchical_Name | Iir_Kind_Block_Configuration | Iir_Kind_Component_Configuration | Iir_Kind_Binding_Indication diff --git a/src/vhdl/vhdl-elocations.ads b/src/vhdl/vhdl-elocations.ads index fd2401289..80a32da90 100644 --- a/src/vhdl/vhdl-elocations.ads +++ b/src/vhdl/vhdl-elocations.ads @@ -79,6 +79,8 @@ package Vhdl.Elocations is -- Iir_Kind_Entity_Aspect_Configuration (None) + -- Iir_Kind_Psl_Hierarchical_Name (None) + -- Iir_Kind_Block_Configuration (None) -- Iir_Kind_Binding_Indication (None) diff --git a/src/vhdl/vhdl-errors.adb b/src/vhdl/vhdl-errors.adb index b9183fbbc..6fcdacf67 100644 --- a/src/vhdl/vhdl-errors.adb +++ b/src/vhdl/vhdl-errors.adb @@ -378,6 +378,8 @@ package body Vhdl.Errors is return "configuration entity aspect"; when Iir_Kind_Entity_Aspect_Open => return "open entity aspect"; + when Iir_Kind_Psl_Hierarchical_Name => + return "hierarchical name"; when Iir_Kinds_Monadic_Operator | Iir_Kinds_Dyadic_Operator => diff --git a/src/vhdl/vhdl-nodes.adb b/src/vhdl/vhdl-nodes.adb index 5bf1e00ed..19a65af85 100644 --- a/src/vhdl/vhdl-nodes.adb +++ b/src/vhdl/vhdl-nodes.adb @@ -1002,6 +1002,7 @@ package body Vhdl.Nodes is | Iir_Kind_Entity_Aspect_Entity | Iir_Kind_Entity_Aspect_Configuration | Iir_Kind_Entity_Aspect_Open + | Iir_Kind_Psl_Hierarchical_Name | Iir_Kind_Block_Configuration | Iir_Kind_Component_Configuration | Iir_Kind_Entity_Class @@ -2656,7 +2657,7 @@ package body Vhdl.Nodes is pragma Assert (Vunit /= Null_Iir); pragma Assert (Has_Vunit_Item_Chain (Get_Kind (Vunit)), "no field Vunit_Item_Chain"); - return Get_Field4 (Vunit); + return Get_Field5 (Vunit); end Get_Vunit_Item_Chain; procedure Set_Vunit_Item_Chain (Vunit : Iir; Chain : Iir) is @@ -2664,7 +2665,7 @@ package body Vhdl.Nodes is pragma Assert (Vunit /= Null_Iir); pragma Assert (Has_Vunit_Item_Chain (Get_Kind (Vunit)), "no field Vunit_Item_Chain"); - Set_Field4 (Vunit, Chain); + Set_Field5 (Vunit, Chain); end Set_Vunit_Item_Chain; function Get_Block_Configuration (Target : Iir) return Iir is diff --git a/src/vhdl/vhdl-nodes.ads b/src/vhdl/vhdl-nodes.ads index 744e5c88c..79ad569fc 100644 --- a/src/vhdl/vhdl-nodes.ads +++ b/src/vhdl/vhdl-nodes.ads @@ -595,6 +595,12 @@ package Vhdl.Nodes is -- -- Get/Set_Configuration_Name (Field1) + -- Iir_Kind_Psl_Hierarchical_Name (Short) + -- + -- Get/Set_Entity_Name (Field2) + -- + -- Get/Set_Architecture (Field3) + -- Iir_Kind_Block_Configuration (Short) -- -- LRM08 3.4.2 Block configuration @@ -1031,27 +1037,6 @@ package Vhdl.Nodes is -- -- Get/Set_End_Has_Identifier (Flag9) - -- Iir_Kind_Library_Declaration (Short) - -- - -- Design files in the library. - -- Get/Set_Design_File_Chain (Field1) - -- - -- Get/Set_Chain (Field2) - -- - -- This node is used to contain all a library. Only internaly used. - -- Name (identifier) of the library. - -- Get/Set_Identifier (Field3) - -- - -- Most recent date in this library. - -- Get/Set_Date (Field4) - -- - -- Get/Set_Library_Directory (Field5) - -- - -- Used to compute dependences. - -- Get/Set_Elab_Flag (Flag3) - -- - -- Get/Set_Visible_Flag (Flag4) - -- Iir_Kind_Vunit_Declaration (Short) -- Iir_Kind_Vmode_Declaration (Short) -- Iir_Kind_Vprop_Declaration (Short) @@ -1065,7 +1050,7 @@ package Vhdl.Nodes is -- -- Get/Set_Inherit_Spec_Chain (Field2) -- - -- Get/Set_Vunit_Item_Chain (Field4) + -- Get/Set_Vunit_Item_Chain (Field5) -- -- Get/Set_Visible_Flag (Flag4) -- @@ -1077,6 +1062,27 @@ package Vhdl.Nodes is -- -- Get/Set_Has_Begin (Flag10) + -- Iir_Kind_Library_Declaration (Short) + -- + -- Design files in the library. + -- Get/Set_Design_File_Chain (Field1) + -- + -- Get/Set_Chain (Field2) + -- + -- This node is used to contain all a library. Only internaly used. + -- Name (identifier) of the library. + -- Get/Set_Identifier (Field3) + -- + -- Most recent date in this library. + -- Get/Set_Date (Field4) + -- + -- Get/Set_Library_Directory (Field5) + -- + -- Used to compute dependences. + -- Get/Set_Elab_Flag (Flag3) + -- + -- Get/Set_Visible_Flag (Flag4) + -- Iir_Kind_Component_Declaration (Medium) -- -- Get/Set_Parent (Field0) @@ -4210,6 +4216,7 @@ package Vhdl.Nodes is Iir_Kind_Entity_Aspect_Entity, Iir_Kind_Entity_Aspect_Configuration, Iir_Kind_Entity_Aspect_Open, + Iir_Kind_Psl_Hierarchical_Name, Iir_Kind_Block_Configuration, Iir_Kind_Block_Header, Iir_Kind_Component_Configuration, @@ -6544,7 +6551,7 @@ package Vhdl.Nodes is function Get_Inherit_Spec_Chain (Vunit : Iir) return Iir; procedure Set_Inherit_Spec_Chain (Vunit : Iir; Chain : Iir); - -- Field: Field4 Chain + -- Field: Field5 Chain function Get_Vunit_Item_Chain (Vunit : Iir) return Iir; procedure Set_Vunit_Item_Chain (Vunit : Iir; Chain : Iir); diff --git a/src/vhdl/vhdl-nodes_meta.adb b/src/vhdl/vhdl-nodes_meta.adb index ad17a56ee..91f1608d2 100644 --- a/src/vhdl/vhdl-nodes_meta.adb +++ b/src/vhdl/vhdl-nodes_meta.adb @@ -1088,6 +1088,8 @@ package body Vhdl.Nodes_Meta is return "entity_aspect_configuration"; when Iir_Kind_Entity_Aspect_Open => return "entity_aspect_open"; + when Iir_Kind_Psl_Hierarchical_Name => + return "psl_hierarchical_name"; when Iir_Kind_Block_Configuration => return "block_configuration"; when Iir_Kind_Block_Header => @@ -2458,6 +2460,9 @@ package body Vhdl.Nodes_Meta is -- Iir_Kind_Entity_Aspect_Configuration Field_Configuration_Name, -- Iir_Kind_Entity_Aspect_Open + -- Iir_Kind_Psl_Hierarchical_Name + Field_Entity_Name, + Field_Architecture, -- Iir_Kind_Block_Configuration Field_Parent, Field_Declaration_Chain, @@ -4546,248 +4551,249 @@ package body Vhdl.Nodes_Meta is Iir_Kind_Entity_Aspect_Entity => 182, Iir_Kind_Entity_Aspect_Configuration => 183, Iir_Kind_Entity_Aspect_Open => 183, - Iir_Kind_Block_Configuration => 189, - Iir_Kind_Block_Header => 193, - Iir_Kind_Component_Configuration => 200, - Iir_Kind_Binding_Indication => 204, - Iir_Kind_Entity_Class => 206, - Iir_Kind_Attribute_Value => 214, - Iir_Kind_Signature => 217, - Iir_Kind_Aggregate_Info => 224, - Iir_Kind_Procedure_Call => 228, - Iir_Kind_Record_Element_Constraint => 234, - Iir_Kind_Array_Element_Resolution => 236, - Iir_Kind_Record_Resolution => 237, - Iir_Kind_Record_Element_Resolution => 240, - Iir_Kind_Attribute_Specification => 248, - Iir_Kind_Disconnection_Specification => 254, - Iir_Kind_Configuration_Specification => 260, - Iir_Kind_Access_Type_Definition => 268, - Iir_Kind_Incomplete_Type_Definition => 276, - Iir_Kind_Interface_Type_Definition => 283, - Iir_Kind_File_Type_Definition => 290, - Iir_Kind_Protected_Type_Declaration => 299, - Iir_Kind_Record_Type_Definition => 310, - Iir_Kind_Array_Type_Definition => 322, - Iir_Kind_Array_Subtype_Definition => 337, - Iir_Kind_Record_Subtype_Definition => 350, - Iir_Kind_Access_Subtype_Definition => 358, - Iir_Kind_Physical_Subtype_Definition => 368, - Iir_Kind_Floating_Subtype_Definition => 379, - Iir_Kind_Integer_Subtype_Definition => 389, - Iir_Kind_Enumeration_Subtype_Definition => 399, - Iir_Kind_Enumeration_Type_Definition => 410, - Iir_Kind_Integer_Type_Definition => 418, - Iir_Kind_Floating_Type_Definition => 426, - Iir_Kind_Physical_Type_Definition => 437, - Iir_Kind_Range_Expression => 445, - Iir_Kind_Protected_Type_Body => 452, - Iir_Kind_Wildcard_Type_Definition => 457, - Iir_Kind_Subtype_Definition => 464, - Iir_Kind_Scalar_Nature_Definition => 468, - Iir_Kind_Overload_List => 469, - Iir_Kind_Entity_Declaration => 481, - Iir_Kind_Configuration_Declaration => 490, - Iir_Kind_Context_Declaration => 496, - Iir_Kind_Package_Declaration => 511, - Iir_Kind_Package_Instantiation_Declaration => 525, - Iir_Kind_Vmode_Declaration => 535, - Iir_Kind_Vprop_Declaration => 545, - Iir_Kind_Vunit_Declaration => 555, - Iir_Kind_Package_Body => 563, - Iir_Kind_Architecture_Body => 575, - Iir_Kind_Type_Declaration => 582, - Iir_Kind_Anonymous_Type_Declaration => 588, - Iir_Kind_Subtype_Declaration => 595, - Iir_Kind_Nature_Declaration => 601, - Iir_Kind_Subnature_Declaration => 607, - Iir_Kind_Package_Header => 609, - Iir_Kind_Unit_Declaration => 618, - Iir_Kind_Library_Declaration => 625, - Iir_Kind_Component_Declaration => 635, - Iir_Kind_Attribute_Declaration => 642, - Iir_Kind_Group_Template_Declaration => 648, - Iir_Kind_Group_Declaration => 655, - Iir_Kind_Element_Declaration => 662, - Iir_Kind_Non_Object_Alias_Declaration => 670, - Iir_Kind_Psl_Declaration => 678, - Iir_Kind_Psl_Endpoint_Declaration => 692, - Iir_Kind_Terminal_Declaration => 699, - Iir_Kind_Free_Quantity_Declaration => 710, - Iir_Kind_Across_Quantity_Declaration => 722, - Iir_Kind_Through_Quantity_Declaration => 734, - Iir_Kind_Enumeration_Literal => 745, - Iir_Kind_Function_Declaration => 770, - Iir_Kind_Procedure_Declaration => 794, - Iir_Kind_Function_Body => 804, - Iir_Kind_Procedure_Body => 815, - Iir_Kind_Object_Alias_Declaration => 826, - Iir_Kind_File_Declaration => 840, - Iir_Kind_Guard_Signal_Declaration => 853, - Iir_Kind_Signal_Declaration => 870, - Iir_Kind_Variable_Declaration => 883, - Iir_Kind_Constant_Declaration => 897, - Iir_Kind_Iterator_Declaration => 908, - Iir_Kind_Interface_Constant_Declaration => 924, - Iir_Kind_Interface_Variable_Declaration => 940, - Iir_Kind_Interface_Signal_Declaration => 961, - Iir_Kind_Interface_File_Declaration => 977, - Iir_Kind_Interface_Type_Declaration => 987, - Iir_Kind_Interface_Package_Declaration => 999, - Iir_Kind_Interface_Function_Declaration => 1016, - Iir_Kind_Interface_Procedure_Declaration => 1029, - Iir_Kind_Anonymous_Signal_Declaration => 1038, - Iir_Kind_Signal_Attribute_Declaration => 1041, - Iir_Kind_Identity_Operator => 1045, - Iir_Kind_Negation_Operator => 1049, - Iir_Kind_Absolute_Operator => 1053, - Iir_Kind_Not_Operator => 1057, - Iir_Kind_Implicit_Condition_Operator => 1061, - Iir_Kind_Condition_Operator => 1065, - Iir_Kind_Reduction_And_Operator => 1069, - Iir_Kind_Reduction_Or_Operator => 1073, - Iir_Kind_Reduction_Nand_Operator => 1077, - Iir_Kind_Reduction_Nor_Operator => 1081, - Iir_Kind_Reduction_Xor_Operator => 1085, - Iir_Kind_Reduction_Xnor_Operator => 1089, - Iir_Kind_And_Operator => 1094, - Iir_Kind_Or_Operator => 1099, - Iir_Kind_Nand_Operator => 1104, - Iir_Kind_Nor_Operator => 1109, - Iir_Kind_Xor_Operator => 1114, - Iir_Kind_Xnor_Operator => 1119, - Iir_Kind_Equality_Operator => 1124, - Iir_Kind_Inequality_Operator => 1129, - Iir_Kind_Less_Than_Operator => 1134, - Iir_Kind_Less_Than_Or_Equal_Operator => 1139, - Iir_Kind_Greater_Than_Operator => 1144, - Iir_Kind_Greater_Than_Or_Equal_Operator => 1149, - Iir_Kind_Match_Equality_Operator => 1154, - Iir_Kind_Match_Inequality_Operator => 1159, - Iir_Kind_Match_Less_Than_Operator => 1164, - Iir_Kind_Match_Less_Than_Or_Equal_Operator => 1169, - Iir_Kind_Match_Greater_Than_Operator => 1174, - Iir_Kind_Match_Greater_Than_Or_Equal_Operator => 1179, - Iir_Kind_Sll_Operator => 1184, - Iir_Kind_Sla_Operator => 1189, - Iir_Kind_Srl_Operator => 1194, - Iir_Kind_Sra_Operator => 1199, - Iir_Kind_Rol_Operator => 1204, - Iir_Kind_Ror_Operator => 1209, - Iir_Kind_Addition_Operator => 1214, - Iir_Kind_Substraction_Operator => 1219, - Iir_Kind_Concatenation_Operator => 1224, - Iir_Kind_Multiplication_Operator => 1229, - Iir_Kind_Division_Operator => 1234, - Iir_Kind_Modulus_Operator => 1239, - Iir_Kind_Remainder_Operator => 1244, - Iir_Kind_Exponentiation_Operator => 1249, - Iir_Kind_Function_Call => 1257, - Iir_Kind_Aggregate => 1264, - Iir_Kind_Parenthesis_Expression => 1267, - Iir_Kind_Qualified_Expression => 1271, - Iir_Kind_Type_Conversion => 1276, - Iir_Kind_Allocator_By_Expression => 1280, - Iir_Kind_Allocator_By_Subtype => 1285, - Iir_Kind_Selected_Element => 1293, - Iir_Kind_Dereference => 1298, - Iir_Kind_Implicit_Dereference => 1303, - Iir_Kind_Slice_Name => 1310, - Iir_Kind_Indexed_Name => 1316, - Iir_Kind_Psl_Expression => 1318, - Iir_Kind_Sensitized_Process_Statement => 1339, - Iir_Kind_Process_Statement => 1359, - Iir_Kind_Concurrent_Simple_Signal_Assignment => 1371, - Iir_Kind_Concurrent_Conditional_Signal_Assignment => 1383, - Iir_Kind_Concurrent_Selected_Signal_Assignment => 1396, - Iir_Kind_Concurrent_Assertion_Statement => 1404, - Iir_Kind_Concurrent_Procedure_Call_Statement => 1411, - Iir_Kind_Psl_Assert_Directive => 1424, - Iir_Kind_Psl_Assume_Directive => 1435, - Iir_Kind_Psl_Cover_Directive => 1447, - Iir_Kind_Psl_Restrict_Directive => 1458, - Iir_Kind_Block_Statement => 1472, - Iir_Kind_If_Generate_Statement => 1483, - Iir_Kind_Case_Generate_Statement => 1492, - Iir_Kind_For_Generate_Statement => 1501, - Iir_Kind_Component_Instantiation_Statement => 1512, - Iir_Kind_Psl_Default_Clock => 1516, - Iir_Kind_Simple_Simultaneous_Statement => 1523, - Iir_Kind_Generate_Statement_Body => 1534, - Iir_Kind_If_Generate_Else_Clause => 1540, - Iir_Kind_Simple_Signal_Assignment_Statement => 1550, - Iir_Kind_Conditional_Signal_Assignment_Statement => 1560, - Iir_Kind_Selected_Waveform_Assignment_Statement => 1571, - Iir_Kind_Null_Statement => 1575, - Iir_Kind_Assertion_Statement => 1582, - Iir_Kind_Report_Statement => 1588, - Iir_Kind_Wait_Statement => 1596, - Iir_Kind_Variable_Assignment_Statement => 1603, - Iir_Kind_Conditional_Variable_Assignment_Statement => 1610, - Iir_Kind_Return_Statement => 1616, - Iir_Kind_For_Loop_Statement => 1625, - Iir_Kind_While_Loop_Statement => 1634, - Iir_Kind_Next_Statement => 1641, - Iir_Kind_Exit_Statement => 1648, - Iir_Kind_Case_Statement => 1656, - Iir_Kind_Procedure_Call_Statement => 1662, - Iir_Kind_If_Statement => 1672, - Iir_Kind_Elsif => 1678, - Iir_Kind_Character_Literal => 1686, - Iir_Kind_Simple_Name => 1694, - Iir_Kind_Selected_Name => 1703, - Iir_Kind_Operator_Symbol => 1709, - Iir_Kind_Reference_Name => 1714, - Iir_Kind_External_Constant_Name => 1722, - Iir_Kind_External_Signal_Name => 1730, - Iir_Kind_External_Variable_Name => 1739, - Iir_Kind_Selected_By_All_Name => 1745, - Iir_Kind_Parenthesis_Name => 1750, - Iir_Kind_Package_Pathname => 1754, - Iir_Kind_Absolute_Pathname => 1755, - Iir_Kind_Relative_Pathname => 1756, - Iir_Kind_Pathname_Element => 1761, - Iir_Kind_Base_Attribute => 1763, - Iir_Kind_Subtype_Attribute => 1768, - Iir_Kind_Element_Attribute => 1773, - Iir_Kind_Left_Type_Attribute => 1778, - Iir_Kind_Right_Type_Attribute => 1783, - Iir_Kind_High_Type_Attribute => 1788, - Iir_Kind_Low_Type_Attribute => 1793, - Iir_Kind_Ascending_Type_Attribute => 1798, - Iir_Kind_Image_Attribute => 1804, - Iir_Kind_Value_Attribute => 1810, - Iir_Kind_Pos_Attribute => 1816, - Iir_Kind_Val_Attribute => 1822, - Iir_Kind_Succ_Attribute => 1828, - Iir_Kind_Pred_Attribute => 1834, - Iir_Kind_Leftof_Attribute => 1840, - Iir_Kind_Rightof_Attribute => 1846, - Iir_Kind_Delayed_Attribute => 1855, - Iir_Kind_Stable_Attribute => 1864, - Iir_Kind_Quiet_Attribute => 1873, - Iir_Kind_Transaction_Attribute => 1882, - Iir_Kind_Event_Attribute => 1886, - Iir_Kind_Active_Attribute => 1890, - Iir_Kind_Last_Event_Attribute => 1894, - Iir_Kind_Last_Active_Attribute => 1898, - Iir_Kind_Last_Value_Attribute => 1902, - Iir_Kind_Driving_Attribute => 1906, - Iir_Kind_Driving_Value_Attribute => 1910, - Iir_Kind_Behavior_Attribute => 1910, - Iir_Kind_Structure_Attribute => 1910, - Iir_Kind_Simple_Name_Attribute => 1917, - Iir_Kind_Instance_Name_Attribute => 1922, - Iir_Kind_Path_Name_Attribute => 1927, - Iir_Kind_Left_Array_Attribute => 1934, - Iir_Kind_Right_Array_Attribute => 1941, - Iir_Kind_High_Array_Attribute => 1948, - Iir_Kind_Low_Array_Attribute => 1955, - Iir_Kind_Length_Array_Attribute => 1962, - Iir_Kind_Ascending_Array_Attribute => 1969, - Iir_Kind_Range_Array_Attribute => 1976, - Iir_Kind_Reverse_Range_Array_Attribute => 1983, - Iir_Kind_Attribute_Name => 1992 + Iir_Kind_Psl_Hierarchical_Name => 185, + Iir_Kind_Block_Configuration => 191, + Iir_Kind_Block_Header => 195, + Iir_Kind_Component_Configuration => 202, + Iir_Kind_Binding_Indication => 206, + Iir_Kind_Entity_Class => 208, + Iir_Kind_Attribute_Value => 216, + Iir_Kind_Signature => 219, + Iir_Kind_Aggregate_Info => 226, + Iir_Kind_Procedure_Call => 230, + Iir_Kind_Record_Element_Constraint => 236, + Iir_Kind_Array_Element_Resolution => 238, + Iir_Kind_Record_Resolution => 239, + Iir_Kind_Record_Element_Resolution => 242, + Iir_Kind_Attribute_Specification => 250, + Iir_Kind_Disconnection_Specification => 256, + Iir_Kind_Configuration_Specification => 262, + Iir_Kind_Access_Type_Definition => 270, + Iir_Kind_Incomplete_Type_Definition => 278, + Iir_Kind_Interface_Type_Definition => 285, + Iir_Kind_File_Type_Definition => 292, + Iir_Kind_Protected_Type_Declaration => 301, + Iir_Kind_Record_Type_Definition => 312, + Iir_Kind_Array_Type_Definition => 324, + Iir_Kind_Array_Subtype_Definition => 339, + Iir_Kind_Record_Subtype_Definition => 352, + Iir_Kind_Access_Subtype_Definition => 360, + Iir_Kind_Physical_Subtype_Definition => 370, + Iir_Kind_Floating_Subtype_Definition => 381, + Iir_Kind_Integer_Subtype_Definition => 391, + Iir_Kind_Enumeration_Subtype_Definition => 401, + Iir_Kind_Enumeration_Type_Definition => 412, + Iir_Kind_Integer_Type_Definition => 420, + Iir_Kind_Floating_Type_Definition => 428, + Iir_Kind_Physical_Type_Definition => 439, + Iir_Kind_Range_Expression => 447, + Iir_Kind_Protected_Type_Body => 454, + Iir_Kind_Wildcard_Type_Definition => 459, + Iir_Kind_Subtype_Definition => 466, + Iir_Kind_Scalar_Nature_Definition => 470, + Iir_Kind_Overload_List => 471, + Iir_Kind_Entity_Declaration => 483, + Iir_Kind_Configuration_Declaration => 492, + Iir_Kind_Context_Declaration => 498, + Iir_Kind_Package_Declaration => 513, + Iir_Kind_Package_Instantiation_Declaration => 527, + Iir_Kind_Vmode_Declaration => 537, + Iir_Kind_Vprop_Declaration => 547, + Iir_Kind_Vunit_Declaration => 557, + Iir_Kind_Package_Body => 565, + Iir_Kind_Architecture_Body => 577, + Iir_Kind_Type_Declaration => 584, + Iir_Kind_Anonymous_Type_Declaration => 590, + Iir_Kind_Subtype_Declaration => 597, + Iir_Kind_Nature_Declaration => 603, + Iir_Kind_Subnature_Declaration => 609, + Iir_Kind_Package_Header => 611, + Iir_Kind_Unit_Declaration => 620, + Iir_Kind_Library_Declaration => 627, + Iir_Kind_Component_Declaration => 637, + Iir_Kind_Attribute_Declaration => 644, + Iir_Kind_Group_Template_Declaration => 650, + Iir_Kind_Group_Declaration => 657, + Iir_Kind_Element_Declaration => 664, + Iir_Kind_Non_Object_Alias_Declaration => 672, + Iir_Kind_Psl_Declaration => 680, + Iir_Kind_Psl_Endpoint_Declaration => 694, + Iir_Kind_Terminal_Declaration => 701, + Iir_Kind_Free_Quantity_Declaration => 712, + Iir_Kind_Across_Quantity_Declaration => 724, + Iir_Kind_Through_Quantity_Declaration => 736, + Iir_Kind_Enumeration_Literal => 747, + Iir_Kind_Function_Declaration => 772, + Iir_Kind_Procedure_Declaration => 796, + Iir_Kind_Function_Body => 806, + Iir_Kind_Procedure_Body => 817, + Iir_Kind_Object_Alias_Declaration => 828, + Iir_Kind_File_Declaration => 842, + Iir_Kind_Guard_Signal_Declaration => 855, + Iir_Kind_Signal_Declaration => 872, + Iir_Kind_Variable_Declaration => 885, + Iir_Kind_Constant_Declaration => 899, + Iir_Kind_Iterator_Declaration => 910, + Iir_Kind_Interface_Constant_Declaration => 926, + Iir_Kind_Interface_Variable_Declaration => 942, + Iir_Kind_Interface_Signal_Declaration => 963, + Iir_Kind_Interface_File_Declaration => 979, + Iir_Kind_Interface_Type_Declaration => 989, + Iir_Kind_Interface_Package_Declaration => 1001, + Iir_Kind_Interface_Function_Declaration => 1018, + Iir_Kind_Interface_Procedure_Declaration => 1031, + Iir_Kind_Anonymous_Signal_Declaration => 1040, + Iir_Kind_Signal_Attribute_Declaration => 1043, + Iir_Kind_Identity_Operator => 1047, + Iir_Kind_Negation_Operator => 1051, + Iir_Kind_Absolute_Operator => 1055, + Iir_Kind_Not_Operator => 1059, + Iir_Kind_Implicit_Condition_Operator => 1063, + Iir_Kind_Condition_Operator => 1067, + Iir_Kind_Reduction_And_Operator => 1071, + Iir_Kind_Reduction_Or_Operator => 1075, + Iir_Kind_Reduction_Nand_Operator => 1079, + Iir_Kind_Reduction_Nor_Operator => 1083, + Iir_Kind_Reduction_Xor_Operator => 1087, + Iir_Kind_Reduction_Xnor_Operator => 1091, + Iir_Kind_And_Operator => 1096, + Iir_Kind_Or_Operator => 1101, + Iir_Kind_Nand_Operator => 1106, + Iir_Kind_Nor_Operator => 1111, + Iir_Kind_Xor_Operator => 1116, + Iir_Kind_Xnor_Operator => 1121, + Iir_Kind_Equality_Operator => 1126, + Iir_Kind_Inequality_Operator => 1131, + Iir_Kind_Less_Than_Operator => 1136, + Iir_Kind_Less_Than_Or_Equal_Operator => 1141, + Iir_Kind_Greater_Than_Operator => 1146, + Iir_Kind_Greater_Than_Or_Equal_Operator => 1151, + Iir_Kind_Match_Equality_Operator => 1156, + Iir_Kind_Match_Inequality_Operator => 1161, + Iir_Kind_Match_Less_Than_Operator => 1166, + Iir_Kind_Match_Less_Than_Or_Equal_Operator => 1171, + Iir_Kind_Match_Greater_Than_Operator => 1176, + Iir_Kind_Match_Greater_Than_Or_Equal_Operator => 1181, + Iir_Kind_Sll_Operator => 1186, + Iir_Kind_Sla_Operator => 1191, + Iir_Kind_Srl_Operator => 1196, + Iir_Kind_Sra_Operator => 1201, + Iir_Kind_Rol_Operator => 1206, + Iir_Kind_Ror_Operator => 1211, + Iir_Kind_Addition_Operator => 1216, + Iir_Kind_Substraction_Operator => 1221, + Iir_Kind_Concatenation_Operator => 1226, + Iir_Kind_Multiplication_Operator => 1231, + Iir_Kind_Division_Operator => 1236, + Iir_Kind_Modulus_Operator => 1241, + Iir_Kind_Remainder_Operator => 1246, + Iir_Kind_Exponentiation_Operator => 1251, + Iir_Kind_Function_Call => 1259, + Iir_Kind_Aggregate => 1266, + Iir_Kind_Parenthesis_Expression => 1269, + Iir_Kind_Qualified_Expression => 1273, + Iir_Kind_Type_Conversion => 1278, + Iir_Kind_Allocator_By_Expression => 1282, + Iir_Kind_Allocator_By_Subtype => 1287, + Iir_Kind_Selected_Element => 1295, + Iir_Kind_Dereference => 1300, + Iir_Kind_Implicit_Dereference => 1305, + Iir_Kind_Slice_Name => 1312, + Iir_Kind_Indexed_Name => 1318, + Iir_Kind_Psl_Expression => 1320, + Iir_Kind_Sensitized_Process_Statement => 1341, + Iir_Kind_Process_Statement => 1361, + Iir_Kind_Concurrent_Simple_Signal_Assignment => 1373, + Iir_Kind_Concurrent_Conditional_Signal_Assignment => 1385, + Iir_Kind_Concurrent_Selected_Signal_Assignment => 1398, + Iir_Kind_Concurrent_Assertion_Statement => 1406, + Iir_Kind_Concurrent_Procedure_Call_Statement => 1413, + Iir_Kind_Psl_Assert_Directive => 1426, + Iir_Kind_Psl_Assume_Directive => 1437, + Iir_Kind_Psl_Cover_Directive => 1449, + Iir_Kind_Psl_Restrict_Directive => 1460, + Iir_Kind_Block_Statement => 1474, + Iir_Kind_If_Generate_Statement => 1485, + Iir_Kind_Case_Generate_Statement => 1494, + Iir_Kind_For_Generate_Statement => 1503, + Iir_Kind_Component_Instantiation_Statement => 1514, + Iir_Kind_Psl_Default_Clock => 1518, + Iir_Kind_Simple_Simultaneous_Statement => 1525, + Iir_Kind_Generate_Statement_Body => 1536, + Iir_Kind_If_Generate_Else_Clause => 1542, + Iir_Kind_Simple_Signal_Assignment_Statement => 1552, + Iir_Kind_Conditional_Signal_Assignment_Statement => 1562, + Iir_Kind_Selected_Waveform_Assignment_Statement => 1573, + Iir_Kind_Null_Statement => 1577, + Iir_Kind_Assertion_Statement => 1584, + Iir_Kind_Report_Statement => 1590, + Iir_Kind_Wait_Statement => 1598, + Iir_Kind_Variable_Assignment_Statement => 1605, + Iir_Kind_Conditional_Variable_Assignment_Statement => 1612, + Iir_Kind_Return_Statement => 1618, + Iir_Kind_For_Loop_Statement => 1627, + Iir_Kind_While_Loop_Statement => 1636, + Iir_Kind_Next_Statement => 1643, + Iir_Kind_Exit_Statement => 1650, + Iir_Kind_Case_Statement => 1658, + Iir_Kind_Procedure_Call_Statement => 1664, + Iir_Kind_If_Statement => 1674, + Iir_Kind_Elsif => 1680, + Iir_Kind_Character_Literal => 1688, + Iir_Kind_Simple_Name => 1696, + Iir_Kind_Selected_Name => 1705, + Iir_Kind_Operator_Symbol => 1711, + Iir_Kind_Reference_Name => 1716, + Iir_Kind_External_Constant_Name => 1724, + Iir_Kind_External_Signal_Name => 1732, + Iir_Kind_External_Variable_Name => 1741, + Iir_Kind_Selected_By_All_Name => 1747, + Iir_Kind_Parenthesis_Name => 1752, + Iir_Kind_Package_Pathname => 1756, + Iir_Kind_Absolute_Pathname => 1757, + Iir_Kind_Relative_Pathname => 1758, + Iir_Kind_Pathname_Element => 1763, + Iir_Kind_Base_Attribute => 1765, + Iir_Kind_Subtype_Attribute => 1770, + Iir_Kind_Element_Attribute => 1775, + Iir_Kind_Left_Type_Attribute => 1780, + Iir_Kind_Right_Type_Attribute => 1785, + Iir_Kind_High_Type_Attribute => 1790, + Iir_Kind_Low_Type_Attribute => 1795, + Iir_Kind_Ascending_Type_Attribute => 1800, + Iir_Kind_Image_Attribute => 1806, + Iir_Kind_Value_Attribute => 1812, + Iir_Kind_Pos_Attribute => 1818, + Iir_Kind_Val_Attribute => 1824, + Iir_Kind_Succ_Attribute => 1830, + Iir_Kind_Pred_Attribute => 1836, + Iir_Kind_Leftof_Attribute => 1842, + Iir_Kind_Rightof_Attribute => 1848, + Iir_Kind_Delayed_Attribute => 1857, + Iir_Kind_Stable_Attribute => 1866, + Iir_Kind_Quiet_Attribute => 1875, + Iir_Kind_Transaction_Attribute => 1884, + Iir_Kind_Event_Attribute => 1888, + Iir_Kind_Active_Attribute => 1892, + Iir_Kind_Last_Event_Attribute => 1896, + Iir_Kind_Last_Active_Attribute => 1900, + Iir_Kind_Last_Value_Attribute => 1904, + Iir_Kind_Driving_Attribute => 1908, + Iir_Kind_Driving_Value_Attribute => 1912, + Iir_Kind_Behavior_Attribute => 1912, + Iir_Kind_Structure_Attribute => 1912, + Iir_Kind_Simple_Name_Attribute => 1919, + Iir_Kind_Instance_Name_Attribute => 1924, + Iir_Kind_Path_Name_Attribute => 1929, + Iir_Kind_Left_Array_Attribute => 1936, + Iir_Kind_Right_Array_Attribute => 1943, + Iir_Kind_High_Array_Attribute => 1950, + Iir_Kind_Low_Array_Attribute => 1957, + Iir_Kind_Length_Array_Attribute => 1964, + Iir_Kind_Ascending_Array_Attribute => 1971, + Iir_Kind_Range_Array_Attribute => 1978, + Iir_Kind_Reverse_Range_Array_Attribute => 1985, + Iir_Kind_Attribute_Name => 1994 ); function Get_Fields_First (K : Iir_Kind) return Fields_Index is @@ -7249,7 +7255,13 @@ package body Vhdl.Nodes_Meta is function Has_Architecture (K : Iir_Kind) return Boolean is begin - return K = Iir_Kind_Entity_Aspect_Entity; + case K is + when Iir_Kind_Entity_Aspect_Entity + | Iir_Kind_Psl_Hierarchical_Name => + return True; + when others => + return False; + end case; end Has_Architecture; function Has_Block_Specification (K : Iir_Kind) return Boolean is @@ -7308,6 +7320,7 @@ package body Vhdl.Nodes_Meta is begin case K is when Iir_Kind_Entity_Aspect_Entity + | Iir_Kind_Psl_Hierarchical_Name | Iir_Kind_Configuration_Declaration | Iir_Kind_Architecture_Body => return True; diff --git a/src/vhdl/vhdl-parse.adb b/src/vhdl/vhdl-parse.adb index cf2a1968e..95b736592 100644 --- a/src/vhdl/vhdl-parse.adb +++ b/src/vhdl/vhdl-parse.adb @@ -157,26 +157,6 @@ package body Vhdl.Parse is end if; end Expect_Scan; - -- Transform the current token into an iir literal. - -- The current token must be either a character or an identifier. - function Current_Text return Iir is - Res: Iir; - begin - case Current_Token is - when Tok_Identifier => - Res := Create_Iir (Iir_Kind_Simple_Name); - when Tok_Character => - Res := Create_Iir (Iir_Kind_Character_Literal); - when others => - raise Internal_Error; - end case; - Set_Identifier (Res, Current_Identifier); - Invalidate_Current_Identifier; - Invalidate_Current_Token; - Set_Location (Res, Get_Token_Location); - return Res; - end Current_Text; - -- Expect the identifier for node RES. procedure Scan_Identifier (Res : Iir) is begin @@ -1346,6 +1326,24 @@ package body Vhdl.Parse is return Res; end Parse_External_Name; + -- LRM09 8.2 Simple names + -- simple_name ::= identifier + function Parse_Simple_Name return Iir + is + Res : Iir; + begin + Expect (Tok_Identifier); + + Res := Create_Iir (Iir_Kind_Simple_Name); + Set_Identifier (Res, Current_Identifier); + Set_Location (Res); + + -- Skip identifier + Scan; + + return Res; + end Parse_Simple_Name; + -- Precond: next token (identifier, string or '<<') -- Postcond: next token -- @@ -1366,12 +1364,7 @@ package body Vhdl.Parse is begin case Current_Token is when Tok_Identifier => - Res := Create_Iir (Iir_Kind_Simple_Name); - Set_Identifier (Res, Current_Identifier); - Set_Location (Res); - - -- Skip identifier - Scan; + Res := Parse_Simple_Name; when Tok_String => -- For operator symbol, such as: "+" (A, B). @@ -4415,7 +4408,8 @@ package body Vhdl.Parse is end Parse_Disconnection_Specification; -- Parse PSL clock_declaration at 'clock'. - function Parse_Psl_Default_Clock_Cont (Loc : Location_Type) return Iir + function Parse_Psl_Default_Clock_Cont + (Loc : Location_Type; Flag_Psl : Boolean) return Iir is Res : Iir; begin @@ -4435,7 +4429,7 @@ package body Vhdl.Parse is Set_Psl_Boolean (Res, Parse_Psl.Parse_Psl_Boolean); Vhdl.Scanner.Flag_Scan_In_Comment := False; - Vhdl.Scanner.Flag_Psl := False; + Vhdl.Scanner.Flag_Psl := Flag_Psl; Expect_Scan (Tok_Semi_Colon); @@ -4444,7 +4438,7 @@ package body Vhdl.Parse is -- 1850-2005 A.4.2 PSL declarations -- clock_declaration ::= DEFAULT CLOCK IS clock_expression ; - function Parse_Psl_Default_Clock return Iir + function Parse_Psl_Default_Clock (Flag_Psl : Boolean) return Iir is Loc : Location_Type; begin @@ -4456,7 +4450,7 @@ package body Vhdl.Parse is -- Skip 'default'. Scan; - return Parse_Psl_Default_Clock_Cont (Loc); + return Parse_Psl_Default_Clock_Cont (Loc, Flag_Psl); end Parse_Psl_Default_Clock; function Parse_Psl_Declaration return Iir @@ -5004,7 +4998,7 @@ package body Vhdl.Parse is when others => Error_Kind ("parse_declarative_part", Parent); end case; - Decl := Parse_Psl_Default_Clock; + Decl := Parse_Psl_Default_Clock (False); when Tok_Identifier => Error_Msg_Parse ("object class keyword such as 'variable' is expected"); @@ -5633,8 +5627,13 @@ package body Vhdl.Parse is end if; when Tok_Character => - Res := Current_Text; + Res := Create_Iir (Iir_Kind_Character_Literal); + Set_Identifier (Res, Current_Identifier); + Set_Location (Res); + + -- Skip character. Scan; + if Current_Token = Tok_Tick then Error_Msg_Parse ("prefix of an attribute can't be a character literal"); @@ -7816,10 +7815,7 @@ package body Vhdl.Parse is Scan; if Current_Token = Tok_Identifier then - Set_Architecture (Res, Current_Text); - - -- Skip identifier. - Scan; + Set_Architecture (Res, Parse_Simple_Name); else Expect (Tok_Identifier, "identifier for architecture"); end if; @@ -8553,7 +8549,8 @@ package body Vhdl.Parse is Error_Msg_Parse (+Target, "PSL default clock is a declaration"); Current_Token := Tok_Psl_Clock; - Res := Parse_Psl_Default_Clock_Cont (Get_Location (Target)); + Res := Parse_Psl_Default_Clock_Cont + (Get_Location (Target), False); return Res; end if; @@ -8581,10 +8578,11 @@ package body Vhdl.Parse is end Parse_Concurrent_Assignment; -- Parse end of PSL assert/cover statement. - procedure Parse_Psl_Assert_Report_Severity (Stmt : Iir) is + procedure Parse_Psl_Assert_Report_Severity + (Stmt : Iir; Flag_Psl : Boolean) is begin -- No more PSL tokens after the property. - Vhdl.Scanner.Flag_Psl := False; + Vhdl.Scanner.Flag_Psl := Flag_Psl; if Current_Token = Tok_Report then -- Skip 'report' @@ -8605,7 +8603,7 @@ package body Vhdl.Parse is Expect_Scan (Tok_Semi_Colon); end Parse_Psl_Assert_Report_Severity; - function Parse_Psl_Assert_Directive return Iir + function Parse_Psl_Assert_Directive (Flag_Psl : Boolean) return Iir is Res : Iir; begin @@ -8621,12 +8619,12 @@ package body Vhdl.Parse is Set_Psl_Property (Res, Parse_Psl.Parse_Psl_Property); - Parse_Psl_Assert_Report_Severity (Res); + Parse_Psl_Assert_Report_Severity (Res, Flag_Psl); return Res; end Parse_Psl_Assert_Directive; - function Parse_Psl_Assume_Directive return Iir + function Parse_Psl_Assume_Directive (Flag_Psl : Boolean) return Iir is Res : Iir; begin @@ -8640,7 +8638,7 @@ package body Vhdl.Parse is Set_Psl_Property (Res, Parse_Psl.Parse_Psl_Property); - Vhdl.Scanner.Flag_Psl := False; + Vhdl.Scanner.Flag_Psl := Flag_Psl; Vhdl.Scanner.Flag_Scan_In_Comment := False; Expect_Scan (Tok_Semi_Colon); @@ -8648,7 +8646,7 @@ package body Vhdl.Parse is return Res; end Parse_Psl_Assume_Directive; - function Parse_Psl_Cover_Directive return Iir + function Parse_Psl_Cover_Directive (Flag_Psl : Boolean) return Iir is Res : Iir; begin @@ -8662,12 +8660,12 @@ package body Vhdl.Parse is Set_Psl_Sequence (Res, Parse_Psl.Parse_Psl_Sequence (True)); - Parse_Psl_Assert_Report_Severity (Res); + Parse_Psl_Assert_Report_Severity (Res, Flag_Psl); return Res; end Parse_Psl_Cover_Directive; - function Parse_Psl_Restrict_Directive return Iir + function Parse_Psl_Restrict_Directive (Flag_Psl : Boolean) return Iir is Res : Iir; begin @@ -8682,7 +8680,7 @@ package body Vhdl.Parse is Set_Psl_Sequence (Res, Parse_Psl.Parse_Psl_Sequence (True)); -- No more PSL tokens after the sequence. - Vhdl.Scanner.Flag_Psl := False; + Vhdl.Scanner.Flag_Psl := Flag_Psl; Vhdl.Scanner.Flag_Scan_In_Comment := False; Expect_Scan (Tok_Semi_Colon); @@ -8805,7 +8803,7 @@ package body Vhdl.Parse is if Vhdl_Std >= Vhdl_08 or else (Flag_Psl_Comment and then Flag_Scan_In_Comment) then - Stmt := Parse_Psl_Assert_Directive; + Stmt := Parse_Psl_Assert_Directive (False); else Stmt := Create_Iir (Iir_Kind_Concurrent_Assertion_Statement); Parse_Assertion (Stmt); @@ -8844,7 +8842,7 @@ package body Vhdl.Parse is when Tok_Default => Postponed_Not_Allowed; Label_Not_Allowed; - Stmt := Parse_Psl_Default_Clock; + Stmt := Parse_Psl_Default_Clock (False); when Tok_Property | Tok_Sequence | Tok_Psl_Endpoint => @@ -8853,13 +8851,13 @@ package body Vhdl.Parse is Stmt := Parse_Psl_Declaration; when Tok_Assume => Postponed_Not_Allowed; - Stmt := Parse_Psl_Assume_Directive; + Stmt := Parse_Psl_Assume_Directive (False); when Tok_Cover => Postponed_Not_Allowed; - Stmt := Parse_Psl_Cover_Directive; + Stmt := Parse_Psl_Cover_Directive (False); when Tok_Restrict => Postponed_Not_Allowed; - Stmt := Parse_Psl_Restrict_Directive; + Stmt := Parse_Psl_Restrict_Directive (False); when Tok_Wait | Tok_Loop | Tok_While => @@ -9088,9 +9086,7 @@ package body Vhdl.Parse is when Tok_Identifier => Res := Create_Iir_List; loop - Append_Element (Res, Current_Text); - -- Skip identifier. - Scan; + Append_Element (Res, Parse_Simple_Name); exit when Current_Token /= Tok_Comma; @@ -9155,10 +9151,7 @@ package body Vhdl.Parse is Scan; if Current_Token = Tok_Identifier then - Set_Architecture (Res, Current_Text); - - -- Skip identifier. - Scan; + Set_Architecture (Res, Parse_Simple_Name); else Expect (Tok_Identifier); end if; @@ -9385,10 +9378,7 @@ package body Vhdl.Parse is return Parse_Component_Configuration (Loc, Iir_Flist_Others); when Tok_Identifier => - El := Current_Text; - - -- Skip identifier. - Scan; + El := Parse_Simple_Name; case Current_Token is when Tok_Colon => @@ -9405,10 +9395,7 @@ package body Vhdl.Parse is Scan; if Current_Token = Tok_Identifier then - Append_Element (List, Current_Text); - - -- Skip identifier. - Scan; + Append_Element (List, Parse_Simple_Name); else Expect (Tok_Identifier); exit; @@ -9779,6 +9766,84 @@ package body Vhdl.Parse is return Res; end Parse_Package; + -- 1850-2005 7.2 Verification units + -- verification_unit ::= + -- vunit_type PSL_Identifier [ ( hierachical_hdl_name ) ] { + -- { inherit_spec } + -- { vunit_item } + -- } + procedure Parse_Verification_Unit (Unit : Iir_Design_Unit) + is + Kind : constant Iir_Kind := Iir_Kind_Vunit_Declaration; + Hier_Name : Iir; + Res : Iir; + Item, Last_Item : Iir; + begin + Res := Create_Iir (Kind); + Set_Parent (Res, Unit); + + -- Recognize PSL keywords. + Vhdl.Scanner.Flag_Psl := True; + + -- Skip 'vunit'. + Scan; + + -- Identifier. + Scan_Identifier (Res); + + -- Hierarchical hdl name. + if Current_Token = Tok_Left_Paren then + -- Skip '('. + Scan; + + Hier_Name := Create_Iir (Iir_Kind_Psl_Hierarchical_Name); + Set_Location (Hier_Name); + Set_Entity_Name (Hier_Name, Parse_Simple_Name); + + Set_Hierarchical_Name (Res, Hier_Name); + + -- Skip ')' + Expect_Scan (Tok_Right_Paren); + end if; + + -- Skip '{'. + Expect_Scan (Tok_Left_Curly); + + -- TODO: inherit spec. + + -- Vunit items. + Last_Item := Null_Iir; + loop + -- Some parse subprograms clear the mode... + Vhdl.Scanner.Flag_Psl := True; + + case Current_Token is + when Tok_Default => + Item := Parse_Psl_Default_Clock (True); + when Tok_Assert => + Item := Parse_Psl_Assert_Directive (True); + when others => + exit; + end case; + + Set_Parent (Item, Res); + if Last_Item = Null_Node then + Set_Vunit_Item_Chain (Res, Item); + else + Set_Chain (Last_Item, Item); + end if; + Last_Item := Item; + end loop; + + -- Skip '}'. + Expect_Scan (Tok_Right_Curly); + + -- Normal mode. + Vhdl.Scanner.Flag_Psl := False; + + Set_Library_Unit (Unit, Res); + end Parse_Verification_Unit; + procedure Parse_Context_Declaration_Or_Reference (Unit : Iir_Design_Unit; Clause : out Iir); @@ -9979,6 +10044,8 @@ package body Vhdl.Parse is Set_Library_Unit (Res, Parse_Package (Res)); when Tok_Configuration => Parse_Configuration_Declaration (Res); + when Tok_Vunit => + Parse_Verification_Unit (Res); when Tok_Identifier => if Current_Identifier = Name_Context then Error_Msg_Parse diff --git a/src/vhdl/vhdl-post_sems.adb b/src/vhdl/vhdl-post_sems.adb index c477ce813..28f0c54d7 100644 --- a/src/vhdl/vhdl-post_sems.adb +++ b/src/vhdl/vhdl-post_sems.adb @@ -39,7 +39,8 @@ package body Vhdl.Post_Sems is -- No checks on package bodies or context declaration case Get_Kind (Lib_Unit) is when Iir_Kind_Package_Body - | Iir_Kind_Context_Declaration => + | Iir_Kind_Context_Declaration + | Iir_Kinds_Verification_Unit => return; when others => null; diff --git a/src/vhdl/vhdl-sem.adb b/src/vhdl/vhdl-sem.adb index 18aefeef4..e99d7f860 100644 --- a/src/vhdl/vhdl-sem.adb +++ b/src/vhdl/vhdl-sem.adb @@ -15,12 +15,16 @@ -- along with GHDL; see the file COPYING. If not, write to the Free -- Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- 02111-1307, USA. + with Errorout; use Errorout; +with Libraries; +with Std_Names; +with Flags; use Flags; +with Str_Table; + with Vhdl.Errors; use Vhdl.Errors; with Vhdl.Std_Package; use Vhdl.Std_Package; with Vhdl.Ieee.Std_Logic_1164; -with Libraries; -with Std_Names; with Vhdl.Sem_Scopes; use Vhdl.Sem_Scopes; with Vhdl.Sem_Expr; use Vhdl.Sem_Expr; with Vhdl.Sem_Names; use Vhdl.Sem_Names; @@ -29,9 +33,8 @@ with Vhdl.Sem_Decls; use Vhdl.Sem_Decls; with Vhdl.Sem_Assocs; use Vhdl.Sem_Assocs; with Vhdl.Sem_Inst; with Vhdl.Sem_Lib; use Vhdl.Sem_Lib; +with Vhdl.Sem_Psl; with Vhdl.Utils; use Vhdl.Utils; -with Flags; use Flags; -with Str_Table; with Vhdl.Sem_Utils; with Vhdl.Sem_Stmts; use Vhdl.Sem_Stmts; with Vhdl.Nodes_Utils; @@ -3365,8 +3368,7 @@ package body Vhdl.Sem is when Iir_Kind_Context_Declaration => Sem_Context_Declaration (Library_Unit); when Iir_Kinds_Verification_Unit => - -- TODO. - raise Internal_Error; + Sem_Psl.Sem_Psl_Verification_Unit (Library_Unit); end case; end if; diff --git a/src/vhdl/vhdl-sem_psl.adb b/src/vhdl/vhdl-sem_psl.adb index df0c1d8a1..917f35e97 100644 --- a/src/vhdl/vhdl-sem_psl.adb +++ b/src/vhdl/vhdl-sem_psl.adb @@ -17,7 +17,9 @@ -- 02111-1307, USA. with Types; use Types; +with Std_Names; with Errorout; use Errorout; + with PSL.Types; use PSL.Types; with PSL.Nodes; use PSL.Nodes; with PSL.Subsets; @@ -28,7 +30,7 @@ with Vhdl.Sem_Expr; with Vhdl.Sem_Stmts; use Vhdl.Sem_Stmts; with Vhdl.Sem_Scopes; with Vhdl.Sem_Names; -with Std_Names; +with Vhdl.Sem_Lib; with Vhdl.Utils; use Vhdl.Utils; with Vhdl.Evaluation; use Vhdl.Evaluation; with Vhdl.Std_Package; @@ -695,7 +697,8 @@ package body Vhdl.Sem_Psl is Set_PSL_Clock (Stmt, Clk); end Sem_Psl_Directive_Clock; - function Sem_Psl_Assert_Directive (Stmt : Iir) return Iir + function Sem_Psl_Assert_Directive + (Stmt : Iir; Can_Rewrite : Boolean) return Iir is Prop : PSL_Node; Res : Iir; @@ -709,7 +712,7 @@ package body Vhdl.Sem_Psl is Prop := Sem_Property (Prop, True); Set_Psl_Property (Stmt, Prop); - if Is_Boolean_Assertion (Prop) then + if Can_Rewrite and then Is_Boolean_Assertion (Prop) then -- This is a simple assertion. Convert to a non-PSL statement, as -- the handling is simpler (and the assertion doesn't need a clock). Res := Rewrite_As_Concurrent_Assertion (Stmt); @@ -884,4 +887,80 @@ package body Vhdl.Sem_Psl is return Null_Iir; end Sem_Psl_Name; + procedure Sem_Hierarchical_Name (Hier_Name : Iir; Unit : Iir) + is + Entity_Name : Iir; + Entity : Iir; + Library : Iir_Library_Declaration; + begin + Entity_Name := Get_Entity_Name (Hier_Name); + + Library := Get_Library (Get_Design_File (Get_Design_Unit (Unit))); + + Entity := Sem_Lib.Load_Primary_Unit + (Library, Get_Identifier (Entity_Name), Entity_Name); + if Entity = Null_Iir then + Error_Msg_Sem (+Entity_Name, + "entity %n was not analysed", +Entity_Name); + return; + end if; + Entity := Get_Library_Unit (Entity); + + if Get_Kind (Entity) /= Iir_Kind_Entity_Declaration then + Error_Msg_Sem (+Entity_Name, + "name %i does not denote an entity", +Entity_Name); + return; + end if; + + Set_Named_Entity (Entity_Name, Entity); + Xrefs.Xref_Ref (Entity_Name, Entity); + end Sem_Hierarchical_Name; + + procedure Sem_Psl_Verification_Unit (Unit : Iir) + is + Hier_Name : constant Iir := Get_Hierarchical_Name (Unit); + Entity : Iir; + Item : Iir; + begin + if Hier_Name = Null_Iir then + -- Hierarchical name is optional. + -- If the unit is not bound, the names are not bound too. + return; + end if; + Sem_Hierarchical_Name (Hier_Name, Unit); + + -- Import declarations. + Entity := Get_Entity_Name (Hier_Name); + if Entity = Null_Iir then + return; + end if; + Entity := Get_Named_Entity (Entity); + if Entity = Null_Iir then + return; + end if; + + Sem_Scopes.Add_Context_Clauses (Get_Design_Unit (Entity)); + + Sem_Scopes.Open_Declarative_Region; + Set_Is_Within_Flag (Entity, True); + Sem_Scopes.Add_Entity_Declarations (Entity); + + Item := Get_Vunit_Item_Chain (Unit); + while Item /= Null_Iir loop + case Get_Kind (Item) is + when Iir_Kind_Psl_Default_Clock => + Sem_Psl_Default_Clock (Item); + when Iir_Kind_Psl_Assert_Directive => + Item := Sem_Psl_Assert_Directive (Item, False); + when others => + Error_Kind ("sem_psl_verification_unit", Item); + end case; + + Item := Get_Chain (Item); + end loop; + + Sem_Scopes.Close_Declarative_Region; + Set_Is_Within_Flag (Entity, False); + end Sem_Psl_Verification_Unit; + end Vhdl.Sem_Psl; diff --git a/src/vhdl/vhdl-sem_psl.ads b/src/vhdl/vhdl-sem_psl.ads index 1cd02796e..f0f239778 100644 --- a/src/vhdl/vhdl-sem_psl.ads +++ b/src/vhdl/vhdl-sem_psl.ads @@ -22,12 +22,16 @@ package Vhdl.Sem_Psl is procedure Sem_Psl_Declaration (Stmt : Iir); procedure Sem_Psl_Endpoint_Declaration (Stmt : Iir); - -- May return a non-psl concurrent assertion statement. - function Sem_Psl_Assert_Directive (Stmt : Iir) return Iir; + -- May return a non-psl concurrent assertion statement iff CAN_REWRITE is + -- true. + function Sem_Psl_Assert_Directive + (Stmt : Iir; Can_Rewrite : Boolean) return Iir; procedure Sem_Psl_Assume_Directive (Stmt : Iir); procedure Sem_Psl_Cover_Directive (Stmt : Iir); procedure Sem_Psl_Restrict_Directive (Stmt : Iir); procedure Sem_Psl_Default_Clock (Stmt : Iir); function Sem_Psl_Name (Name : Iir) return Iir; + + procedure Sem_Psl_Verification_Unit (Unit : Iir); end Vhdl.Sem_Psl; diff --git a/src/vhdl/vhdl-sem_stmts.adb b/src/vhdl/vhdl-sem_stmts.adb index 848baeeb2..96c23ac8b 100644 --- a/src/vhdl/vhdl-sem_stmts.adb +++ b/src/vhdl/vhdl-sem_stmts.adb @@ -2028,7 +2028,7 @@ package body Vhdl.Sem_Stmts is when Iir_Kind_Psl_Endpoint_Declaration => Sem_Psl.Sem_Psl_Endpoint_Declaration (El); when Iir_Kind_Psl_Assert_Directive => - New_El := Sem_Psl.Sem_Psl_Assert_Directive (El); + New_El := Sem_Psl.Sem_Psl_Assert_Directive (El, True); when Iir_Kind_Psl_Assume_Directive => Sem_Psl.Sem_Psl_Assume_Directive (El); when Iir_Kind_Psl_Cover_Directive => diff --git a/src/vhdl/vhdl-utils.adb b/src/vhdl/vhdl-utils.adb index 6653034a5..4269bdbf2 100644 --- a/src/vhdl/vhdl-utils.adb +++ b/src/vhdl/vhdl-utils.adb @@ -326,6 +326,7 @@ package body Vhdl.Utils is | Iir_Kind_Association_Element_Subprogram | Iir_Kinds_Choice | Iir_Kinds_Entity_Aspect + | Iir_Kind_Psl_Hierarchical_Name | Iir_Kind_If_Generate_Else_Clause | Iir_Kind_Elsif | Iir_Kind_Record_Element_Constraint |