Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - Procedures, variables and their scope.

 
Thread Tools Search this Thread
Old 10-27-2004, 01:47 PM   #1
Default Procedures, variables and their scope.


Hi All,

I have a problem, as far as I know procedures can change
signals/variables as long as the procedures are defined within the
scope where the variables are defined. Yet when i try to simulate my
vhdl code the ISE synthesizer gives me the following warning :

WARNING:Xst:1960 - C:/projects/redemption/ax88796.vhd line 86:
Potential simulation mismatch, variable <register_uit> declared in
block <$PROCESS1> is assigned in block <WriteReg>.

My code looks basicly like the code shown here. It seems like that the
variables within the procedure do not change the variable outside the
procedure, which is what i was hoping for.

Is there any Macro command or something in vhdl, because that is what
i am using the procedure for.

With regards,

Michel Bieleveld.


entity ax88796 is
...
end ax88796;

architecture RTL of ax88796 is
...
begin
process (nRST,CLK)
...
variable operand : std_logic_vector(15 downto 0);

procedure ReadReg(Ax_reg : in std_logic_vector(7 downto 0))is
begin
operand := B"00001110" & Ax_reg;
return_state := current_state;
next_state := st_ExRead;
end ReadReg;

begin
...

blahblah ReadReg(X"00");
...
end process;
end rtl;


Michel Bieleveld
  Reply With Quote
Old 10-27-2004, 02:38 PM   #2
Mike Treseler
 
Posts: n/a
Default Re: Procedures, variables and their scope.
Michel Bieleveld wrote:

> I have a problem, as far as I know procedures can change
> signals/variables as long as the procedures are defined within the
> scope where the variables are defined.


Variables must be passed a parameters to a procedure.

> It seems like that the
> variables within the procedure do not change the variable outside the
> procedure


If you pass the process variable, the procedure can change
its value. Variable scope is local to the procedure or process.
Pass the variable or use a signal.

-- Mike Treseler


Mike Treseler
  Reply With Quote
Old 10-27-2004, 10:57 PM   #3
Michel Bieleveld
 
Posts: n/a
Default Re: Procedures, variables and their scope.
But I thought the difference between (pure) functions and procedures
is that procedures can have side effects. In this case changing a
variable defined in the process from which I am calling the procedure.

<Michel Bieleveld>


Mike Treseler <> wrote in message news:<rOmdnbbU7q9TOeLcRVn->...
> Michel Bieleveld wrote:
>
> > I have a problem, as far as I know procedures can change
> > signals/variables as long as the procedures are defined within the
> > scope where the variables are defined.

>
> Variables must be passed a parameters to a procedure.
>
> > It seems like that the
> > variables within the procedure do not change the variable outside the
> > procedure

>
> If you pass the process variable, the procedure can change
> its value. Variable scope is local to the procedure or process.
> Pass the variable or use a signal.
>
> -- Mike Treseler



Michel Bieleveld
  Reply With Quote
Old 10-28-2004, 12:06 AM   #4
Mike Treseler
 
Posts: n/a
Default Re: Procedures, variables and their scope.
Michel Bieleveld wrote:
> But I thought the difference between (pure) functions and procedures
> is that procedures can have side effects.

True

> In this case changing a
> variable defined in the process from which I am calling the procedure.


Yes, but only if the variable is passed from process scope
to procedure scope.

-- Mike Treseler


Mike Treseler
  Reply With Quote
Old 10-29-2004, 11:09 AM   #5
Alan Fitch
 
Posts: n/a
Default Re: Procedures, variables and their scope.

"Mike Treseler" <> wrote in message
news:caKdnYwPMemVtx3cRVn-...
> Michel Bieleveld wrote:
> > But I thought the difference between (pure) functions and

procedures
> > is that procedures can have side effects.

> True
>
> > In this case changing a
> > variable defined in the process from which I am calling the

procedure.
>
> Yes, but only if the variable is passed from process scope
> to procedure scope.
>


Hallo Mike,
I don't think that's correct. Michel is right, a procedure
declared
within a process can directly access variables declared within the
process,
just as it can directly access signals declared within the
architecture that
contains that process.

Regarding the original problem, Michel can you post your actual code?

regards
Alan

--
Alan Fitch
Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * Perl * Tcl/Tk * Verification * Project
Services

Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24
1AW, UK
Tel: +44 (0)1425 471223 mail:

Fax: +44 (0)1425 471573 Web:
http://www.doulos.com

The contents of this message may contain personal views which are not
the
views of Doulos Ltd., unless specifically stated.



Alan Fitch
  Reply With Quote
Old 10-29-2004, 03:18 PM   #6
Mike Treseler
 
Posts: n/a
Default Re: Procedures, variables and their scope.
Alan Fitch wrote:

> I don't think that's correct. Michel is right, a procedure
> declared within a process can directly access variables declared within the
> process, just as it can directly access signals declared within the
> architecture that contains that process.


Sorry about that.
Yes you and Michel are right, and
I did not read his example carefully.

As long as the variable is declared before the procedure
it is directly visible to that procedure.

My comments applied to packaged procedures
that can be called from any process.

-- Mike Treseler


Mike Treseler
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

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