Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

Fixed point multiplication in Verilog

Status
Not open for further replies.

krishvamsi

Junior Member level 2
Joined
Aug 21, 2018
Messages
24
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
160
i have two 8 bit signed numbers which i'd represented in fixed-point . one is -3.15 = 1100.1110 , other number is 5.1 = 0101.0010 . now i want to obtain the product of these two numbers in verilog. Manually i got the product as 0100000111111100 which is not equal to -16.065. how should i make it equal to manual result ?
 

What's the intended result format? You are apparently using signed 4.4 format, the "manual multiply" result isn't correct for signed multiply.
 

the intended result should be in 16 bit signed fixed-point format which should be equivalent to that actual product i.e -16.065
 

I see -50*82=-4100

Shift 8 for the 4+4 fractional bits:

-4100/2^8 = 16.0156

Looks correct with a little rounding error
 

16 bit what? 8.8?

I get 11101111 11111100 in signed multiply.

yes exactly . can u tell me the logic u used ? i'll be using it in verilog

- - - Updated - - -

I see -50*82=-4100

Shift 8 for the 4+4 fractional bits:

-4100/2^8 = 16.0156

Looks correct with a little rounding error

can u please elaborate this ? i have 5.1 and -3.15 . from where u got -50 and 82 ?
 

From the binary values in your own post

11001110 is -50
01010010 is 82

That's what the values are to the verilog code (if declared as signed).

wire signed [7:0] a = 8'b11001110;
wire signed [7:0] b = 8'b01010010;

wire signed [15:0] c = a*b;

C is 11101111 11111100 or -4100 in signed decimal
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top