FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > VHDL

VHDL comp.lang.vhdl newsgroup / Usenet

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-03-2003, 03:06 PM
Matt North
Guest
 
Posts: n/a
Default Subprograms

The while loop below is used in a subprogram

while i<=something loop
dosomething
i:=i+1;
exit when i=something+1;
end loop;

is it possible to use the values of i in another process which calls this
subroutine while i is changing.
i.e. use the value of i to strobe the address of ram.

When i simulate i just get the final value of i. NOT USEFULL.



Reply With Quote
  #2 (permalink)  
Old 11-03-2003, 04:27 PM
Mike Treseler
Guest
 
Posts: n/a
Default Re: Subprograms

Matt North wrote:
> The while loop below is used in a subprogram
>
> while i<=something loop
> dosomething
> i:=i+1;
> exit when i=something+1;
> end loop;
>
> is it possible to use the values of i in another process which calls this
> subroutine while i is changing.


Variables local to the procedure
go out of scope at the exit.

The calling process has to have
the variable or signal already
declared and in scope to pass it as an
inout parameter to the procedure.

Another process could not have access
to the same variable. You could have
two processes share a signal as long
and one is the driver and the other
just reads it.

-- Mike Treseler

Reply With Quote
  #3 (permalink)  
Old 11-03-2003, 04:54 PM
Jim Lewis
Guest
 
Posts: n/a
Default Re: Subprograms

You can add a signal out to your procedure and then
strobe it at the appropriate time.

One way to do this (testbench style):
Drive Strobe such that each time it gets the opposite
value that it previously had (requires Strobe to be initialized
somewhere - I suggest initializing the signal):
Strobe <= not Strobe ; -- strobe must be class INOUT
Alternately: Strobe <= i ; -- if strobe is an integer

Wake up when strobe changes:
wait on Strobe ;

Alternately (closer to real hardware behavior):
Drive nAds so it is a clock cycle wide (like 386):
nAds <= '0' after tpd, '1' after tpd + tperiod_clk ;

Wake up when nAds is high on the rising edge of Clk:
wait on Clk until nAds = '1' and Clk = '1' ;


Cheers,
Jim
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~
Jim Lewis
Director of Training mailto:[email protected]
SynthWorks Design Inc. http://www.SynthWorks.com
1-503-590-4787

Expert VHDL Training for Hardware Design and Verification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~

Matt North wrote:
> The while loop below is used in a subprogram
>
> while i<=something loop
> dosomething
> i:=i+1;
> exit when i=something+1;
> end loop;
>
> is it possible to use the values of i in another process which calls this
> subroutine while i is changing.
> i.e. use the value of i to strobe the address of ram.
>
> When i simulate i just get the final value of i. NOT USEFULL.
>
>
>


Reply With Quote
  #4 (permalink)  
Old 11-03-2003, 05:15 PM
Matt North
Guest
 
Posts: n/a
Default Re: Subprograms

Jim,

> Alternately (closer to real hardware behavior):
> Drive nAds so it is a clock cycle wide (like 386):
> nAds <= '0' after tpd, '1' after tpd + tperiod_clk ;


My procedure is called in a process;

process(rst, clk)
variable ptr: int_r;
begin
rising_edge(clk) then
wr<='1';
proc1(ram, ptr, "jksdf kjsdfjk");
end if;
addr_int<=ptr;
end process;

The contents of the procedure;

procedure proc1(signal data: out bit_vector(7 downto 0);
variable ptr: out int_r;
info: string) is

variable i: int_r:=0;

begin

while i<=info'HIGH loop
if i=0 then
data<=prel;
i:=i+1;
elsif i<=info'LENGTH then
data<=func_call(info(i));
i:=i+1;
else
data<=(others=>'0');
end if;
end if;
ptr:=i;
exit when i=info'HIGH+1;
end loop;

end ChWriteMM;

I would like to be able to get all the values of the variable i as it
increments and use them to strobe a ram address.
I dont think this is possible as the procedure is being called in one clk
cycle.
The variable i is incrementing but at what period i do not know.
When i simulate the code the value of ptr is the final value of i
(info'HIGH), this is no good i need to pass all the
values of i as it reaches info'HIGH.

Thanks,
Matt


"Jim Lewis" <[email protected]> wrote in message
news:[email protected]
> You can add a signal out to your procedure and then
> strobe it at the appropriate time.
>
> One way to do this (testbench style):
> Drive Strobe such that each time it gets the opposite
> value that it previously had (requires Strobe to be initialized
> somewhere - I suggest initializing the signal):
> Strobe <= not Strobe ; -- strobe must be class INOUT
> Alternately: Strobe <= i ; -- if strobe is an integer
>
> Wake up when strobe changes:
> wait on Strobe ;
>
> Alternately (closer to real hardware behavior):
> Drive nAds so it is a clock cycle wide (like 386):
> nAds <= '0' after tpd, '1' after tpd + tperiod_clk ;
>
> Wake up when nAds is high on the rising edge of Clk:
> wait on Clk until nAds = '1' and Clk = '1' ;
>
>
> Cheers,
> Jim
> --
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~
> Jim Lewis
> Director of Training mailto:[email protected]
> SynthWorks Design Inc. http://www.SynthWorks.com
> 1-503-590-4787
>
> Expert VHDL Training for Hardware Design and Verification
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~
>
> Matt North wrote:
> > The while loop below is used in a subprogram
> >
> > while i<=something loop
> > dosomething
> > i:=i+1;
> > exit when i=something+1;
> > end loop;
> >
> > is it possible to use the values of i in another process which calls

this
> > subroutine while i is changing.
> > i.e. use the value of i to strobe the address of ram.
> >
> > When i simulate i just get the final value of i. NOT USEFULL.
> >
> >
> >

>



Reply With Quote
  #5 (permalink)  
Old 11-03-2003, 08:03 PM
Jim Lewis
Guest
 
Posts: n/a
Default Re: Subprograms

Matt,
I recommend that you simulate this before
you go further. Your while loop in the
procedure proc1 executes in 0 time. Since
no time passes between iterations (assigments
to data), when a value of data is scheduled it will
replace (meaning delete from ever happening) the
previous value. So the only value on data
is the last value.

Time needs to pass when apply run your sequence on
data. Note procedures (unlike functions) are permitted
to have wait statements in them. If you are waiting on
a data object, that object will need to have the class
of signal.

You might want to reconsider your problem.
You want your procedures to do an action on an
interface. This means that if you are driving things
to a RAM interface, then you will want the procedure
to drive data, address, and the control signals.

Cheers,
Jim

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~
Jim Lewis
Director of Training mailto:[email protected]
SynthWorks Design Inc. http://www.SynthWorks.com
1-503-590-4787

Expert VHDL Training for Hardware Design and Verification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~

Matt North wrote:

> Jim,
>
>
>>Alternately (closer to real hardware behavior):
>>Drive nAds so it is a clock cycle wide (like 386):
>> nAds <= '0' after tpd, '1' after tpd + tperiod_clk ;

>
>
> My procedure is called in a process;
>
> process(rst, clk)
> variable ptr: int_r;
> begin
> rising_edge(clk) then
> wr<='1';
> proc1(ram, ptr, "jksdf kjsdfjk");
> end if;
> addr_int<=ptr;
> end process;
>
> The contents of the procedure;
>
> procedure proc1(signal data: out bit_vector(7 downto 0);
> variable ptr: out int_r;
> info: string) is
>
> variable i: int_r:=0;
>
> begin
>
> while i<=info'HIGH loop
> if i=0 then
> data<=prel;
> i:=i+1;
> elsif i<=info'LENGTH then
> data<=func_call(info(i));
> i:=i+1;
> else
> data<=(others=>'0');
> end if;
> end if;
> ptr:=i;
> exit when i=info'HIGH+1;
> end loop;
>
> end ChWriteMM;
>
> I would like to be able to get all the values of the variable i as it
> increments and use them to strobe a ram address.
> I dont think this is possible as the procedure is being called in one clk
> cycle.
> The variable i is incrementing but at what period i do not know.
> When i simulate the code the value of ptr is the final value of i
> (info'HIGH), this is no good i need to pass all the
> values of i as it reaches info'HIGH.
>
> Thanks,
> Matt
>
>
> "Jim Lewis" <[email protected]> wrote in message
> news:[email protected]
>
>>You can add a signal out to your procedure and then
>>strobe it at the appropriate time.
>>
>>One way to do this (testbench style):
>>Drive Strobe such that each time it gets the opposite
>>value that it previously had (requires Strobe to be initialized
>>somewhere - I suggest initializing the signal):
>> Strobe <= not Strobe ; -- strobe must be class INOUT
>> Alternately: Strobe <= i ; -- if strobe is an integer
>>
>>Wake up when strobe changes:
>> wait on Strobe ;
>>
>>Alternately (closer to real hardware behavior):
>>Drive nAds so it is a clock cycle wide (like 386):
>> nAds <= '0' after tpd, '1' after tpd + tperiod_clk ;
>>
>>Wake up when nAds is high on the rising edge of Clk:
>> wait on Clk until nAds = '1' and Clk = '1' ;
>>
>>
>>Cheers,
>>Jim
>>--
>>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~
>>Jim Lewis
>>Director of Training mailto:[email protected]
>>SynthWorks Design Inc. http://www.SynthWorks.com
>>1-503-590-4787
>>
>>Expert VHDL Training for Hardware Design and Verification
>>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~
>>
>>Matt North wrote:
>>
>>>The while loop below is used in a subprogram
>>>
>>>while i<=something loop
>>> dosomething
>>> i:=i+1;
>>> exit when i=something+1;
>>>end loop;
>>>
>>>is it possible to use the values of i in another process which calls

>
> this
>
>>>subroutine while i is changing.
>>>i.e. use the value of i to strobe the address of ram.
>>>
>>>When i simulate i just get the final value of i. NOT USEFULL.
>>>
>>>
>>>

>>

>
>


--

Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On



All times are GMT +1. The time now is 06:52 PM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved