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

a verilog syntax help

Status
Not open for further replies.

noura7

Member level 3
Joined
Apr 19, 2010
Messages
54
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
tunisia
Activity points
1,602
Can any one please help me the meaning of the following verilog code:

assign sum5=D2 + {D2[23],D2[23:1]};
assign sum6={D1[22:0],D1[0]} + {D3[23],D3[23:1]} +sum5;
assign sum7=sum6[23:19] + 1'b1;


tkx a lot
Noura
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
47,928
Helped
14,143
Reputation
28,545
Reaction score
12,827
Trophy points
1,393
Location
Bochum, Germany
Activity points
278,099
First question, do you know the meaning of the concatenation operator {x,y,z} in Verilog? It's simply assembling single bits or bit vectors to a result bit vector.

sum5 is adding the original D2 vector and a right shifted D2 value. The right shift is performed by omitting one LSB and adding the MSB for sign extension. Assuming D2 is a signed entity, you get sum5 = 1.5*D2.

sum6 is applying further calculations, tyr to figure it out.
 

noura7

Member level 3
Joined
Apr 19, 2010
Messages
54
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
tunisia
Activity points
1,602
thank you FvM for your response. Really i don't understand how can u get sum5=1.5*D2. Can you please give me further détails with examples

Thks a lot
Noura
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
47,928
Helped
14,143
Reputation
28,545
Reaction score
12,827
Trophy points
1,393
Location
Bochum, Germany
Activity points
278,099
You should take a closer look at {D2[23],D2[23:1]}. The operation is called arithmetic shift right. The bitvector is shifted right by omitting the least significant bit D2[0]. Arithmetic shift means, that the sign bit (most significant bit D2[23]) is duplicated. Examples for 4 bit signed numbers:

+4 ('0100') -> +2 ('0010')
-6 ('1010') -> -3 ('1101')

Summing D2 and 0.5*D2 results in 1.5*D2
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top