Variables in procedures (packages)

Discussion in 'VHDL' started by ALuPin@web.de, Jun 20, 2008.

  1. Guest

    Hi newsgroup,

    I have variables used in a procedure defined in a package. A process
    in a testbench module is calling that
    procedure.
    When marking the package in Modelsim and opening the "Locals" window I
    do not see any variables.

    Is there some way to make them visible ?

    Rgds,
    Andre
    , Jun 20, 2008
    #1
    1. Advertising

  2. Andy Guest

    On Jun 20, 3:21 am, "" <> wrote:
    > Hi newsgroup,
    >
    > I have variables used in a procedure defined in a package. A process
    > in a testbench module is calling that
    > procedure.
    > When marking the package in Modelsim and opening the "Locals" window I
    > do not see any variables.
    >
    > Is there some way to make them visible ?
    >
    > Rgds,
    > Andre


    I'm not sure about this, but I believe that if you go through the
    package, then there is no scope to associate with the procedure. You
    need to drive down through the procedure call in your code to get into
    the procedure body, so that the simulator knows for which instance you
    need the local variables.

    Andy
    Andy, Jun 20, 2008
    #2
    1. Advertising


  3. > On Jun 20, 3:21 am, "" <> wrote:


    >> I have variables used in a procedure defined in a package. A process
    >> in a testbench module is calling that
    >> procedure.


    Andy wrote:
    > I'm not sure about this, but I believe that if you go through the
    > package, then there is no scope to associate with the procedure. You
    > need to drive down through the procedure call in your code to get into
    > the procedure body, so that the simulator knows for which instance you
    > need the local variables.


    Yes. There are two parts to the solution.
    One is an "add wave" command for each calling process.
    Two is to trace code through the procedure
    because that is the only time variable
    local to the procedure are visible.

    Note that procedures *declared* in process scope
    have direct access to process variables, which
    are always visible.

    -- Mike Treseler
    Mike Treseler, Jun 20, 2008
    #3
  4. Guest

    Hi,

    thank you for your comments.
    I think it can indeed be an advantage to use procedures declared in
    the process calling them so that the variables are permanently
    visible.
    When declaring the procedures in a separate package the only way to
    make the variables visible
    is to set a breakpoint on the code line where the procedure is called
    and then to step through
    the code.

    Rgds
    Andre
    , Jun 23, 2008
    #4
  5. rickman Guest

    On Jun 23, 5:53 am, "" <> wrote:
    > Hi,
    >
    > thank you for your comments.
    > I think it can indeed be an advantage to use procedures declared in
    > the process calling them so that the variables are permanently
    > visible.
    > When declaring the procedures in a separate package the only way to
    > make the variables visible
    > is to set a breakpoint on the code line where the procedure is called
    > and then to step through
    > the code.
    >
    > Rgds
    > Andre


    This may be heresy, but another option is to make the procedures small
    enough that you can debug them by eye. If you need a large procedure,
    keep breaking it down into smaller procedures and functions until they
    are small. I try to keep mine under 10 lines total if practical.
    That is the Forth philosophy and it can work if you actually follow
    it.

    The trouble is that simulators are a PITA to use. They are slow,
    require a lot of setup to generate the correct stimulus and can be
    difficult to interpret when you are looking for the source of a bug.
    It can be much better to code in ways that reduce the likelihood of
    creating bugs. The last few passes on my recent design I chose to go
    straight to the chip where I could use a scope on the real circuit
    rather than try to drill down through the simulator. It worked pretty
    well for the slow logic that takes a long time to run in the
    simulator.

    Rick
    rickman, Jun 26, 2008
    #5
    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. Michel Bieleveld

    Procedures, variables and their scope.

    Michel Bieleveld, Oct 27, 2004, in forum: VHDL
    Replies:
    5
    Views:
    3,790
    Mike Treseler
    Oct 29, 2004
  2. Mark
    Replies:
    4
    Views:
    7,981
    mike_treseler
    Nov 9, 2004
  3. Paul  Smith
    Replies:
    0
    Views:
    729
    Paul Smith
    Nov 18, 2003
  4. David Lyon
    Replies:
    19
    Views:
    572
    David Lyon
    Apr 24, 2009
  5. Ian
    Replies:
    3
    Views:
    166
Loading...

Share This Page