Procedures and Registers

Discussion in 'VHDL' started by makeuptest, Nov 22, 2010.

  1. makeuptest

    makeuptest Guest

    I was writing some code and decided to make it a procedure to put in a
    library. I have written functions many times, but not a procedure.
    This was a routine for some registers and counters internal to the
    procedure and so required a clock and reset. I couldn't figure out
    how to wirte it so that it would be inside a clocked process, so I
    added the clock and reset to the inputs and put the clocking code
    within the procedure.

    That was all well and good. But when I tried to test it, none of the
    internal variables that should have created registers were being
    remembered. I ran a simulation and the variables were getting reset
    initially, but on the next entry to the procedure they were back to
    being undefined.

    Do I have a basic misunderstanding about how procedures operate? I
    haven't found a good reference to explain enough to figure out what I
    am doing wrong.

    Greg
     
    makeuptest, Nov 22, 2010
    #1
    1. Advertising

  2. makeuptest

    KJ Guest

    On Nov 21, 10:34 pm, makeuptest <> wrote:

    >
    > That was all well and good.  But when I tried to test it, none of the
    > internal variables that should have created registers were being
    > remembered.  I ran a simulation and the variables were getting reset
    > initially, but on the next entry to the procedure they were back to
    > being undefined.
    >


    Procedures do not inherently 'remember' the values of internal
    variables or signals as you would have in a process. Instead you must
    make the signal available on the interface of the procedure and hook
    up a real signal to that port.

    This generally means that you must actually add two signals to the
    interface of the procedure: one is an 'input' to the procedure which
    represents the current state of the signal; the other is an 'output'
    of the procedure which represent the next state of the signal.

    > Do I have a basic misunderstanding about how procedures operate?


    Yes...you can't hide signals within a procedure.

    Kevin Jennings
     
    KJ, Nov 22, 2010
    #2
    1. Advertising

  3. makeuptest

    makeuptest Guest

    On Nov 22, 12:00 am, KJ <> wrote:
    > On Nov 21, 10:34 pm, makeuptest <> wrote:
    >
    >
    >
    > > That was all well and good.  But when I tried to test it, none of the
    > > internal variables that should have created registers were being
    > > remembered.  I ran a simulation and the variables were getting reset
    > > initially, but on the next entry to the procedure they were back to
    > > being undefined.

    >
    > Procedures do not inherently 'remember' the values of internal
    > variables or signals as you would have in a process.  Instead you must
    > make the signal available on the interface of the procedure and hook
    > up a real signal to that port.
    >
    > This generally means that you must actually add two signals to the
    > interface of the procedure:  one is an 'input' to the procedure which
    > represents the current state of the signal; the other is an 'output'
    > of the procedure which represent the next state of the signal.
    >
    > > Do I have a basic misunderstanding about how procedures operate?

    >
    > Yes...you can't hide signals within a procedure.
    >
    > Kevin Jennings


    Yes, I finally found a reference that says variables won't retain
    their values between invocations in a procedure. I guess that is
    different from a process, but now that I think about it, that only
    makes sense. In order to have a register created, the process would
    have to pass the value out and back in.

    Thanks
     
    makeuptest, Nov 22, 2010
    #3
  4. On 11/22/2010 2:27 PM, makeuptest wrote:

    > In order to have a register created, the process would
    > have to pass the value out and back in.
    >


    For example, see the procedure "retime" here:
    http://mysite.ncnetwork.net/reszotzl/rise_count.vhd

    -- Mike Treseler
     
    Mike Treseler, Nov 23, 2010
    #4
    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. Calvin
    Replies:
    0
    Views:
    613
    Calvin
    Nov 23, 2005
  2. Robert Gamble

    Floating Point and Wide Registers

    Robert Gamble, Aug 21, 2006, in forum: C Programming
    Replies:
    70
    Views:
    1,217
    Jun Woong
    Sep 4, 2006
  3. Haai
    Replies:
    0
    Views:
    1,371
  4. Mike Halloran

    Volatile and Registers

    Mike Halloran, Mar 3, 2008, in forum: C Programming
    Replies:
    2
    Views:
    959
    Richard Bos
    Mar 3, 2008
  5. rehansherwani
    Replies:
    0
    Views:
    419
    rehansherwani
    Jul 6, 2008
Loading...

Share This Page