-1

一般来说,有两种方法,我知道什么是乘法定点/浮点乘法。我是像 Verilog 这样的硬件工程师。

1.Verilog的一种方式 -浮点乘法

2.另一种方法是左移“<<”然后右移“>>”

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

更新1。

I think there are some way what multiplication in verilog.

1.方式一。

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.方式二。3.98 = 几乎'b11_111110101...在这里,我们可以选择适合的深度来计算乘法。8 = 'b1000 11_11111010 * 1000 = (4 int),(0 frac) * (2 int),(8 frac) 11 1111101000 = 8144 然后我们得到 8144*2^-8 = 31.8125

更新 2

我对如何将固定分数应用于整数Verilog - 浮点乘法之间的乘法感到困惑

哪一个是更好的方法?

4

1 回答 1

0

进行定点运算的最佳方法是使用经过(希望)仔细编写和调试的定点库。您使用的是 Verilog,因此只需在 Google 中搜索“verilog 定点库”。你会发现这个

http://opencores.org/project,verilog_fixed_point_math_library

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

于 2015-12-17T13:28:14.947 回答