How portable is this code?

Discussion in 'VHDL' started by Tricky, Nov 14, 2008.

  1. Tricky

    Tricky Guest

    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?
    Tricky, Nov 14, 2008
    #1
    1. Advertising

  2. Tricky wrote:

    > 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
    Mike Treseler, Nov 14, 2008
    #2
    1. Advertising

  3. Tricky <> writes:

    > 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

    --

    TRW Conekt - Consultancy in Engineering, Knowledge and Technology
    http://www.conekt.net/electronics.html
    Martin Thompson, Nov 17, 2008
    #3
    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. Eli Bendersky
    Replies:
    1
    Views:
    1,146
    Mike Treseler
    Mar 1, 2006
  2. Shin
    Replies:
    5
    Views:
    4,291
  3. The Saqe

    Looking for portable C++ code

    The Saqe, Sep 23, 2003, in forum: C++
    Replies:
    3
    Views:
    341
    Noah Roberts
    Sep 24, 2003
  4. Rolf Hemmerling
    Replies:
    3
    Views:
    741
    Roger Leigh
    Oct 31, 2003
  5. Replies:
    7
    Views:
    897
Loading...

Share This Page