Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > operation in procdure

Reply
Thread Tools

operation in procdure

 
 
IcYdRIP
Guest
Posts: n/a
 
      04-13-2005
I have to reuse the same call many times. so I plan to use a procedure.
I've read the reference manual and some books, But I still don't know
if it's possible to use a clock signal from entity in the procedure. I
mean, if there's a clk signal in the entity, and I define a procedure
in the package, the declaration as follow for example:

procedure dm9000_rd_data(signal clk : in std_logic; reg : in
std_logic_vector(7 downto 0); signal daBus : inout std_logic_vector(7
downto 0); signal cmd, cs, iowait, rd : out std_logic;

and can I use the clk as it's in a entity? such as clk's events and
values. or I can just read the clk value only?

thanks!

 
Reply With Quote
 
 
 
 
Paul Uiterlinden
Guest
Posts: n/a
 
      04-13-2005
IcYdRIP wrote:
> I have to reuse the same call many times. so I plan to use a procedure.
> I've read the reference manual and some books, But I still don't know
> if it's possible to use a clock signal from entity in the procedure. I
> mean, if there's a clk signal in the entity, and I define a procedure
> in the package, the declaration as follow for example:
>
> procedure dm9000_rd_data(signal clk : in std_logic; reg : in
> std_logic_vector(7 downto 0); signal daBus : inout std_logic_vector(7
> downto 0); signal cmd, cs, iowait, rd : out std_logic;
>
> and can I use the clk as it's in a entity? such as clk's events and
> values. or I can just read the clk value only?


WAIT is supported in procedures. Also attributes such as 'EVENT can be
used. That's why you must declare the formal parameter as signal.

Paul.
 
Reply With Quote
 
 
 
 
cristian
Guest
Posts: n/a
 
      04-13-2005

The signals declared in the procedure declaration are local to the
procedure. So, you can have a clock signal for using within the
procedure.
When invoking the procedure you will associate a signal to the
procedure's clock signal. That associated signal can be the clock that
you have declared in the entity.
Since clock is declared as signal you can use all the attributes
available for signals.

rgds,

cristian

 
Reply With Quote
 
Mike Treseler
Guest
Posts: n/a
 
      04-13-2005
cristian wrote:
> The signals declared in the procedure declaration are local to the
> procedure. So, you can have a clock signal for using within the
> procedure.


A procedure can use a signal passed to it,
or a signal in the scope of the calling process,
but if I try to *declare* a signal inside a procedure
declaration, I will see something like this:

** Error: Signal declaration 'bozo' not allowed in this region.

Signals can be "local" to an architecture, block or package.

-- Mike Treseler
 
Reply With Quote
 
IcYdRIP
Guest
Posts: n/a
 
      04-14-2005
thank you !
since signal declaration is not allowed in the procedure. so the
signals used in a procedure must be passed from others.

but I have a doubt. if I invoke a procedure in a process, and the
process with a clock sensitive signal. since in a process, all sentence
are executed step by step. when invoking a procedure, the clock signal
maybe had a stabel value, not in the up edge or down edge. so what
about the clk's event property? or because the executing time is very
very short and is always lower than the smallest standard time scale,
the procedure will still use the event property? or all the property
will delayed for 1 clock cycle?
thank you!

 
Reply With Quote
 
Mike Treseler
Guest
Posts: n/a
 
      04-14-2005
IcYdRIP wrote:
> thank you !


You are welcome.

> but I have a doubt. if I invoke a procedure in a process, and the
> process with a clock sensitive signal.


A vhdl procedure is not so complicated.
It is mainly an editing convenience.
Get a simulator, try it and see.
Any invocation of a procedure can be replaced
by the one or more lines of code that the
procedure represents.

See my folder for procedure examples for
design and simulation.

http://home.comcast.net/~mike_treseler/


-- Mike Treseler
 
Reply With Quote
 
IcYdRIP
Guest
Posts: n/a
 
      04-14-2005
thank you, Mike
I read and try them first.

 
Reply With Quote
 
cristian
Guest
Posts: n/a
 
      04-15-2005
Mike,
you are right based on what I wrote, but what I wrote is actually not
what I mean...
Based on the Procedure definition:
"Formal parameters are separated by semicolons in the formal parameter
list. Each formal parameter is essentially a declaration of an
object that is local to the procedure. "
I was refering to the formal parameter that may be declared as a
signal. Therefore, it's local to the procedure. If the formal
parameter is associated with an 'actual' signal that is a clock signal,
the clock can be used within the procedure.
Sorry, about not being clear on my writting.

rgds,

cristian

 
Reply With Quote
 
IcYdRIP
Guest
Posts: n/a
 
      04-15-2005
that's ok, cristian. thank you!

and Mike, I've read the uart code.
It seems all procedures(not in testbench vhdl file) have no parameters.
and all variables declared in the process are all visible in the
procedures which are invoked in the process.

but as book wrote, a procedure doesn't return any result, just change
the parameter value which will affect the actual parameters when
invoking. and all variables in a procedure are dynamic, they don't
store values during two calls. or this rule just affect the variables
which are declared in the procedure.

so, as the example uart code wrote, if the variables are declared in
the process which invokes the procedure, then the procedure can use
these variables and pass the changed values to the process?

thank you!

 
Reply With Quote
 
Mike Treseler
Guest
Posts: n/a
 
      04-16-2005
IcYdRIP wrote:

> and Mike, I've read the uart code.
> It seems all procedures(not in testbench vhdl file) have no parameters.


True. For synthesis, I use procedures to break up
the pages of sequential code that a single process
entity requires. Attaching identifiers to blocks of
code allows me to make the top level procedures
easier to read. It also allows me to match the
specific design to the template, that can be used
for _any_ design.

> and all variables declared in the process are all visible in the
> procedures which are invoked in the process.


Yes. This is the upside for single
process design entities. No signal
declarations are required.

> but as book wrote, a procedure doesn't return any result, just change
> the parameter value which will affect the actual parameters when
> invoking. and all variables in a procedure are dynamic, they don't
> store values during two calls. or this rule just affect the variables
> which are declared in the procedure.


Note that the variables *and* the procedures
are declared between the IS and BEGIN of the single process.
No variables are declared in the procedures.
Each process has access can read or write variables
declared above above.

This allows code simplification,
like modifying tx and rx state variables
in the the cpu_regs procedure.

> so, as the example uart code wrote, if the variables are declared in
> the process which invokes the procedure, then the procedure can use
> these variables and pass the changed values to the process?


Yes. You've got it.

-- 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
Boolean operation and arithmetic operation Buzz Lightyear C++ 10 08-12-2009 01:27 PM
I/O operation, file operation behaviou raan C++ 2 08-16-2007 07:13 PM
Does bit operation always work more efficiently than math operation? david ullua C Programming 13 03-01-2006 11:02 PM
DWL-G650 operation with (and without) WPA2 Fred Marshall Wireless Networking 6 05-08-2005 02:14 AM
my AMD compaq laptop frooze about 4 minutes of operation =?Utf-8?B?SGFycnkgTGV1bmc=?= Wireless Networking 0 08-17-2004 04:15 AM



Advertisments