Which function takes precedence when multiple are visible?

K

kevin.neilson

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?
 
K

KJ

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top