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

verilog code difference

Status
Not open for further replies.

spauls

Advanced Member level 2
Joined
Dec 17, 2002
Messages
524
Helped
26
Reputation
52
Reaction score
9
Trophy points
1,298
Activity points
3,353
simple verilog code

Hi All,

i have two codes for swapping of a and b , which one should be OK .

always @ (posedge clock ) begin
a <=b ;
b <= a;
end

always @ (posedge clock) begin
a =b ;
b = a;
end

please clarify.
 

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
vhdl code for swapping register

First one is OK.

For example:
Now, a=X, b=Y. After posedge of clock, result of first one is a=Y, b=X, and result of second one is a=Y, b=Y.

You can find some papers of blocking &non-blocking assignment of Verilog to check it.
 

z81203

Full Member level 5
Joined
Aug 1, 2001
Messages
308
Helped
5
Reputation
10
Reaction score
1
Trophy points
1,298
Activity points
2,356
1 second clock verilog code

first is simultaneously, second is sequentially.
 

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
verilog code for swapping

when synthesis
first non-blocking take 2 dff shifting there outputs
more reference ADVANCE VERILOG Training by Cummuings

second blocking statement will take on (dff)register give the output as b and input as a
 

sameer_dlh25

Advanced Member level 4
Joined
Sep 21, 2005
Messages
105
Helped
15
Reputation
30
Reaction score
2
Trophy points
1,298
Location
San Jose
Activity points
1,882
verilog difference = <=

Hi Spauls,

The difference can easily be understood with philosophies of Verilog non-blocking and blocking statement.

In any always block <= is a non blocking one and all such statement will be executed simultaneously. After synthesis these will result in FF's.

whereas = is a blocking one in your case X = Y and Y = X will be executed sequentially and both X and Y will have Y finally. I think this is not what is intended !

:D
 

jjww110

Full Member level 5
Joined
Apr 19, 2005
Messages
258
Helped
8
Reputation
16
Reaction score
2
Trophy points
1,298
Location
china
Activity points
2,933
how to profile verilog code

you should understand block and non-block in verilog!!
 

phoenixfeng

Full Member level 2
Joined
Mar 27, 2004
Messages
147
Helped
15
Reputation
30
Reaction score
6
Trophy points
1,298
Activity points
770
difference assignment <= and = in verilog

I agree with sameer_dlh25 and AlexWan
 

spauls

Advanced Member level 2
Joined
Dec 17, 2002
Messages
524
Helped
26
Reputation
52
Reaction score
9
Trophy points
1,298
Activity points
3,353
can anybody suggests good book on verilog starting from scratch
 

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
HDL chip design by Doulas smith
Verilog HDL by samir palnikar
Verilog Synthesis by Baskar

this 3 books must for all Verilog beginers
 

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
The first case is ok. a is assigned to b and at the same time b is assigned to a. That means a and b could have difference values depands on the initial values.

For the second case, value of b is assigned to a and b wont change...
 

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
first one.

the second one, both a and b will have value of b.

there is a virtual-temp value for every variable, so the previous signal can be hold there until the clock edge. all assignment will take the temp value for any operation.

the temp value will get updated after clock pulse come in.
 

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
it's a simple verilog problem.
 

fangjingyao

Newbie level 3
Joined
Mar 11, 2006
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,303
Verilog Hdl Synthesis- a practical primer,by J.bhasker,is a good one book
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top