biased rounding un-biased rounding:

1. 正數的時候 行為一樣 1-4 round down, 5-9 round up
>> HW上是看到1就進位
ex. S0.8 ([8:0]) roundS0.3
[4]1: [8:5]+1
[4]0: [8:5]
2. 負數的時候
biased rounding和正數一樣行為
ex. S0.8 ([8:0]) roundS0.3
[4]1: [8:5]+1
[4]0: [8:5]
unbiased rounding要多判斷後面的位數
ex. S0.8 ([8:0]) roundS0.3
[4]1 && [3:0]有任意1:          [8:5]+1
[4]0 || ([4]1 && [3:0]0): [8:5]

 

可以参考下面这个例子 :只有-1.5的case有差别。

 
 
 

 

S4.4

S4.0 biased

S4.0 unbiased

-1

111110000

11111

11111

-1.25

111101100

11111

11111

-1.5

111101000

11111 (-1)

11110 (-2)

-1.75

111100100

11110

11110

-2

111100000

11110

11110

 

signed numbers addition overflow process:

eg. s2.0 + s2.0 = s3.0  to avoid overflow 

   [-4]  |     1 0 0

+ [-1]  |     1 1 1

= [-5]  |   1 0 1 1   

 

 

=====================================background knowledge=======================

biased vs unbiased rounding

biased vs unbiased rounding

biased vs unbiased rounding

biased vs unbiased rounding

biased vs unbiased rounding

signed number overflow:

a[N-1:0].   only bit[N-1] and bit[N-2] both have carry, then result does NOT overflow;  otherwise, viseverse.

OF = Cn-1 xor Cn-2 

eg.1

 [+2]cplmnt = 010

 [+3]cplmnt = 011

=[-3]cplment=101   (OF=0 xor 1=1, overflow)

eg.2

  [-2] = 110

  [-3] = 101

=[+3]= 011    (OF=1 xor 0=1, overflow)

 

biased vs unbiased rounding

biased vs unbiased rounding

相关文章:

  • 2022-12-23
  • 2021-06-28
  • 2020-10-07
  • 2021-07-06
  • 2021-09-07
  • 2021-08-13
  • 2021-12-30
  • 2022-01-15
猜你喜欢
  • 2021-08-05
  • 2022-01-27
  • 2022-12-23
  • 2021-05-25
相关资源
相似解决方案