Chargement…
Chargement…
Use a signed 9-bit partial remainder A, 8-bit quotient Q, and positive 9-bit divisor M. At each step, shift A,Q left. If the previous A was nonnegative, subtract M; otherwise add M. Write 1 to Q0 when the new remainder is nonnegative, otherwise 0. After eight steps, add M once more if the remainder is negative.
When i_divisor=0 at start, do not begin the eight steps. Immediately pulse o_done, assert o_div_zero, return a zero quotient, and copy the dividend to the remainder. In other cases, o_div_zero stays low.
The testbench covers exact and inexact divisions, a dividend below the divisor, zero and 255 values, and the divide-by-zero policy.