关于固定/浮点乘法的最佳方法是什么?

时间:2015-12-17 13:12:56

标签: verilog register-transfer-level

一般来说,有两种方法,因为我知道乘法固定/浮点乘法。 我是Verilog的硬件工程师。

1.单向 Verilog - Floating points multiplication

2.另一种方式是 向左移动"<<"然后向右转#34; >>"

我认为上述方法结果都是一样的。 但我不确定,所以我在这里问我想知道哪种方式可以使用和纠正?

UPDATE1。

I think there are some way what multiplication in verilog.

1.way one。

What if I want to multipicate with 3.82 *2.581.
Then we can make integer above fractional numbers like this.
3.98*8  = 31.84.
What if we want only integer result then we could like this way to calculate .
3.98<<7 =3.98 * 2^7  = almost 509.
Then we can get 509 * 8 = 4072
Then we can 31 at 4072>>7.

2.way two。     3.98 =差不多&#39; b11_111110101 ......     在这里,我们可以选择适合计算乘法的深度。     8 =&#39; b1000     11_11111010 * 1000 =(4 int),(0 frac)*(2 int),(8 frac)     11 1111101000 = 8144 然后我们得到8144 * 2 ^ -8 = 31.8125

更新2

我对how can I apply fixed fraction to the integerVerilog - Floating points multiplication

之间的乘法感到困惑

哪一个更好?

1 个答案:

答案 0 :(得分:0)

定点运算的最佳方法是使用定期编写和调试的定点库。您正在使用Verilog,因此只需在Google中搜索“verilog定点库”即可。你会发现这个

http://opencores.org/project,verilog_fixed_point_math_library

和其他人。我不推荐这个特别的,因为我没有使用它,但是你可以看到它已被很多人使用过。