bcm-v4 [Specification]

## PHY Cordic (int theta, struct cint32 *val)

Note: struct cint32 {int q; int i;};

This routine does most of its calculations in a pseudo-floating point. The binary point is in the middle of a 32-bit word, which explains the shifts below. Both arguments are in this form.

1. Create an arctangent table with the following elements:
• 2949120, 1740967, 919879, 466945, 234379, 117304, 58666, 29335, 14668, 7334, 3667, 1833, 917, 458, 229, 115, 57, 29
2. Set signx to 1
3. Set the imaginary part of val to 39797
4. Set the real part of val to 0
5. Set the angle to 0
6. While theta > (180 << 16)

1. Subtract 360 << 16 from theta

7. While -theta > (180 << 16)

1. Add 360 << 16 to theta

8. If theta > (90 << 16)

1. Subtract (180 << 16) from theta

2. Set signx to -1
9. If -theta > (90 << 16)

1. Add 180 << 16 to theta

1. Set signx to -1
10. Loop from 0 to 17 (inclusive)
1. If theta greater than the angle
1. Save the imaginary part of val minus the real part right shifted by the loop index
2. Add the imaginary part of val right shifted by the loop index to the real part of val
3. Replace the imaginary part of val with the temporary from above
4. Add the value from the arctangent table indexed by the loop variable to the angle
2. Otherwise
1. Save the imaginary part of val plus the real part right shifted by the loop index
2. Subtract the imaginary part of val right shifted by the loop index from the real part of val
3. Replace the imaginary part of val with the temporary from above
4. Subtract the value from the arctangent table indexed by the loop variable from the angle
11. Multiply the real and imaginary parts of val by signx

Exported/Archived from the wiki to HTML on 2016-10-27