diff options
author | Tristan Gingold | 2014-09-03 04:41:55 +0200 |
---|---|---|
committer | Tristan Gingold | 2014-09-03 04:41:55 +0200 |
commit | 6d8c5299f20b4cd8f1e049f7eea454c00a3102b7 (patch) | |
tree | e06fd1ab55f2398d2e121ad6d7a7b3236aaeda6b | |
parent | e6ffb98cb5ad3f07bcaf79323d8ab8411688c494 (diff) | |
download | ghdl-6d8c5299f20b4cd8f1e049f7eea454c00a3102b7.tar.gz ghdl-6d8c5299f20b4cd8f1e049f7eea454c00a3102b7.tar.bz2 ghdl-6d8c5299f20b4cd8f1e049f7eea454c00a3102b7.zip |
Fix ghdl_simul (after previous change).
-rw-r--r-- | canon.adb | 18 | ||||
-rw-r--r-- | configuration.adb | 12 | ||||
-rw-r--r-- | iirs_utils.adb | 30 | ||||
-rw-r--r-- | iirs_utils.ads | 12 | ||||
-rw-r--r-- | sem_specs.adb | 9 | ||||
-rw-r--r-- | simulate/annotations.adb | 35 | ||||
-rw-r--r-- | simulate/debugger.adb | 2 | ||||
-rw-r--r-- | simulate/elaboration.adb | 85 | ||||
-rw-r--r-- | simulate/execution.adb | 14 | ||||
-rw-r--r-- | translate/translation.adb | 34 |
10 files changed, 144 insertions, 107 deletions
@@ -650,6 +650,8 @@ package body Canon is -- FIXME: -- should canon concatenation. + when Iir_Kind_Parenthesis_Expression => + Canon_Expression (Get_Expression (Expr)); when Iir_Kind_Type_Conversion | Iir_Kind_Qualified_Expression => Canon_Expression (Get_Expression (Expr)); @@ -2039,15 +2041,13 @@ package body Canon is is El : Iir; Comp_Conf : Iir; - Inst : Iir; begin El := Get_Concurrent_Statement_Chain (Parent); while El /= Null_Iir loop case Get_Kind (El) is when Iir_Kind_Component_Instantiation_Statement => - Inst := Get_Instantiated_Unit (El); - if Get_Kind (Inst) in Iir_Kinds_Denoting_Name - and then Get_Named_Entity (Inst) = Comp + if Is_Component_Instantiation (El) + and then Get_Named_Entity (Get_Instantiated_Unit (El)) = Comp then Comp_Conf := Get_Component_Configuration (El); if Comp_Conf = Null_Iir then @@ -2119,11 +2119,9 @@ package body Canon is -- PARENT is the parent for the chain of concurrent statements. procedure Canon_Component_Specification (Conf : Iir; Parent : Iir) is - Spec : Iir_List; + Spec : constant Iir_List := Get_Instantiation_List (Conf); List : Iir_Designator_List; begin - Spec := Get_Instantiation_List (Conf); - if Spec = Iir_List_All or Spec = Iir_List_Others then List := Create_Iir_List; Canon_Component_Specification_All_Others @@ -2443,7 +2441,6 @@ package body Canon is when Iir_Kind_Component_Instantiation_Statement => declare Comp_Conf : Iir; - Comp : Iir; Res : Iir_Component_Configuration; Designator_List : Iir_List; Inst_List : Iir_List; @@ -2452,15 +2449,14 @@ package body Canon is begin Comp_Conf := Get_Component_Configuration (El); if Comp_Conf = Null_Iir then - Comp := Get_Instantiated_Unit (El); - if Get_Kind (Comp) in Iir_Kinds_Denoting_Name then + if Is_Component_Instantiation (El) then -- Create a component configuration. -- FIXME: should merge all these default configuration -- of the same component. Res := Create_Iir (Iir_Kind_Component_Configuration); Location_Copy (Res, El); Set_Parent (Res, Conf); - Set_Component_Name (Res, Comp); + Set_Component_Name (Res, Get_Instantiated_Unit (El)); Designator_List := Create_Iir_List; Append_Element (Designator_List, Build_Simple_Name (El, El)); diff --git a/configuration.adb b/configuration.adb index 997c9d2..b9391f7 100644 --- a/configuration.adb +++ b/configuration.adb @@ -206,14 +206,10 @@ package body Configuration is while Stmt /= Null_Iir loop case Get_Kind (Stmt) is when Iir_Kind_Component_Instantiation_Statement => - declare - Unit : constant Iir := Get_Instantiated_Unit (Stmt); - begin - if Get_Kind (Unit) not in Iir_Kinds_Denoting_Name then - -- Entity or configuration instantiation. - Add_Design_Aspect (Unit, True); - end if; - end; + if Is_Entity_Instantiation (Stmt) then + -- Entity or configuration instantiation. + Add_Design_Aspect (Get_Instantiated_Unit (Stmt), True); + end if; when Iir_Kind_Generate_Statement | Iir_Kind_Block_Statement => Add_Design_Concurrent_Stmts (Stmt); diff --git a/iirs_utils.adb b/iirs_utils.adb index 310fffa..9dc3c6e 100644 --- a/iirs_utils.adb +++ b/iirs_utils.adb @@ -799,6 +799,36 @@ package body Iirs_Utils is end case; end Get_Entity_Identifier_Of_Architecture; + function Is_Component_Instantiation + (Inst : Iir_Component_Instantiation_Statement) + return Boolean is + begin + case Get_Kind (Get_Instantiated_Unit (Inst)) is + when Iir_Kinds_Denoting_Name => + return True; + when Iir_Kind_Entity_Aspect_Entity + | Iir_Kind_Entity_Aspect_Configuration => + return False; + when others => + Error_Kind ("is_component_instantiation", Inst); + end case; + end Is_Component_Instantiation; + + function Is_Entity_Instantiation + (Inst : Iir_Component_Instantiation_Statement) + return Boolean is + begin + case Get_Kind (Get_Instantiated_Unit (Inst)) is + when Iir_Kinds_Denoting_Name => + return False; + when Iir_Kind_Entity_Aspect_Entity + | Iir_Kind_Entity_Aspect_Configuration => + return True; + when others => + Error_Kind ("is_entity_instantiation", Inst); + end case; + end Is_Entity_Instantiation; + function Get_String_Type_Bound_Type (Sub_Type : Iir) return Iir is begin if Get_Kind (Sub_Type) /= Iir_Kind_Array_Subtype_Definition then diff --git a/iirs_utils.ads b/iirs_utils.ads index 98b6b9e..3b06e27 100644 --- a/iirs_utils.ads +++ b/iirs_utils.ads @@ -164,6 +164,18 @@ package Iirs_Utils is -- Return the identifier of the entity for architecture ARCH. function Get_Entity_Identifier_Of_Architecture (Arch : Iir) return Name_Id; + -- Return True is component instantiation statement INST instantiate a + -- component. + function Is_Component_Instantiation + (Inst : Iir_Component_Instantiation_Statement) + return Boolean; + + -- Return True is component instantiation statement INST instantiate a + -- design entity. + function Is_Entity_Instantiation + (Inst : Iir_Component_Instantiation_Statement) + return Boolean; + -- Return the bound type of a string type, ie the type of the (first) -- dimension of a one-dimensional array type. function Get_String_Type_Bound_Type (Sub_Type : Iir) return Iir; diff --git a/sem_specs.adb b/sem_specs.adb index 039e576..5100716 100644 --- a/sem_specs.adb +++ b/sem_specs.adb @@ -1187,7 +1187,6 @@ package body Sem_Specs is return Boolean is Comp : constant Iir := Get_Named_Entity (Get_Component_Name (Spec)); - Inst : Iir; El : Iir; Res : Boolean; begin @@ -1196,9 +1195,9 @@ package body Sem_Specs is while El /= Null_Iir loop case Get_Kind (El) is when Iir_Kind_Component_Instantiation_Statement => - Inst := Get_Instantiated_Unit (El); - if Get_Kind (Inst) in Iir_Kinds_Denoting_Name - and then Get_Named_Entity (Inst) = Comp + if Is_Component_Instantiation (El) + and then + Get_Named_Entity (Get_Instantiated_Unit (El)) = Comp and then (not Check_Applied or else Get_Component_Configuration (El) = Null_Iir) @@ -1302,7 +1301,7 @@ package body Sem_Specs is Error_Msg_Sem ("label does not denote an instantiation", El); else Inst_Unit := Get_Instantiated_Unit (Inst); - if Get_Kind (Inst_Unit) not in Iir_Kinds_Denoting_Name + if Is_Entity_Instantiation (Inst) or else (Get_Kind (Get_Named_Entity (Inst_Unit)) /= Iir_Kind_Component_Declaration) then diff --git a/simulate/annotations.adb b/simulate/annotations.adb index 4508d83..a0b9ae8 100644 --- a/simulate/annotations.adb +++ b/simulate/annotations.adb @@ -284,7 +284,6 @@ package body Annotations is procedure Annotate_Type_Definition (Block_Info: Sim_Info_Acc; Def: Iir) is El: Iir; - List: Iir_List; begin -- Happen only with universal types. if Def = Null_Iir then @@ -293,7 +292,6 @@ package body Annotations is case Get_Kind (Def) is when Iir_Kind_Enumeration_Type_Definition => - List := Get_Enumeration_Literal_List (Def); if Def = Std_Package.Boolean_Type_Definition or else Def = Std_Package.Bit_Type_Definition then @@ -353,20 +351,27 @@ package body Annotations is Annotate_Anonymous_Type_Definition (Block_Info, El); when Iir_Kind_Array_Subtype_Definition => - List := Get_Index_Subtype_List (Def); - for I in Natural loop - El := Get_Nth_Element (List, I); - exit when El = Null_Iir; - Annotate_Anonymous_Type_Definition (Block_Info, El); - end loop; + declare + List : constant Iir_List := Get_Index_Subtype_List (Def); + begin + for I in Natural loop + El := Get_Index_Type (List, I); + exit when El = Null_Iir; + Annotate_Anonymous_Type_Definition (Block_Info, El); + end loop; + end; when Iir_Kind_Record_Type_Definition => - List := Get_Elements_Declaration_List (Def); - for I in Natural loop - El := Get_Nth_Element (List, I); - exit when El = Null_Iir; - Annotate_Anonymous_Type_Definition (Block_Info, Get_Type (El)); - end loop; + declare + List : constant Iir_List := Get_Elements_Declaration_List (Def); + begin + for I in Natural loop + El := Get_Nth_Element (List, I); + exit when El = Null_Iir; + Annotate_Anonymous_Type_Definition + (Block_Info, Get_Type (El)); + end loop; + end; when Iir_Kind_Record_Subtype_Definition => null; @@ -765,7 +770,7 @@ package body Annotations is when Iir_Kind_For_Loop_Statement => Annotate_Declaration - (Block_Info, Get_Iterator_Scheme (El)); + (Block_Info, Get_Parameter_Specification (El)); Annotate_Sequential_Statement_Chain (Block_Info, Get_Sequential_Statement_Chain (El)); diff --git a/simulate/debugger.adb b/simulate/debugger.adb index 072fba6..1677efa 100644 --- a/simulate/debugger.adb +++ b/simulate/debugger.adb @@ -1298,7 +1298,7 @@ package body Debugger is Add_Declarations (Get_Declaration_Chain (N), False); when Iir_Kind_For_Loop_Statement => Open_Declarative_Region; - Add_Name (Get_Iterator_Scheme (N)); + Add_Name (Get_Parameter_Specification (N)); when Iir_Kind_Block_Statement => Open_Declarative_Region; Add_Declarations (Get_Declaration_Chain (N), False); diff --git a/simulate/elaboration.adb b/simulate/elaboration.adb index 4808b45..c0e5d90 100644 --- a/simulate/elaboration.adb +++ b/simulate/elaboration.adb @@ -734,17 +734,16 @@ package body Elaboration is | Iir_Kind_Record_Type_Definition => Elaborate_Type_Definition (Instance, Ind); when Iir_Kind_Array_Subtype_Definition => - -- LRM93 §12.3.1.3 + -- LRM93 12.3.1.3 -- The elaboration of an index constraint consists of the -- declaration of each of the discrete ranges in the index -- constraint in some order that is not defined by the language. declare - St_Indexes : Iir_List; + St_Indexes : constant Iir_List := Get_Index_Subtype_List (Ind); St_El : Iir; begin - St_Indexes := Get_Index_Subtype_List (Ind); for I in Natural loop - St_El := Get_Nth_Element (St_Indexes, I); + St_El := Get_Index_Type (St_Indexes, I); exit when St_El = Null_Iir; Elaborate_Subtype_Indication_If_Anonymous (Instance, St_El); end loop; @@ -1396,35 +1395,38 @@ package body Elaboration is (Instance : Block_Instance_Acc; Stmt : Iir_Component_Instantiation_Statement) is - Component : constant Iir := Get_Instantiated_Unit (Stmt); Frame : Block_Instance_Acc; begin - if Get_Kind (Component) = Iir_Kind_Component_Declaration then - - -- Elaboration of a component instantiation statement that - -- instanciates a component declaration has no effect unless the - -- component instance is either fully bound to a design entity - -- defined by an entity declaration and architecture body or is - -- bound to a configuration of such a design entity. - -- FIXME: in fact the component is created. - - -- If a component instance is so bound, then elaboration of the - -- corresponding component instantiation statement consists of the - -- elaboration of the implied block statement representing the - -- component instance and [...] - Frame := Create_Block_Instance (Instance, Component, Stmt); - - Elaborate_Generic_Clause (Frame, Get_Generic_Chain (Component)); - Elaborate_Generic_Map_Aspect - (Frame, Instance, Get_Generic_Map_Aspect_Chain (Stmt)); - Elaborate_Port_Clause (Frame, Get_Port_Chain (Component)); - Elaborate_Port_Map_Aspect - (Frame, Instance, - Get_Port_Chain (Component), Get_Port_Map_Aspect_Chain (Stmt)); + if Is_Component_Instantiation (Stmt) then + declare + Component : constant Iir := + Get_Named_Entity (Get_Instantiated_Unit (Stmt)); + begin + -- Elaboration of a component instantiation statement that + -- instanciates a component declaration has no effect unless the + -- component instance is either fully bound to a design entity + -- defined by an entity declaration and architecture body or is + -- bound to a configuration of such a design entity. + -- FIXME: in fact the component is created. + + -- If a component instance is so bound, then elaboration of the + -- corresponding component instantiation statement consists of the + -- elaboration of the implied block statement representing the + -- component instance and [...] + Frame := Create_Block_Instance (Instance, Component, Stmt); + + Elaborate_Generic_Clause (Frame, Get_Generic_Chain (Component)); + Elaborate_Generic_Map_Aspect + (Frame, Instance, Get_Generic_Map_Aspect_Chain (Stmt)); + Elaborate_Port_Clause (Frame, Get_Port_Chain (Component)); + Elaborate_Port_Map_Aspect + (Frame, Instance, + Get_Port_Chain (Component), Get_Port_Map_Aspect_Chain (Stmt)); + end; else -- Direct instantiation declare - Aspect : constant Iir := Component; + Aspect : constant Iir := Get_Instantiated_Unit (Stmt); Arch : Iir; Config : Iir; begin @@ -1676,7 +1678,7 @@ package body Elaboration is Conf : Iir_Component_Configuration) is Component : constant Iir_Component_Declaration := - Get_Instantiated_Unit (Stmt); + Get_Named_Entity (Get_Instantiated_Unit (Stmt)); Entity : Iir_Entity_Declaration; Arch_Name : Name_Id; Arch_Design : Iir_Design_Unit; @@ -1907,9 +1909,7 @@ package body Elaboration is Item : Iir; begin - if Conf = Null_Iir then - raise Internal_Error; - end if; + pragma Assert (Conf /= Null_Iir); -- Associate configuration items with subinstance. Gather items for -- for-generate statements. @@ -1964,7 +1964,7 @@ package body Elaboration is for I in Natural loop El := Get_Nth_Element (List, I); exit when El = Null_Iir; - Info := Get_Info (El); + Info := Get_Info (Get_Named_Entity (El)); if Sub_Conf (Info.Inst_Slot) /= Null_Iir then raise Internal_Error; end if; @@ -2031,10 +2031,16 @@ package body Elaboration is Elaborate_Block_Configuration (Sub_Conf (Slot), Sub_Instances (Slot)); when Iir_Kind_Component_Instantiation_Statement => - Info := Get_Info (Stmt); - Slot := Info.Inst_Slot; - Elaborate_Component_Configuration - (Stmt, Sub_Instances (Slot), Sub_Conf (Slot)); + if Is_Component_Instantiation (Stmt) then + Info := Get_Info (Stmt); + Slot := Info.Inst_Slot; + Elaborate_Component_Configuration + (Stmt, Sub_Instances (Slot), Sub_Conf (Slot)); + else + -- Nothing to do for entity instantiation, will be + -- done during elaboration of statements. + null; + end if; when others => null; end case; @@ -2287,12 +2293,13 @@ package body Elaboration is -- GHDL: done by sem. declare + Attr_Decl : constant Iir := + Get_Named_Entity (Get_Attribute_Designator (Decl)); + Attr_Type : constant Iir := Get_Type (Attr_Decl); Value : Iir_Attribute_Value; Val : Iir_Value_Literal_Acc; - Attr_Type : Iir; begin Value := Get_Attribute_Value_Spec_Chain (Decl); - Attr_Type := Get_Type (Get_Attribute_Designator (Decl)); while Value /= Null_Iir loop -- 2. The expression is evaluated to determine the value -- of the attribute. diff --git a/simulate/execution.adb b/simulate/execution.adb index d82f32f..af34e96 100644 --- a/simulate/execution.adb +++ b/simulate/execution.adb @@ -2968,6 +2968,9 @@ package body Execution is Error_Msg_Constraint (Expr); return null; + when Iir_Kind_Parenthesis_Expression => + return Execute_Expression (Block, Get_Expression (Expr)); + when Iir_Kind_Type_Conversion => return Execute_Type_Conversion (Block, Expr, @@ -4297,7 +4300,8 @@ package body Execution is Stmt : Iir) is begin - Destroy_Iterator_Declaration (Instance, Get_Iterator_Scheme (Stmt)); + Destroy_Iterator_Declaration + (Instance, Get_Parameter_Specification (Stmt)); end Finalize_For_Loop_Statement; procedure Finalize_Loop_Statement (Instance : Block_Instance_Acc; @@ -4313,15 +4317,13 @@ package body Execution is is Instance : constant Block_Instance_Acc := Proc.Instance; Stmt : constant Iir_For_Loop_Statement := Instance.Stmt; + Iterator : constant Iir := Get_Parameter_Specification (Stmt); Bounds : Iir_Value_Literal_Acc; - Iterator : Iir; Index : Iir_Value_Literal_Acc; Stmt_Chain : Iir; Is_Nul : Boolean; Marker : Mark_Type; begin - Iterator := Get_Iterator_Scheme (Stmt); - -- Elaborate the iterator (and its type). Elaborate_Declaration (Instance, Iterator); @@ -4355,7 +4357,7 @@ package body Execution is function Finish_For_Loop_Statement (Instance : Block_Instance_Acc) return Boolean is - Iterator : constant Iir := Get_Iterator_Scheme (Instance.Stmt); + Iterator : constant Iir := Get_Parameter_Specification (Instance.Stmt); Bounds : Iir_Value_Literal_Acc; Index : Iir_Value_Literal_Acc; Marker : Mark_Type; @@ -4459,7 +4461,7 @@ package body Execution is is Instance : constant Block_Instance_Acc := Proc.Instance; Stmt : constant Iir := Instance.Stmt; - Label : constant Iir := Get_Loop (Stmt); + Label : constant Iir := Get_Named_Entity (Get_Loop_Label (Stmt)); Cond : Boolean; Parent : Iir; begin diff --git a/translate/translation.adb b/translate/translation.adb index 03333b1..ebc4838 100644 --- a/translate/translation.adb +++ b/translate/translation.adb @@ -21710,7 +21710,7 @@ package body Translation is begin Info := Add_Info (Inst, Kind_Block); Info.Block_Decls_Type := O_Tnode_Null; - if Get_Kind (Comp) in Iir_Kinds_Denoting_Name then + if Is_Component_Instantiation (Inst) then -- Via a component declaration. Comp_Info := Get_Info (Get_Named_Entity (Comp)); Info.Block_Link_Field := Add_Instance_Factory_Field @@ -22372,7 +22372,7 @@ package body Translation is end if; Comp := Get_Instantiated_Unit (Stmt); - if Get_Kind (Comp) not in Iir_Kinds_Denoting_Name then + if Is_Entity_Instantiation (Stmt) then -- This is a direct instantiation. Set_Component_Link (Parent_Info.Block_Decls_Type, Info.Block_Link_Field); @@ -27287,26 +27287,16 @@ package body Translation is Info.Block_Link_Field, Ghdl_Ptr_Type)); New_Record_Aggr_El (List, New_Rti_Address (Parent)); - case Get_Kind (Inst) is - when Iir_Kinds_Denoting_Name => - Val := New_Rti_Address - (Get_Info (Get_Named_Entity (Inst)).Comp_Rti_Const); - when Iir_Kind_Entity_Aspect_Entity => - declare - Ent : constant Iir := Get_Entity (Inst); - begin - Val := New_Rti_Address (Get_Info (Ent).Block_Rti_Const); - end; - when Iir_Kind_Entity_Aspect_Configuration => - declare - Config : constant Iir := Get_Configuration (Inst); - Ent : constant Iir := Get_Entity (Config); - begin - Val := New_Rti_Address (Get_Info (Ent).Block_Rti_Const); - end; - when others => - Val := New_Null_Access (Ghdl_Rti_Access); - end case; + if Is_Component_Instantiation (Stmt) then + Val := New_Rti_Address + (Get_Info (Get_Named_Entity (Inst)).Comp_Rti_Const); + else + declare + Ent : constant Iir := Get_Entity_From_Entity_Aspect (Inst); + begin + Val := New_Rti_Address (Get_Info (Ent).Block_Rti_Const); + end; + end if; New_Record_Aggr_El (List, Val); Finish_Record_Aggr (List, Val); |