Something was breaking in this question. A code-formatted block follows a numbered list, and the code isn't <pre>
-formatted. I'm guessing that it has to do with the many <
and >
symbols involved. Workaround is to put a dummy tag between the list and code block.
example text:
A ***CORDIC division*** is implemented using ***CORDIC multiplication***, rearranging as follows:
c = a/b
a - c*b = 0
For the multiplication `z = x*y`:
> <sup>[[source]][2]</sup> ***z*** is composed of shifted versions of ***y***. The unknown value for ***z***, may be found by driving ***x*** to zero 1 bit at a time. If the *i<sup><sup> </sup>th</sup>* bit of ***x*** is nonzero, ***y**<sup><sup> </sup>i</sup>* is right shifted by *i* bits and added to the current value of ***z***. The *i<sup><sup> </sup>th</sup>* bit is then removed from ***x*** by subtracting *2<sup>-i</sup>* from ***x***. If ***x*** is negative, the *i<sup><sup> </sup>th</sup>* bit in the twos complement format would be removed by adding *2<sup>-i</sup>*. In either case, when ***x*** has been driven to zero all bits have been examined and ***z*** contains the signed product of ***x*** and ***y*** correct to *B* bits.
>This algorithm is similar to the standard shift and add multiplication algorithm except for two important features:
> 1. Arithmetic right shifts are used instead of left shifts, allowing signed numbers to be used.
> 2. Computing the product to *B* bits with the CORDIC algorithm is equivalent to rounding the result of the standard algorithm to the most significant *B* bits.
> divide_4q(x,y){
> for (i=1; i=<B; i++){
> if (x > 0)
> if (y > 0)
> x = x - y*2^(-i);
> z = z + 2^(-i);
> else
> x = x + y*2^(-i);
> z = z - 2^(-i);
> else
> if (y > 0)
> x = x + y*2^(-i);
> z = z - 2^(-i);
> else
> x = x - y*2^(-i);
> z = z + 2^(-i);
> }
> return(z)
> }
Broken result:
A CORDIC division is implemented using CORDIC multiplication, rearranging as follows:
c = a/b a - c*b = 0
For the multiplication
z = x*y
:[source] z is composed of shifted versions of y. The unknown value for z, may be found by driving x to zero 1 bit at a time. If the i th bit of x is nonzero, y i is right shifted by i bits and added to the current value of z. The i th bit is then removed from x by subtracting 2-i from x. If x is negative, the i th bit in the twos complement format would be removed by adding 2-i. In either case, when x has been driven to zero all bits have been examined and z contains the signed product of x and y correct to B bits.
This algorithm is similar to the standard shift and add multiplication algorithm except for two important features:
- Arithmetic right shifts are used instead of left shifts, allowing signed numbers to be used.
Computing the product to B bits with the CORDIC algorithm is equivalent to rounding the result of the standard algorithm to the most significant B bits.
divide_4q(x,y){ for (i=1; i= 0) if (y > 0) x = x - y*2^(-i); z = z + 2^(-i); else x = x + y*2^(-i); z = z - 2^(-i); else
if (y > 0) x = x + y*2^(-i); z = z - 2^(-i); else x = x - y*2^(-i); z = z + 2^(-i); } return(z) }
Fixed result:
(with <tyblus-unbreak-tag>
between numbered list and code block)
A CORDIC division is implemented using CORDIC multiplication, rearranging as follows:
c = a/b a - c*b = 0
For the multiplication
z = x*y
:[source] z is composed of shifted versions of y. The unknown value for z, may be found by driving x to zero 1 bit at a time. If the i th bit of x is nonzero, y i is right shifted by i bits and added to the current value of z. The i th bit is then removed from x by subtracting 2-i from x. If x is negative, the i th bit in the twos complement format would be removed by adding 2-i. In either case, when x has been driven to zero all bits have been examined and z contains the signed product of x and y correct to B bits.
This algorithm is similar to the standard shift and add multiplication algorithm except for two important features:
- Arithmetic right shifts are used instead of left shifts, allowing signed numbers to be used.
- Computing the product to B bits with the CORDIC algorithm is equivalent to rounding the result of the standard algorithm to the most significant B bits.
divide_4q(x,y){ for (i=1; i=<B; i++){ if (x > 0) if (y > 0) x = x - y*2^(-i); z = z + 2^(-i); else x = x + y*2^(-i); z = z - 2^(-i); else if (y > 0) x = x + y*2^(-i); z = z - 2^(-i); else x = x - y*2^(-i); z = z + 2^(-i); } return(z) }