How portable is this code?

T

Tricky

consider the following functions:

function get_i return integer is
begin
return 10;
end function get_i;

function get_i return boolean is
begin
return true;
end function get_i;

they both have the same name but different return types. are these
going to be safe in something like this statement across most, if not
all simulators?

echo(integer'image(get_i) & " " & boolean'image(get_i) & LF);

Am I creating a potentially confusing (for the simulator/synthesisor)
situation?
 
M

Mike Treseler

Tricky said:
Am I creating a potentially confusing (for the simulator/synthesisor)
situation?

As long as the return types are different,
the function IDs can be the same.

-- Mike Treseler
 
M

Martin Thompson

Tricky said:
consider the following functions:

function get_i return integer is
begin
return 10;
end function get_i;

function get_i return boolean is
begin
return true;
end function get_i;

I make lots of use of this in my simulations. For example, I have
functions to decode data streams which can return several different types,
depending on how much the data I'm interested in having returned to
me.

I've never tried it in synthesis though - it ought to work,
but... well, let's say I'm a bit more pessimistic in my expectations
of synth tools (although not as much as some are :)

Cheers,
Martin
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top