为什么在非还原硬件二进制划分算法中会忽略溢出?

时间:2018-08-05 03:45:47

标签: algorithm hardware division

我正在读一本有关非还原二进制除法算法的硬件友好版本的书,例如52_octal除以41_octal

Round | Action            | Divisor | Remainder(6 bits) appended Quotient(6 bits)  
------+-------------------+---------+----------------------------------------------
0     | Init Value        | 100 001 | 000 000 101 010
      | R>0, RQ << 0, Sub | 100 001 | 000 001 010 100
------+-------------------+---------+----------------------------------------------
1     | R=R-D             | 100 001 | 100 000 010 100
      | R<0, RQ << 0, Add | 100 001 | 000 000 101 000 <--- Now the remainder bits overflow!
------+-------------------+---------+----------------------------------------------
2     | R=R+D             | 100 001 | 100 001 101 000
      | R<0, RQ << 0, Add | 100 001 | 000 011 010 000 <--- Overflow again.
------+-------------------+---------+----------------------------------------------
3     | R=R+D             | 100 001 | 100 100 010 000
      | R<0, RQ << 0, Add | 100 001 | 001 000 100 000 <--- Overflow again.
------+-------------------+---------+----------------------------------------------
4     | R=R+D             | 100 001 | 101 001 100 000
      | R<0, RQ << 0, Add | 100 001 | 010 011 000 000 <--- Overflow again.
------+-------------------+---------+----------------------------------------------
5     | R=R+D             | 100 001 | 110 100 000 000
      | R<0, RQ << 0, Add | 100 001 | 101 000 000 000 <--- Overflow again.
------+-------------------+---------+----------------------------------------------
6     | R=R+D             | 100 001 | 001 001 000 000
      | R>0, RQ << 1, Sub | 100 001 | 010 010 000 001
------+-------------------+---------+----------------------------------------------
      | Shift R-part right 1 bit    | 001 001 000 001
                                    | R=11_oct | Q=1_oct
End

为什么这不会导致错误?我遵循此算法,它给出了正确的答案...

0 个答案:

没有答案