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

Reply

VHDL - vhdl wait

 
Thread Tools Search this Thread
Old 11-20-2007, 02:16 PM   #1
Default vhdl wait


Please review the snipped below.
I would expect the following scenario :
1. process p1 gets executed first. dummy is set to '0'. Then the
process is suspended until v_p1_enable is '1'
2. process p2 gets executed. After a suspension of 1us, it sets
v_p1_enable to '1'
3. process p1 comes out of suspension and resumes it tasks, setting
dummy to '1'

But simulation shows me that this is not the case... why not ?

architecture RTL of test is
shared variable v_p1_enable : std_logic := '0';
begin

p1:
process
variable dummy : std_logic;
begin
dummy := '0';
wait until v_p1_enable = '1';
dummy := '1';
end process;

p2:
process
begin
wait for 1 us;
v_p1_enable := '1';
end process;

end RTL;


Jan
  Reply With Quote
Old 11-20-2007, 02:40 PM   #2
Pieter Hulshoff
 
Posts: n/a
Default Re: vhdl wait
Jan wrote:
> Please review the snipped below.
> I would expect the following scenario :
> 1. process p1 gets executed first. dummy is set to '0'. Then the
> process is suspended until v_p1_enable is '1'
> 2. process p2 gets executed. After a suspension of 1us, it sets
> v_p1_enable to '1'
> 3. process p1 comes out of suspension and resumes it tasks, setting
> dummy to '1'
>
> But simulation shows me that this is not the case... why not ?
>
> architecture RTL of test is
> shared variable v_p1_enable : std_logic := '0';
> begin
>
> p1:
> process
> variable dummy : std_logic;
> begin
> dummy := '0';
> wait until v_p1_enable = '1';
> dummy := '1';
> end process;
>
> p2:
> process
> begin
> wait for 1 us;
> v_p1_enable := '1';
> end process;
>
> end RTL;


Because p1 will immediately continue at the top of the process again, and set
dummy back to '0', and then wait for v_p1_enable to become '1' again.

Regards,

Pieter Hulshoff


Pieter Hulshoff
  Reply With Quote
Old 11-20-2007, 02:50 PM   #3
Jan
 
Posts: n/a
Default Re: vhdl wait
Fair enough... so let's change p1 to this :

p1:
process
variable dummy : std_logic;
begin
dummy := '0';
wait until v_p1_enable = '1';
dummy := '1';
wait for 1 us;
end process

still no movement on dummy in simulation...



Jan
  Reply With Quote
Old 11-20-2007, 03:00 PM   #4
Jonathan Bromley
 
Posts: n/a
Default Re: vhdl wait
On Tue, 20 Nov 2007 06:16:13 -0800 (PST), Jan <>
wrote:

>Please review the snipped below.
>I would expect the following scenario :
>1. process p1 gets executed first. dummy is set to '0'. Then the
>process is suspended until v_p1_enable is '1'
>2. process p2 gets executed. After a suspension of 1us, it sets
>v_p1_enable to '1'
>3. process p1 comes out of suspension and resumes it tasks, setting
>dummy to '1'
>
>But simulation shows me that this is not the case... why not ?


You can't wait on a shared variable; at least, not in
isolation. You need at least one signal.

VHDL's "wait until" command creates a sensitivity list from all
SIGNALS that take part in the wait expression. You have no
signals, so the wait statement has no sensitivity list and
will never release.
--
Jonathan Bromley, Consultant

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

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK

http://www.MYCOMPANY.com

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


Jonathan Bromley
  Reply With Quote
Old 11-20-2007, 03:12 PM   #5
Jan
 
Posts: n/a
Default Re: vhdl wait
p1 is an transmitting unit.
p2 is the receiving unit.

After transmitting something (p1), something is received (p2) in
response. p1 should meanwhile wait until the reception is complete.

How can i synchronize these two processes ?


Jan
  Reply With Quote
Old 11-20-2007, 03:24 PM   #6
Jonathan Bromley
 
Posts: n/a
Default Re: vhdl wait
On Tue, 20 Nov 2007 07:12:47 -0800 (PST), Jan <>
wrote:

>p1 is an transmitting unit.
>p2 is the receiving unit.
>
>After transmitting something (p1), something is received (p2) in
>response. p1 should meanwhile wait until the reception is complete.
>
>How can i synchronize these two processes ?


Like I said: use a signal (NOT a shared variable).

Basically, in VHDL communication between processes should
be achieved with signals. They have delta-delay update
semantics, guaranteeing freedom from races.

Shared variables are great for stuff like making configuration
information available throughout a testbench, or gathering
coverage data into a single tree. They're USELESS for
communication and synchronization between processes.
--
Jonathan Bromley, Consultant

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

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK

http://www.MYCOMPANY.com

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


Jonathan Bromley
  Reply With Quote
Old 11-20-2007, 04:01 PM   #7
Brian Drummond
 
Posts: n/a
Default Re: vhdl wait
On Tue, 20 Nov 2007 06:16:13 -0800 (PST), Jan <>
wrote:

>Please review the snipped below.
>I would expect the following scenario :
>1. process p1 gets executed first. dummy is set to '0'. Then the
>process is suspended until v_p1_enable is '1'
>2. process p2 gets executed. After a suspension of 1us, it sets
>v_p1_enable to '1'
>3. process p1 comes out of suspension and resumes it tasks, setting
>dummy to '1'
>
>But simulation shows me that this is not the case... why not ?
>
>architecture RTL of test is
>shared variable v_p1_enable : std_logic := '0';
>begin
>
>p1:
>process
>variable dummy : std_logic;
>begin
> dummy := '0';
> wait until v_p1_enable = '1';


Do shared variables generate events? I didn't think they did.
In which case there's nothing to wake up this process.

I expect this would work if v_p1_enable was a signal.

- Brian




Brian Drummond
  Reply With Quote
Old 11-22-2007, 06:24 AM   #8
Thomas Stanka
 
Posts: n/a
Default Re: vhdl wait
On 20 Nov., 15:16, Jan <jan.ki...@gmail.com> wrote:
> Please review the snipped below.
> I would expect the following scenario :
> 1. process p1 gets executed first. dummy is set to '0'. Then the


There is no such thing as "process p1 gets executed first" in the
language. Your simulator may start processes in any order. It is up to
you to implement handshakes or semaphores where needed.

The real problem was already good answered by the other posters.

bye Thomas


Thomas Stanka
  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