Procedures and Registers

M

makeuptest

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
 
K

KJ

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
 
M

makeuptest

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.


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
 

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

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top