diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-08-20 05:22:06 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-08-20 05:22:06 +0200 |
commit | 6bb756cc46b8c717d7f84cbe6e01ed79f84f484a (patch) | |
tree | 1ca5bb3a1d71698ddc3b9e0a7c27ab2467f0b242 | |
parent | 44cba3374a04d84b16c93a9e6867ddc4b8a3146c (diff) | |
download | ghdl-6bb756cc46b8c717d7f84cbe6e01ed79f84f484a.tar.gz ghdl-6bb756cc46b8c717d7f84cbe6e01ed79f84f484a.tar.bz2 ghdl-6bb756cc46b8c717d7f84cbe6e01ed79f84f484a.zip |
vhdl: handle architecture in verification unit hierarchical name.
-rw-r--r-- | src/vhdl/vhdl-parse.adb | 12 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem.adb | 10 | ||||
-rw-r--r-- | src/vhdl/vhdl-sem_psl.adb | 44 |
3 files changed, 53 insertions, 13 deletions
diff --git a/src/vhdl/vhdl-parse.adb b/src/vhdl/vhdl-parse.adb index 1983409a5..e79f31526 100644 --- a/src/vhdl/vhdl-parse.adb +++ b/src/vhdl/vhdl-parse.adb @@ -9800,9 +9800,19 @@ package body Vhdl.Parse is Hier_Name := Create_Iir (Iir_Kind_Psl_Hierarchical_Name); Set_Location (Hier_Name); + Set_Hierarchical_Name (Res, Hier_Name); + Set_Entity_Name (Hier_Name, Parse_Simple_Name); - Set_Hierarchical_Name (Res, Hier_Name); + if Current_Token = Tok_Left_Paren then + -- Skip '('. + Scan; + + Set_Architecture (Hier_Name, Parse_Simple_Name); + + -- Skip ')'. + Expect_Scan (Tok_Right_Paren); + end if; -- Skip ')' Expect_Scan (Tok_Right_Paren); diff --git a/src/vhdl/vhdl-sem.adb b/src/vhdl/vhdl-sem.adb index e99d7f860..555c6a733 100644 --- a/src/vhdl/vhdl-sem.adb +++ b/src/vhdl/vhdl-sem.adb @@ -1113,11 +1113,11 @@ package body Vhdl.Sem is -- a use clause that makes a homograph of the declaration potentially -- visible (see 10.4) appears in the corresponding configuration -- declaration, and if the scope of that use clause encompasses all or - -- part of those configuration items. If such a use clase appears, then - -- the declaration will be directly visible within the corresponding - -- configuration items, except at hose places that fall within the scope - -- of the additional use clause. At such places, neither name will be - -- directly visible. + -- part of those configuration items. If such a use clause appears, + -- then the declaration will be directly visible within the + -- corresponding configuration items, except at hose places that fall + -- within the scope of the additional use clause. At such places, + -- neither name will be directly visible. -- FIXME: handle use clauses. Sem_Scopes.Extend_Scope_Of_Block_Declarations (Block); diff --git a/src/vhdl/vhdl-sem_psl.adb b/src/vhdl/vhdl-sem_psl.adb index b99ee5a17..e4823cd69 100644 --- a/src/vhdl/vhdl-sem_psl.adb +++ b/src/vhdl/vhdl-sem_psl.adb @@ -890,36 +890,49 @@ package body Vhdl.Sem_Psl is procedure Sem_Hierarchical_Name (Hier_Name : Iir; Unit : Iir) is Entity_Name : Iir; - Entity : Iir; + Design_Entity : Iir; + Lib_Entity : Iir; + Arch_Name : Iir; + Arch : 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 + Design_Entity := Sem_Lib.Load_Primary_Unit (Library, Get_Identifier (Entity_Name), Entity_Name); - if Entity = Null_Iir then + if Design_Entity = Null_Iir then Error_Msg_Sem (+Entity_Name, "entity %n was not analysed", +Entity_Name); return; end if; - Entity := Get_Library_Unit (Entity); + Lib_Entity := Get_Library_Unit (Design_Entity); - if Get_Kind (Entity) /= Iir_Kind_Entity_Declaration then + if Get_Kind (Lib_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); + Set_Named_Entity (Entity_Name, Lib_Entity); + Xrefs.Xref_Ref (Entity_Name, Lib_Entity); + + Arch_Name := Get_Architecture (Hier_Name); + if Arch_Name /= Null_Iir then + Arch := Sem_Lib.Load_Secondary_Unit + (Design_Entity, Get_Identifier (Arch_Name), Arch_Name); + if Arch /= Null_Iir then + Set_Named_Entity (Arch_Name, Get_Library_Unit (Arch)); + end if; + end if; end Sem_Hierarchical_Name; procedure Sem_Psl_Verification_Unit (Unit : Iir) is Hier_Name : constant Iir := Get_Hierarchical_Name (Unit); Entity : Iir; + Arch : Iir; Item : Iir; begin if Hier_Name = Null_Iir then @@ -939,12 +952,25 @@ package body Vhdl.Sem_Psl is return; end if; + Arch := Get_Architecture (Hier_Name); + if Arch /= Null_Iir then + Arch := Get_Named_Entity (Arch); + if Arch = Null_Iir then + return; + end if; + 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); + if Arch /= Null_Iir then + Sem_Scopes.Open_Scope_Extension; + Sem_Scopes.Extend_Scope_Of_Block_Declarations (Arch); + end if; + Item := Get_Vunit_Item_Chain (Unit); while Item /= Null_Iir loop case Get_Kind (Item) is @@ -961,6 +987,10 @@ package body Vhdl.Sem_Psl is Item := Get_Chain (Item); end loop; + if Arch /= Null_Iir then + Sem_Scopes.Close_Scope_Extension; + end if; + Sem_Scopes.Close_Declarative_Region; Set_Is_Within_Flag (Entity, False); end Sem_Psl_Verification_Unit; |