procedure as argument in procedure

Discussion in 'VHDL' started by AlexWare, Oct 21, 2009.

  1. AlexWare

    AlexWare Guest

    Hello everybody,

    in a behavioral model I would like to pass a procedure as argument in
    a procedure call.
    I read that formal parameters in a subprogram can be only constants,
    variables or signals; is there any, usual or recommended way to do
    what I need?

    Thanks.


    Alex
     
    AlexWare, Oct 21, 2009
    #1
    1. Advertising

  2. AlexWare <> writes:

    > Hello everybody,
    >
    > in a behavioral model I would like to pass a procedure as argument in
    > a procedure call.
    > I read that formal parameters in a subprogram can be only constants,
    > variables or signals; is there any, usual or recommended way to do
    > what I need?
    >


    No. You're stuck, as far as I can tell. If you have a very small
    universe of procedures you might want to call, you can pass a token
    (e.g. a number) to say which function you meant to call, then manually
    dispatch inside the procedure by switching on the token.

    Otherwise, you can create your design using another language (LISP,
    Haskell, etc) that can do these sorts of things and then translate,
    but that could easily turn into a thesis project!

    - Kenn

    > Thanks.
    >
    >
    > Alex
     
    Kenn Heinrich, Oct 21, 2009
    #2
    1. Advertising

  3. AlexWare wrote:

    > Hello everybody,
    >
    > in a behavioral model I would like to pass a procedure as argument in
    > a procedure call.
    > I read that formal parameters in a subprogram can be only constants,
    > variables or signals; is there any, usual or recommended way to do
    > what I need?


    The closest thing that comes to mind is VHDL-2008. Note however that as far
    as I know the features needed here have not yet been implemented in any
    simulator.

    What you could use is a procedure with a generic. That generic then would
    not be a generic constant as we know it today, but a generic subprogram
    instead.

    VHDL-2008 has expanded the capabilities of "generics" in two ways.

    Firstly, the things that we usually call a generic is actually a generic
    constant. That has changed in VHDL-2008: besides generic constants you can
    now have generic types and generic subprograms as well. That means that you
    can pass a type, procedure or function through a generic map.

    Secondly, generics can be applied on subprograms (and packages) in
    VHDL-2008. But to use such a subprogram, it must first be instantiated one
    or multiple times, with a generic map, resulting in different versions of
    the original subprogram.

    The book VHDL-2008 by Ashenden/Lewis has lots of more details.

    But as said above, it is not usable at the moment by the lack of support of
    simulators. And I don't know if the solution is applicable to your problem.

    --
    Paul Uiterlinden
    www.aimvalley.nl
    e-mail addres: remove the not.
     
    Paul Uiterlinden, Oct 23, 2009
    #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. Bhushit Joshipura

    defaulting argument to previous argument

    Bhushit Joshipura, Dec 29, 2003, in forum: C++
    Replies:
    5
    Views:
    428
  2. Ben Kial
    Replies:
    1
    Views:
    720
    Eric Enright
    Nov 15, 2004
  3. S?ren Gammelmark
    Replies:
    1
    Views:
    1,984
    Eric Sosman
    Jan 7, 2005
  4. nw
    Replies:
    0
    Views:
    338
  5. Reckoner
    Replies:
    11
    Views:
    738
    Steven D'Aprano
    Jan 19, 2009
Loading...

Share This Page