Visibility rules

Discussion in 'VHDL' started by Paul Uiterlinden, May 13, 2011.

  1. I am curious how simulators deal with code as shown below when analyzing it:

    PACKAGE pkg IS
    FUNCTION min
    (
    a : integer;
    b : integer
    ) RETURN integer;
    END PACKAGE pkg;

    PACKAGE BODY pkg IS
    FUNCTION min
    (
    a : integer;
    b : integer
    ) RETURN integer IS
    BEGIN
    IF a < b THEN
    RETURN a;
    ELSE
    RETURN b;
    END IF;
    END FUNCTION min;
    END PACKAGE BODY pkg;

    ENTITY ent IS
    END ENTITY ent;

    USE work.pkg.ALL;

    ARCHITECTURE arch OF ent IS
    BEGIN
    p: PROCESS IS
    VARIABLE v : integer;
    BEGIN
    v := min(123, 456);
    WAIT;
    END PROCESS p;
    END ARCHITECTURE arch;

    I use ModelSim. Up to version 10.0 (including 10.0beta1) this used to work
    fine. Version 10.0a (and I suppose 10.0 as well) now complains:

    ** Error: vhdl/function_min.vhd(34): (vcom-1078) Identifier "min" is not
    directly visible.
    Potentially visible declarations are:
    std.STANDARD.min (physical unit)
    work.pkg.min (function)

    So clearly there is a collision now with the physical unit "min" from type
    TIME.

    Technote MG539708 by Mentor explains that the above behaviour is LRM
    compliant. The fact that this used to work in earlier versions is an
    unlucky event, based on the order in which declarations were found (USE
    clauses). The clause "USE std.standard.all" always is present implicitly.

    So, could somebody please analyze the above code in a different simulator to
    see if it is accepted or not?

    Additionally, I wonder why a function name "DEL" (instead of "min) *is*
    accepted. DEL is one of the enumeration literals of type CHARACTER.

    To add to the fun: this is not accepted by any version of ModelSim:

    PACKAGE pkg IS
    COMPONENT del IS
    END COMPONENT del;
    END PACKAGE pkg;

    ENTITY ent IS
    END ENTITY ent;

    USE work.pkg.ALL;

    ARCHITECTURE arch OF ent IS
    BEGIN
    del_i: del;
    END ARCHITECTURE arch;

    Ah, wait a minute: the clarification of error message 1078 explains why del
    can be used as function and not as a component (both declared in a
    package):

    vcom Message # 1078:
    The name is ambiguous according to the visibility rules.
    IEEE Std 1076-1993, 10.4 Use clauses, line 234:
    Potentially visible declarations that have the same designator are not
    made directly visible unless each of them is either an enumeration
    literal specification or the declaration of a subprogram (either by a
    subprogram declaration or by an implicit declaration).

    Still, I am curious if my code with function min fails in other simulators.

    --
    Paul Uiterlinden
    www.aimvalley.nl
    e-mail addres: remove the not.
     
    Paul Uiterlinden, May 13, 2011
    #1
    1. Advertising

  2. Alan Fitch wrote:

    >> Still, I am curious if my code with function min fails in other
    >> simulators.
    >>

    >
    > It fails in Cadence:
    >
    > ncvhdl -v93 test.vhd
    > ncvhdl: 10.20-s009: (c) Copyright 1995-2011 Cadence Design Systems, Inc.
    > v := min(123, 456);
    > |
    > ncvhdl_p: *E,IDENRD (test.vhd,34|13): identifier (MIN) is not visible,
    > as it is directly visible via use clauses from more than one design
    > unit. This results in conflict. This object is defined at:
    > STD.STANDARD
    > WORKLIB.PKG


    Thanks. That is the correct answer (LRM-wise). If only ModelSim would have
    given that answer years ago. Now I'm stuck with many many VHDL files that
    are not LRM compliant.

    I was happy when I read that in VHDL-2008 the functions minimum and maximum
    where added, instead of min and max. Those function names where already in
    use by me. Now I now that min was a bad choice anyway.

    --
    Paul Uiterlinden
    www.aimvalley.nl
    e-mail addres: remove the not.
     
    Paul Uiterlinden, May 16, 2011
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    15
    Views:
    1,346
    Jerry Coffin
    Feb 1, 2005
  2. Balu

    Data Grid Column Visibility

    Balu, Jan 3, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    526
  3. Balu
    Replies:
    4
    Views:
    15,008
    =?Utf-8?B?Tm90SGVscGZ1bA==?=
    Jan 12, 2006
  4. RMD
    Replies:
    0
    Views:
    395
  5. C

    Form Fields Visibility

    C, Oct 28, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    413
    Guest
    Oct 28, 2003
Loading...

Share This Page