Altera_Forum
Honored Contributor
12 years agoproblem: multiply two fractional numbers in verilog
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: 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.