nvc icon indicating copy to clipboard operation
nvc copied to clipboard

Entity declaration not visibile within it's entity declarative items by selection (expanded name)

Open diogratia opened this issue 11 years ago • 0 comments

entity entity_attr is
  constant MIN_DELAY : NATURAL := 42;
  attribute DELAY   : NATURAL;
  attribute DELAY of entity_attr : entity is MIN_DELAY;
end entity;

architecture foo of entity_attr is

begin
end architecture;

entity test is
end entity;

architecture foe of test is
    constant fumble: natural := work.entity_attr'DELAY;
begin
alu_div_0:
    entity work.entity_attr ;

MONITOR:
    process
    begin
        report "constant fumble = " & natural'image(fumble);
        report "alu_div'DELAY = " & natural'image(work.entity_attr'DELAY);
        wait;
    end process;
end architecture;

Expected behavior:

ghdl -a entity_attr.vhdl
ghdl -e test
ghdl -r test
entity_attr.vhdl:24:9:@0ms:(report note): constant fumble = 42
entity_attr.vhdl:25:9:@0ms:(report note): alu_div'DELAY = 42

nvc's peformance:

nvc -a entity_attr.vhdl
** Error: no visible declaration for WORK.ENTITY_ATTR
    File entity_attr.vhdl, Line 16
        constant fumble: natural := work.entity_attr'DELAY;
                                    ^^^^^^^^^^^^^^^^

Authorities: IEEE Std 1076-2008 8.3 Selected names paras 1 and 3:

A selected name is used to denote a named entity whose declaration appears either within the declaration of another named entity or within a design library.

A selected name can denote an element of a record, an object designated by an access value, or a named entity whose declaration is contained within another named entity, particularly within a library, a package, or a protected type. Furthermore, a selected name can denote all named entities whose declarations are contained within a library or a package.

para 9 (the usage is of an expanded name):

An expanded name denotes a named entity declared immediately within a named construct if the prefix denotes a construct that is an entity declaration, an architecture body, a subprogram declaration, a subprogram body, a block statement, a process statement, a generate statement, a loop statement, or a protected type definition, and the suffix is the simple name, character literal, or operator symbol of a named entity whose declaration occurs immediately within that construct. This form of expanded name is only allowed within the construct itself, or if the prefix denotes an entity declaration and the expanded name occurs within an architecture body corresponding to the entity declaration.

Note the entity declarative items are part of the entity declaration. See 3.2 Entity declaration, 3.2.1 General, the BNF para 2 (which is authoritative outside the syntax summary Annex).

Also see 12.2 Scope of declarations, para 2:

The scope of a declaration, except for an architecture body, extends from the beginning of the declaration to the end of the immediately closing declarative region; the scope of an architecture body extends from the beginning to the end of the architecture body. In either case, this part of the scope of a declaration is called the immediate scope. ...

12.3 Visibility, para 3:

A declaration is visible only within a certain part of its scope; this part starts at the end of the declaration except in the declaration of a design unit other than a PSL verification unit, a package declaration, or a protected type declaration, in which case it starts immediately after the reserved word is occurring after the identifier of the design unit, a package declaration, or protected type declaration. This rule applies to both explicit and implicit declarations. ...

diogratia avatar Jun 02 '15 00:06 diogratia