| Contents | Index |
y = cordiccos(theta, niters)
y = cordiccos(theta, niters) computes the cosine of theta using a CORDIC algorithm approximation.
CORDIC is an acronym for COordinate Rotation DIgital Computer. The Givens rotation-based CORDIC algorithm is among one of the most hardware-efficient algorithms available because it requires only iterative shift-add operations (see [1], [2]) The CORDIC algorithm eliminates the need for explicit multipliers. Using CORDIC, you can calculate various functions, such as sine, cosine, arc sine, arc cosine, arc tangent, and vector magnitude. You can also use this algorithm for divide, square root, and hyperbolic, and logarithmic functions.
Increasing the number of CORDIC iterations can produce more accurate results, but doing so also increases the expense of the computation and adds latency.
Compare the results produced by various iterations of the cordiccos algorithm to the results of the double-precision cos function:
% Create 1024 points between [0, 2*pi) stepSize = pi/512; thRadDbl = 0:stepSize:(2*pi - stepSize); thRadFxp = sfi(thRadDbl, 12); % signed, 12-bit fixed-point cosThRef = cos(double(thRadFxp)); % reference results % Use 12-bit quantized inputs and vary the number % of iterations from 2 to 10. % Compare the fixed-point CORDIC results to the % double-precision trig function results. for niters = 2:2:10 cdcCosTh = cordiccos(thRadFxp, niters); errCdcRef = cosThRef - double(cdcCosTh); figure; hold on; axis([0 2*pi -1.25 1.25]); plot(thRadFxp, cosThRef, 'b'); plot(thRadFxp, cdcCosTh, 'g'); plot(thRadFxp, errCdcRef, 'r'); ylabel('cos(\Theta)'); set(gca,'XTick',0:pi/2:2*pi); set(gca,'XTickLabel',{'0','pi/2','pi','3*pi/2','2*pi'}); set(gca,'YTick',-1:0.5:1); set(gca,'YTickLabel',{'-1.0','-0.5','0','0.5','1.0'}); ref_str = 'Reference: cos(double(\Theta))'; cdc_str = sprintf('12-bit CORDIC cosine; N = %d', niters); err_str = sprintf('Error (max = %f)', max(abs(errCdcRef))); legend(ref_str, cdc_str, err_str); end
After 10 iterations, the CORDIC algorithm has approximated the cosine of theta to within 0.005187 of the double-precision cosine result.

[1] Volder, J.E. "The CORDIC Trigonometric Computing Technique," IRE Transactions on Electronic Computers. Vol. EC-8, September 1959, pp. 330–334.
[2] Andraka, R. "A survey of CORDIC algorithm for FPGA based computers." Proceedings of the 1998 ACM/SIGDA sixth international symposium on Field programmable gate arrays. Feb. 22–24, 1998, pp. 191–200.
cordiccexp | cordicsin | cordicsincos

Learn how to apply early verification to your development process through these technical resources.
How much time do you spend on testing to ensure implementation meets system-level requirements?
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |