Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Procedures and Registers

Reply
Thread Tools

Procedures and Registers

 
 
makeuptest
Guest
Posts: n/a
 
      11-22-2010
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
 
Reply With Quote
 
 
 
 
KJ
Guest
Posts: n/a
 
      11-22-2010
On Nov 21, 10:34*pm, makeuptest <spamgoeshe...@yahoo.com> 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
 
Reply With Quote
 
 
 
 
makeuptest
Guest
Posts: n/a
 
      11-22-2010
On Nov 22, 12:00*am, KJ <kkjenni...@sbcglobal.net> wrote:
> On Nov 21, 10:34*pm, makeuptest <spamgoeshe...@yahoo.com> 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
 
Reply With Quote
 
Mike Treseler
Guest
Posts: n/a
 
      11-23-2010
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding two registers A and B in vhdl Haai VHDL 0 08-18-2007 07:28 PM
Adding two registers A and B in vhdl Haai Hardware 0 08-18-2007 03:56 PM
Floating Point and Wide Registers Robert Gamble C Programming 70 09-04-2006 04:10 AM
jtag/ATPG and read-only registers Calvin VHDL 0 11-23-2005 04:43 AM
About Latches and Registers was (When do I always put a "else NULL"statement in my VHDL code?) Ingmar Seifert VHDL 0 09-14-2003 07:57 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57