blocking and non-blocking ?

M

Muthu

Guest
Hi,

I have tried the following.

I am expecting 'a', 'b' should be a Clock.

But, only 'a' is asserted high after 2ns. it is not all varying.

Can any one explain why?

---------------------------------------------------------------
`timescale 1ns /10ps

module test;
reg a,b;

initial
begin
a = 0;
b = 0;
end

always @(a)
begin
#2 a = !a;
$display($time,"Change in A");
end

always @(b)
begin
#2 b <= !b;
$display($time,"Change in B");
end


endmodule
---------------------------------------------------------------
 
On 1 Mar 2004 06:10:54 -0800, muthu_nano@yahoo.co.in (Muthu) wrote:

Hi,

I have tried the following.

I am expecting 'a', 'b' should be a Clock.

But, only 'a' is asserted high after 2ns. it is not all varying.

[...]

always @(a)
begin
#2 a = !a;
$display($time,"Change in A");
end
Your always block should have NO sensitivity list.

At the time when 'a' changes, the code inside the always block is
still executing. Then, when it reaches the @(a) event control,
'a' has already changed and so @(a) will never see a change.

With nonblocking assignment to 'b', the update of 'b' takes
place after the always block has finished and therefore is
waiting at its @(b) event control. Consequently, the
event control sees the change.

Again my question: why do you believe you need the sensitivity
lists? It is very unusual for a stimulus-generator or other
behavioural process to require a sensitivity list.

--
Jonathan Bromley, Consultant

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

Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, BH24 1AW, UK
Tel: +44 (0)1425 471223 mail:jonathan.bromley@doulos.com
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.
 

Welcome to EDABoard.com

Sponsor

Back
Top