A difference between VHDL sources working

T

toomuch

Guest
Hi

Can someone tell me if there is a defference between the following two VHDL
sources working:
1.
process
begin
wait until C'event and C='1';
if B='0' then
Q<=B;
else
Q<= A;
end if;
end process;

2.
process
begin
if B='0' then
wait until C'event and C='1';
Q<=B;
else
wait until C'event and C='1';
Q<=A;
end if;
end process;


Simulation of this two processes gives different results. Does anybody know
why? Is there a specification discussing those cases?

Thanks for any help
 
It's apparent from the code:
Case 1 says "wait for clock, THEN test B and act accordingly"
Case 2 says "Test B, decide how to act, THEN wait for clock"

Also, Case A is synthesisable (being a register with a 2-input mux in
front), case B is probably not synthesisable (ie there is no hardware
equivalent).

"toomuch" <toomuch@poczta.onet.pl> wrote:

:Hi
:
:Can someone tell me if there is a defference between the following two VHDL
:sources working:
:1.
:process
:begin
: wait until C'event and C='1';
: if B='0' then
: Q<=B;
: else
: Q<= A;
: end if;
:end process;
:
:2.
:process
:begin
: if B='0' then
: wait until C'event and C='1';
: Q<=B;
: else
: wait until C'event and C='1';
: Q<=A;
: end if;
:end process;
:
:
:Simulation of this two processes gives different results. Does anybody know
:why? Is there a specification discussing those cases?
:
:Thanks for any help
:
:
 
On Mon, 29 Dec 2003 21:21:55 +0100, "toomuch" <toomuch@poczta.onet.pl>
wrote:

Hi

Can someone tell me if there is a defference between the following two VHDL
sources working:
1.
process
begin
wait until C'event and C='1';
if B='0' then
Q<=B;
else
Q<= A;
end if;
end process;

2.
process
begin
if B='0' then
wait until C'event and C='1';
Q<=B;
else
wait until C'event and C='1';
Q<=A;
end if;
end process;


Simulation of this two processes gives different results.
Yes.

Does anybody know why?
Yes.

1 samples B and A just after the rising edge of C.

2 samples B and A just after the rising edge of C, but doesn't use the
value of B until after the next rising edge of C.

2 is not good coding style. Don't have more than one wait statement
in a synthesisable process.

Is there a specification discussing those cases?
Yes. Try: The VHDL LRM. Any VHDL text book. Any VHDL lecture notes.
The VHDL FAQ. Google.

Regards,
Allan.
 

Welcome to EDABoard.com

Sponsor

Back
Top