diff options
author | Tristan Gingold <tgingold@free.fr> | 2016-09-14 20:27:51 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2016-09-14 20:27:51 +0200 |
commit | d4c687a2bfc5035b8292de0eb222da5cc342777d (patch) | |
tree | ef58d79ac861499dba350e328eb8e2ed92b77138 | |
parent | 52f10edcb18bfeabe56a99a5ee1d47eae34e32cb (diff) | |
download | ghdl-d4c687a2bfc5035b8292de0eb222da5cc342777d.tar.gz ghdl-d4c687a2bfc5035b8292de0eb222da5cc342777d.tar.bz2 ghdl-d4c687a2bfc5035b8292de0eb222da5cc342777d.zip |
Comments and reformatting.
-rw-r--r-- | src/ghdldrv/ghdllocal.adb | 12 | ||||
-rw-r--r-- | src/vhdl/canon.adb | 178 | ||||
-rw-r--r-- | src/vhdl/configuration.adb | 13 | ||||
-rw-r--r-- | src/vhdl/translate/translation.adb | 88 |
4 files changed, 120 insertions, 171 deletions
diff --git a/src/ghdldrv/ghdllocal.adb b/src/ghdldrv/ghdllocal.adb index 5072ad44f..193910896 100644 --- a/src/ghdldrv/ghdllocal.adb +++ b/src/ghdldrv/ghdllocal.adb @@ -43,8 +43,6 @@ package body Ghdllocal is type Ieee_Lib_Kind is (Lib_Standard, Lib_None, Lib_Synopsys, Lib_Mentor); Flag_Ieee : Ieee_Lib_Kind; - Flag_Create_Default_Config : constant Boolean := True; - -- If TRUE, generate 32bits code on 64bits machines. Flag_32bit : Boolean := False; @@ -100,12 +98,10 @@ package body Ghdllocal is end if; if Flags.Flag_Elaborate then - if Flag_Create_Default_Config then - Lib := Get_Library_Unit (Unit); - if Get_Kind (Lib) = Iir_Kind_Architecture_Body then - Config := Canon.Create_Default_Configuration_Declaration (Lib); - Set_Default_Configuration_Declaration (Lib, Config); - end if; + Lib := Get_Library_Unit (Unit); + if Get_Kind (Lib) = Iir_Kind_Architecture_Body then + Config := Canon.Create_Default_Configuration_Declaration (Lib); + Set_Default_Configuration_Declaration (Lib, Config); end if; end if; end Finish_Compilation; diff --git a/src/vhdl/canon.adb b/src/vhdl/canon.adb index 13f61fb48..38e8ffd13 100644 --- a/src/vhdl/canon.adb +++ b/src/vhdl/canon.adb @@ -992,50 +992,6 @@ package body Canon is return Res; end Canon_Default_Association_Chain; --- function Canon_Default_Map_Association_List --- (Formal_List, Actual_List : Iir_List; Loc : Location_Type) --- return Iir_Association_List --- is --- Res : Iir_Association_List; --- Formal, Actual : Iir; --- Assoc : Iir; --- Nbr_Assoc : Natural; --- begin --- -- formal is the entity port/generic. --- if Formal_List = Null_Iir_List then --- if Actual_List /= Null_Iir_List then --- raise Internal_Error; --- end if; --- return Null_Iir_List; --- end if; - --- Res := Create_Iir (Iir_Kind_Association_List); --- Set_Location (Res, Loc); --- Nbr_Assoc := 0; --- for I in Natural loop --- Formal := Get_Nth_Element (Formal_List, I); --- exit when Formal = Null_Iir; --- Actual := Find_Name_In_List (Actual_List, Get_Identifier (Formal)); --- if Actual /= Null_Iir then --- Assoc := Create_Iir (Iir_Kind_Association_Element_By_Expression); --- Set_Whole_Association_Flag (Assoc, True); --- Set_Actual (Assoc, Actual); --- Nbr_Assoc := Nbr_Assoc + 1; --- else --- Assoc := Create_Iir (Iir_Kind_Association_Element_Open); --- end if; --- Set_Location (Assoc, Loc); --- Set_Formal (Assoc, Formal); --- Set_Associated_Formal (Assoc, Formal); --- Append_Element (Res, Assoc); --- end loop; --- if Nbr_Assoc /= Get_Nbr_Elements (Actual_List) then --- -- There is non-associated actuals. --- raise Internal_Error; --- end if; --- return Res; --- end Canon_Default_Map_Association_List; - function Canon_Conditional_Variable_Assignment_Statement (Stmt : Iir) return Iir is @@ -1269,13 +1225,13 @@ package body Canon is return Res; end Canon_Sequential_Stmts; - -- Create a statement transform from concurrent_signal_assignment - -- statement STMT (either selected or conditional). - -- waveform transformation is not done. - -- PROC is the process created. - -- PARENT is the place where signal assignment must be placed. This may - -- be PROC, or an 'if' statement if the assignment is guarded. - -- See LRM93 9.5 + -- Create a statement transform from concurrent_signal_assignment + -- statement STMT (either selected or conditional). + -- waveform transformation is not done. + -- PROC is the process created. + -- PARENT is the place where signal assignment must be placed. This may + -- be PROC, or an 'if' statement if the assignment is guarded. + -- See LRM93 9.5 procedure Canon_Concurrent_Signal_Assignment (Stmt: Iir; Proc: out Iir_Sensitized_Process_Statement; @@ -1309,19 +1265,23 @@ package body Canon is end if; if Get_Guard (Stmt) /= Null_Iir then - -- LRM93 9.1 - -- If the option guarded appears in the concurrent signal assignment - -- statement, then the concurrent signal assignment is called a - -- guarded assignment. - -- If the concurrent signal assignement statement is a guarded - -- assignment and the target of the concurrent signal assignment is - -- a guarded target, then the statement transform is as follow: - -- if GUARD then signal_transform else disconnect_statements end if; - -- Otherwise, if the concurrent signal assignment statement is a - -- guarded assignement, but the target if the concurrent signal - -- assignment is not a guarded target, the then statement transform - -- is as follows: - -- if GUARD then signal_transform end if; + -- LRM93 9.1 + -- If the option guarded appears in the concurrent signal assignment + -- statement, then the concurrent signal assignment is called a + -- guarded assignment. + -- If the concurrent signal assignement statement is a guarded + -- assignment and the target of the concurrent signal assignment is + -- a guarded target, then the statement transform is as follow: + -- if GUARD then + -- signal_transform + -- else + -- disconnect_statements + -- end if; + -- Otherwise, if the concurrent signal assignment statement is a + -- guarded assignement, but the target if the concurrent signal + -- assignment is not a guarded target, the then statement transform + -- is as follows: + -- if GUARD then signal_transform end if; If_Stmt := Create_Iir (Iir_Kind_If_Statement); Set_Parent (If_Stmt, Proc); Set_Sequential_Statement_Chain (Proc, If_Stmt); @@ -1353,12 +1313,12 @@ package body Canon is end if; end; else - -- LRM93 9.1 - -- Finally, if the concurrent signal assignment statement is not a - -- guarded assignment, and the traget of the concurrent signal - -- assignment is not a guarded target, then the statement transform - -- is as follows: - -- signal_transform + -- LRM93 9.1 + -- Finally, if the concurrent signal assignment statement is not a + -- guarded assignment, and the traget of the concurrent signal + -- assignment is not a guarded target, then the statement transform + -- is as follows: + -- signal_transform Chain := Proc; end if; end Canon_Concurrent_Signal_Assignment; @@ -2127,10 +2087,9 @@ package body Canon is -- designator_all and designator_others must have been replaced -- by a list during canon. raise Internal_Error; - else - Bind := Get_Default_Binding_Indication - (Get_Named_Entity (Get_First_Element (Instances))); end if; + Bind := Get_Default_Binding_Indication + (Get_Named_Entity (Get_First_Element (Instances))); if Bind = Null_Iir then -- Component is not bound. return; @@ -2178,9 +2137,8 @@ package body Canon is and then Get_Architecture (Entity_Aspect) = Null_Iir then Entity := Get_Entity (Entity_Aspect); - if Get_Kind (Entity) /= Iir_Kind_Entity_Declaration then - raise Internal_Error; - end if; + pragma Assert + (Get_Kind (Entity) = Iir_Kind_Entity_Declaration); Set_Architecture (Entity_Aspect, Get_Block_Specification (Block)); end if; @@ -2240,8 +2198,7 @@ package body Canon is end loop; end Copy_Association; - procedure Advance (Assoc : in out Iir; Inter : Iir) - is + procedure Advance (Assoc : in out Iir; Inter : Iir) is begin loop Assoc := Get_Chain (Assoc); @@ -2386,40 +2343,36 @@ package body Canon is begin El := Get_Concurrent_Statement_Chain (Parent); while El /= Null_Iir loop - case Get_Kind (El) is - when Iir_Kind_Component_Instantiation_Statement => - if Is_Component_Instantiation (El) - and then Get_Named_Entity (Get_Instantiated_Unit (El)) = Comp + -- Handle only component instantiation of COMP. + if Get_Kind (El) = Iir_Kind_Component_Instantiation_Statement + and then 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 + -- The component is not yet configured. + Append_Element (List, Build_Simple_Name (El, El)); + Set_Component_Configuration (El, Conf); + else + -- The component is already configured. + -- Handle incremental configuration. + if Get_Kind (Comp_Conf) = Iir_Kind_Configuration_Specification + and then Spec = Iir_List_All then - Comp_Conf := Get_Component_Configuration (El); - if Comp_Conf = Null_Iir then - -- The component is not yet configured. - Append_Element (List, Build_Simple_Name (El, El)); - Set_Component_Configuration (El, Conf); - else - -- The component is already configured. - -- Handle incremental configuration. - if (Get_Kind (Comp_Conf) - = Iir_Kind_Configuration_Specification) - and then Spec = Iir_List_All - then - -- FIXME: handle incremental configuration. - raise Internal_Error; - end if; - if Spec = Iir_List_All then - -- Several component configuration for an instance. - -- Must have been caught by sem. - raise Internal_Error; - elsif Spec = Iir_List_Others then - null; - else - raise Internal_Error; - end if; - end if; + -- FIXME: handle incremental configuration. + raise Internal_Error; end if; - when others => - null; - end case; + if Spec = Iir_List_All then + -- Several component configuration for an instance. + -- Must have been caught by sem. + raise Internal_Error; + elsif Spec = Iir_List_Others then + null; + else + raise Internal_Error; + end if; + end if; + end if; El := Get_Chain (El); end loop; end Canon_Component_Specification_All_Others; @@ -2903,10 +2856,7 @@ package body Canon is end if; end; - when Iir_Kind_Sensitized_Process_Statement - | Iir_Kind_Process_Statement - | Iir_Kind_Psl_Assert_Statement - | Iir_Kind_Psl_Cover_Statement + when Iir_Kinds_Simple_Concurrent_Statement | Iir_Kind_Psl_Default_Clock | Iir_Kind_Psl_Declaration | Iir_Kind_Psl_Endpoint_Declaration diff --git a/src/vhdl/configuration.adb b/src/vhdl/configuration.adb index c4cddca72..b36142595 100644 --- a/src/vhdl/configuration.adb +++ b/src/vhdl/configuration.adb @@ -262,10 +262,7 @@ package body Configuration is Alt := Get_Chain (Alt); end loop; end; - when Iir_Kind_Process_Statement - | Iir_Kind_Sensitized_Process_Statement - | Iir_Kind_Psl_Assert_Statement - | Iir_Kind_Psl_Cover_Statement + when Iir_Kinds_Simple_Concurrent_Statement | Iir_Kind_Psl_Default_Clock | Iir_Kind_Psl_Declaration | Iir_Kind_Psl_Endpoint_Declaration @@ -400,10 +397,10 @@ package body Configuration is procedure Check_Binding_Indication (Conf : Iir) is + Bind : constant Iir_Binding_Indication := Get_Binding_Indication (Conf); + Conf_Chain : constant Iir := Get_Port_Map_Aspect_Chain (Bind); Assoc : Iir; - Conf_Chain : Iir; Inst_Chain : Iir; - Bind : Iir_Binding_Indication; Err : Boolean; Inst : Iir; Inst_List : Iir_List; @@ -411,9 +408,6 @@ package body Configuration is Assoc_1 : Iir; Actual : Iir; begin - Bind := Get_Binding_Indication (Conf); - Conf_Chain := Get_Port_Map_Aspect_Chain (Bind); - Err := False; -- Note: the assoc chain is already canonicalized. @@ -628,6 +622,7 @@ package body Configuration is return Null_Iir; end case; + -- Exclude std.standard Set_Configuration_Mark_Flag (Std_Package.Std_Standard_Unit, True); Set_Configuration_Done_Flag (Std_Package.Std_Standard_Unit, True); diff --git a/src/vhdl/translate/translation.adb b/src/vhdl/translate/translation.adb index 81e7e5e7e..977162565 100644 --- a/src/vhdl/translate/translation.adb +++ b/src/vhdl/translate/translation.adb @@ -203,7 +203,7 @@ package body Translation is procedure Translate (Unit : Iir_Design_Unit; Main : Boolean) is Design_File : constant Iir_Design_File := Get_Design_File (Unit); - El : Iir; + Lib_Unit : constant Iir := Get_Library_Unit (Unit); Lib : Iir_Library_Declaration; Lib_Mark, Ent_Mark, Sep_Mark, Unit_Mark : Id_Mark_Type; Id : Name_Id; @@ -212,28 +212,32 @@ package body Translation is if False then -- No translation for context items. - El := Get_Context_Items (Unit); - while El /= Null_Iir loop - case Get_Kind (El) is - when Iir_Kind_Use_Clause => - null; - when Iir_Kind_Library_Clause => - null; - when others => - Error_Kind ("translate1", El); - end case; - El := Get_Chain (El); - end loop; + declare + El : Iir; + begin + El := Get_Context_Items (Unit); + while El /= Null_Iir loop + case Get_Kind (El) is + when Iir_Kind_Use_Clause => + null; + when Iir_Kind_Library_Clause => + null; + when others => + Error_Kind ("translate1", El); + end case; + El := Get_Chain (El); + end loop; + end; end if; - El := Get_Library_Unit (Unit); if Flags.Verbose then if Main then Report_Msg (Msgid_Note, Semantic, +Unit, - "translating (with code generation) %n", (1 => +El)); + "translating (with code generation) %n", + (1 => +Lib_Unit)); else Report_Msg (Msgid_Note, Semantic, +Unit, - "translating %n", (1 => +El)); + "translating %n", (1 => +Lib_Unit)); end if; end if; @@ -247,14 +251,15 @@ package body Translation is end if; Push_Identifier_Prefix (Lib_Mark, Id); - if Get_Kind (El) = Iir_Kind_Architecture_Body then + if Get_Kind (Lib_Unit) = Iir_Kind_Architecture_Body then -- Put 'ARCH' between the entity name and the architecture name, to -- avoid a name clash with names from entity (eg an entity port with -- the same name as an architecture). - Push_Identifier_Prefix (Ent_Mark, Get_Identifier (Get_Entity (El))); + Push_Identifier_Prefix (Ent_Mark, + Get_Identifier (Get_Entity (Lib_Unit))); Push_Identifier_Prefix (Sep_Mark, "ARCH"); end if; - Id := Get_Identifier (El); + Id := Get_Identifier (Lib_Unit); if Id /= Null_Identifier then Push_Identifier_Prefix (Unit_Mark, Id); end if; @@ -276,28 +281,31 @@ package body Translation is New_Debug_Filename_Decl (Pathname); end; - Current_Library_Unit := El; + Current_Library_Unit := Lib_Unit; - case Get_Kind (El) is + case Get_Kind (Lib_Unit) is when Iir_Kind_Package_Declaration => New_Debug_Comment_Decl - ("package declaration " & Image_Identifier (El)); - Chap2.Translate_Package_Declaration (El); + ("package declaration " & Image_Identifier (Lib_Unit)); + Chap2.Translate_Package_Declaration (Lib_Unit); when Iir_Kind_Package_Body => - New_Debug_Comment_Decl ("package body " & Image_Identifier (El)); - Chap2.Translate_Package_Body (El); + New_Debug_Comment_Decl + ("package body " & Image_Identifier (Lib_Unit)); + Chap2.Translate_Package_Body (Lib_Unit); when Iir_Kind_Package_Instantiation_Declaration => New_Debug_Comment_Decl - ("package instantiation " & Image_Identifier (El)); - Chap2.Translate_Package_Instantiation_Declaration (El); + ("package instantiation " & Image_Identifier (Lib_Unit)); + Chap2.Translate_Package_Instantiation_Declaration (Lib_Unit); when Iir_Kind_Entity_Declaration => - New_Debug_Comment_Decl ("entity " & Image_Identifier (El)); - Chap1.Translate_Entity_Declaration (El); + New_Debug_Comment_Decl ("entity " & Image_Identifier (Lib_Unit)); + Chap1.Translate_Entity_Declaration (Lib_Unit); when Iir_Kind_Architecture_Body => - New_Debug_Comment_Decl ("architecture " & Image_Identifier (El)); - Chap1.Translate_Architecture_Body (El); + New_Debug_Comment_Decl + ("architecture " & Image_Identifier (Lib_Unit)); + Chap1.Translate_Architecture_Body (Lib_Unit); when Iir_Kind_Configuration_Declaration => - New_Debug_Comment_Decl ("configuration " & Image_Identifier (El)); + New_Debug_Comment_Decl + ("configuration " & Image_Identifier (Lib_Unit)); if Id = Null_Identifier then -- Default configuration. declare @@ -306,32 +314,32 @@ package body Translation is Mark_Arch : Id_Mark_Type; Mark_Sep : Id_Mark_Type; Arch : Iir; - Entity : constant Iir := Get_Entity (El); + Entity : constant Iir := Get_Entity (Lib_Unit); begin -- Note: this is done inside the architecture identifier. Push_Identifier_Prefix (Mark_Entity, Get_Identifier (Entity)); Arch := Get_Block_Specification - (Get_Block_Configuration (El)); + (Get_Block_Configuration (Lib_Unit)); Push_Identifier_Prefix (Mark_Sep, "ARCH"); Push_Identifier_Prefix (Mark_Arch, Get_Identifier (Arch)); Push_Identifier_Prefix (Mark, Name_Table.Get_Identifier ("DEFAULT_CONFIG")); - Chap1.Translate_Configuration_Declaration_Body (El); + Chap1.Translate_Configuration_Declaration_Body (Lib_Unit); Pop_Identifier_Prefix (Mark); Pop_Identifier_Prefix (Mark_Arch); Pop_Identifier_Prefix (Mark_Sep); Pop_Identifier_Prefix (Mark_Entity); end; else - Chap1.Translate_Configuration_Declaration_Decl (El); - Chap1.Translate_Configuration_Declaration_Body (El); + Chap1.Translate_Configuration_Declaration_Decl (Lib_Unit); + Chap1.Translate_Configuration_Declaration_Body (Lib_Unit); end if; when Iir_Kind_Context_Declaration => - New_Debug_Comment_Decl ("context " & Image_Identifier (El)); + New_Debug_Comment_Decl ("context " & Image_Identifier (Lib_Unit)); null; when others => - Error_Kind ("translate", El); + Error_Kind ("translate", Lib_Unit); end case; Current_Filename_Node := O_Dnode_Null; @@ -340,7 +348,7 @@ package body Translation is if Id /= Null_Identifier then Pop_Identifier_Prefix (Unit_Mark); end if; - if Get_Kind (El) = Iir_Kind_Architecture_Body then + if Get_Kind (Lib_Unit) = Iir_Kind_Architecture_Body then Pop_Identifier_Prefix (Sep_Mark); Pop_Identifier_Prefix (Ent_Mark); end if; |