mohsen p
Newbie level 1
- Joined
- Apr 17, 2010
- Messages
- 1
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,288
I have to multiply two fractional numbers of 42 bits in verilog. I am using the fixed point (Q12.30). Now my result is wrong.
part of my code:
for example if in1=-2 & in2=-1.89652 then out=3.79304 , but my result is -15956.351736 !!!
in modelsim:
-2 is 42'b111111111110_000000000000000000000000000000
-1.89652 is 42'b111111111110_00011010011111011010111100000
-15956.351736 is 111111111100000110101011_101001011111010010100010000000000000000000000000000000000000 (WRONG)
plz tell me how multiply two fractional numbers.
thanks.
part of my code:
Code:
module my_name (out,Clk);
input Clk;
output reg signed [83:0] out; //(Q24.60)
reg signed [41:0] in1; //(Q12.30)
reg signed [41:0] in2; //(Q12.30)
always @(posedge Clk)
out <= in1 * in2;
endmodule
for example if in1=-2 & in2=-1.89652 then out=3.79304 , but my result is -15956.351736 !!!
in modelsim:
-2 is 42'b111111111110_000000000000000000000000000000
-1.89652 is 42'b111111111110_00011010011111011010111100000
-15956.351736 is 111111111100000110101011_101001011111010010100010000000000000000000000000000000000000 (WRONG)
plz tell me how multiply two fractional numbers.
thanks.