Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

what is the difference between #1 a<=b and a<=#1 b

Status
Not open for further replies.

aravind

Advanced Member level 1
Joined
Jun 29, 2004
Messages
487
Helped
45
Reputation
94
Reaction score
18
Trophy points
1,298
Location
india
Activity points
3,597
it is thumb rule u should not use a = #5 b;
u can use #5 a= b;
because it is blocking statement.
1.it blocks b value for 5 secs and give it to a
2.a=b value happen after 5 secs .

simillary for non-blocking statement its vice versa
u must follow a <= #5b
because it wont block corresponding statements
 

jarodz

Full Member level 1
Joined
Mar 12, 2005
Messages
96
Helped
16
Reputation
32
Reaction score
3
Trophy points
1,288
Location
Taiwan
Activity points
2,147
A. #5 a = b, after 5 time unit, simulator execute assign value of b to a.
B. a = #5 b, when simulator execute this statement,
keep the current value of b, and then assign this keeped value to a after 5 time unit.
It is same with "<=".



Sincerely,
Jarod
 

nand_gates

Advanced Member level 3
Joined
Jul 19, 2004
Messages
892
Helped
174
Reputation
348
Reaction score
51
Trophy points
1,308
Activity points
6,803
These are the ways one model transport delay and inertial delay in verilog simulator.
If ur are familiar with VHDL you will get it!
I am assuming timescale as 1ns
#1 a<=b // This models transport delay b will appear at 'a' after 1 ns
a<=#1 b // This models inertial delay 'a' follows 'b' after 1 ns delay in additin to this
any pulse < 1ns will get filter out at 'a'

Plaese refer the link below for VHDL!
http://www.gmvhdl.com/delay.htm
 

novise

Newbie level 6
Joined
Feb 14, 2006
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,365
when #1a<=b is used b(t) is assigned a at time t+1 ,on the other hand when a<=#1b is used b(t+1) is assigned to a at time t+1
 

rsjgs

Newbie level 5
Joined
Feb 14, 2006
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,351
the difference is that in the first case the evaluation of the RHS takes place immediately but assigment after 1 ns. In the second case evaluation itself done after 1 ns
 

darylz

Full Member level 2
Joined
Mar 24, 2005
Messages
129
Helped
5
Reputation
10
Reaction score
1
Trophy points
1,298
Activity points
1,975
that nand_gates said is extract!
 

bracketx

Newbie level 6
Joined
Jan 11, 2006
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,351
hehe,there's several explanation.
 

positive_edge

Newbie level 4
Joined
Feb 13, 2006
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,337
1)

#1 a <= b

Evaluation of the assignment is delayed by the timing control.
RHS expression evaluated.
Assignment is scheduled ie a <--- b(t + 1 )

2)a <= #1 b

RHS expression evaluated .
Assignment is delayed by the timing control and is scheduled at the end of the queue.
Flow continues on.
a<-- b at simulation time t + 1
 

AlexWan

Full Member level 5
Joined
Dec 26, 2003
Messages
304
Helped
8
Reputation
16
Reaction score
2
Trophy points
1,298
Activity points
2,692
1 #N a<=b
Adding delays to the left-hand-side (LHS) of nonblocking assignments to model combinational logic is flawed.
Code:
module adder_t2 (co, sum, a, b, ci);
   output co;
   output [3:0] sum;
   input [3:0] a, b;
   input ci;

   reg co;
   reg [3:0] sum;

   always @(a or b or ci)
       #12 {co, sum} <= a + b + ci;
endmodule
If the a input changes at time 15, then if the a, b and ci inputs all change during the next 9ns, the outputs will be updated with the latest values of a, b and ci. This modeling style permitted the ci input to propagate a value to the sum and carry outputs after only 3ns instead of the required 12ns propagation delay.

So do not place delays on the LHS of nonblocking assignments to model combinational logic. This is a bad coding style.

Any guys may get the more detail inforamtion from Clifford E. Cummings papers.[/code]
 

weng

Member level 1
Joined
Jan 13, 2006
Messages
32
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,576
Do these blocking and nonblocking assignment reflect the actual circuit?

Can anyone code an example?
 

Vonn

Full Member level 4
Joined
Oct 6, 2002
Messages
230
Helped
3
Reputation
6
Reaction score
1
Trophy points
1,298
Activity points
2,460
sure it does ... here is an example :

if you write in your process :

a = 1;
b = a;
c = b;
these are Blocking assignment a = b = c = 1 and the generated circuit will be a 3 buffers connected to each others

1 ---[buffer]--->a---[buffer]--->b---[buffer]--->c

while if you write it using non-blocking

a <= 1;
b <= a;
c <= b;

this is Nonblocking assignment that means :
a = 1
b = old value of a
c = old value of b

and the actual circuit will be f/f instead of buffers

1 ---[f/f]--->a---[f/f]--->b---[f/f]--->c
 

yuenkit

Advanced Member level 4
Joined
Jan 20, 2005
Messages
108
Helped
6
Reputation
12
Reaction score
1
Trophy points
1,298
Activity points
1,047
transportation delay and inertial delay
 

weng

Member level 1
Joined
Jan 13, 2006
Messages
32
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,576
Do these blocking and nonblocking assignment reflect the actual circuit?

Can anyone code an example?
I am sorry that I didn't make my question clear.

What I wanted to ask is whether these blocking and nonblocking assignments with delays reflect the actual circuit. How do the delays in both assignments synthesize to circuit?
 

shiv_emf

Advanced Member level 2
Joined
Aug 31, 2005
Messages
605
Helped
22
Reputation
44
Reaction score
6
Trophy points
1,298
Activity points
4,106
Vonn has given nice example !! can i use it for designing shift register ?/
 

archillios

Full Member level 1
Joined
Jun 29, 2005
Messages
97
Helped
5
Reputation
10
Reaction score
1
Trophy points
1,288
Activity points
1,910
AlexWan is right, that is a bad coding style when used in combinational logic modeling. Thanks for Alex!
see the code below:

/*
bad coding style example
*/
module adder_t2 (co, sum, a, b, ci);
output co;
output [3:0] sum;
input [3:0] a, b;
input ci;

reg co;
reg [3:0] sum;

always @(a or b or ci)
#12 {co, sum} <= a + b + ci; // bad non-block assignment delay coding style
endmodule
module tb;
reg [3:0] a, b;
reg ci;
wire [3:0] sum;
wire co;
adder_t2 dut (.co(co),.sum(sum),.a(a),.b(b),.ci(ci));
initial
begin
#0 {a,b,ci} = {4'h1,4'h1,1'h0};
#50;
#11 {a,b,ci} = {4'h2,4'h5,1'h1};
#5 {a,b,ci} = {4'he,4'h0,1'h1};
#9 {a,b,ci} = {4'h5,4'h1,1'h0};
#50;
$display("good night");
$stop;

end
endmodule
/////////////////////////////////////////
unexpected behavior will be seen.

after the a/b/ci is changed, the {co, sum} <= a + b + ci; is scheduled at 12 time unit later, before the time is come, any change of a/b/ci will effect the {co, sum}, so the delay is not #12.
 

foster_cn

Member level 4
Joined
Jan 14, 2003
Messages
73
Helped
3
Reputation
6
Reaction score
1
Trophy points
1,288
Activity points
442
does the #1 in a <= #1 b means the flipflop transition time?
 

darylz

Full Member level 2
Joined
Mar 24, 2005
Messages
129
Helped
5
Reputation
10
Reaction score
1
Trophy points
1,298
Activity points
1,975
the assignment sequence is different!
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top