Which function takes precedence when multiple are visible?

Discussion in 'VHDL' started by kevin.neilson@xilinx.com, Apr 3, 2013.

  1. Guest

    This seems like it would be a common question, but I can't find the answer.

    I just wonder which function takes precedence if there are two functions with the same name (and argument/return types) in different visible packages:

    use work.pkga.my_function;
    use work.pkgb.my_function;

    ....

    a <= my_function(b); -- am I using pkga or pkgb?
     
    , Apr 3, 2013
    #1
    1. Advertising

  2. KJ Guest

    On Tuesday, April 2, 2013 9:12:51 PM UTC-4, wrote:
    > This seems like it would be a common question, but I can't find the answer.
    > I just wonder which function takes precedence if there are two functions
    > with the same name (and argument/return types) in different visible packages:
    > use work.pkga.my_function;
    > use work.pkgb.my_function;
    > ... a <= my_function(b); -- am I using pkga or pkgb?


    Neither package will take precedence. When you compile, you will get an error that says something to the effect that there is more than one function that could be used in this case. The language definition does not allow for assumptions to be made (that's a 'good thing' by the way).

    If you have to have both packages visible via the 'use' statement than you would have to specify which package you want to use in the functino call like this...

    a <= work.pkga.my_function(b);
    aa <= work.pkgb.my_function(b);

    Kevin Jennings
     
    KJ, Apr 3, 2013
    #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. spamfurnace
    Replies:
    1
    Views:
    2,636
    Scott M.
    May 24, 2004
  2. Lee
    Replies:
    5
    Views:
    3,011
  3. Neo
    Replies:
    10
    Views:
    665
    sushant
    Jan 20, 2005
  4. Replies:
    1
    Views:
    474
    Victor Bazarov
    Jul 20, 2005
  5. =?utf-8?B?5YiY5piK?=
    Replies:
    4
    Views:
    454
    Bo Persson
    Jul 26, 2007
Loading...

Share This Page