Global Sources
EE Times-India
Stay in touch with EE Times India
 
EE Times-India > Embedded
 
 
Embedded  

Implement trigonometric functions in software with CORDIC

Posted: 23 Jul 2008     Print Version  Bookmark and Share

Keywords:CORDIC  algorithm 

The input data's are scaled down by 2 to avoid the overflow. The rotational gain K needs to be compensated at some stage (i.e. compensation can be done before or after the iteration). In order to scale down the input further, the input X is multiplied by the inverse of gain before the iteration.

In the Tasking tool chain, the parameter transforms of the first four arguments of the function will be in R12 to R16. Using C166SV2 instruction set, the micro rotations according to Equation (8) is given below as reference implementation. A fixed point number representation is used for the implementation. The registers R1, R2, R13 are assigned with X, Y, shift value respectively.

Label3:
   MOV R12,#0h
   MOV R3,R1
   MOV R5,R2
   ASHR R5,#0fh
   CMP R5,#0
   JMPA cc_NZ, Label1

; Micro rotation 1

;I=I+(Q>>K)
   MOV R7,R2
   ASHR R7,R13
   MOV MAH,R1
   CoADD R12,R7
CoSTORE R1,MAS
;Q=Q-(I_tmp>>K)
   ASHR R3,R13
   MOV MAH,R2
   CoSUB R12,R3
   CoSTORE R2,MAS
JMPA cc_NZ,Label 2

; Micro rotation 2

Label1:
;I=I-(Q>>K)
   MOV R7, R2
   ASHR R7,R13
   MOV MAH,R1
   CoSUB R12,R7
   CoSTORE R1,MAS
Q=Q+ (I_tmp>>K)
   ASHR R3, R13
   MOV MAH, R2
   CoADD R12, R3
   CoSTORE R2,MAS

Label2:
   ADD R13, #1h
   CMPD1 R6,#0h
   JMPR cc_NZ, Label3

The number of iterations is fixed to 15 and the direction of rotation is depended on Y, therefore there is no need to record the degree of rotation (i.e. the value of Z). This reduces the latency from n + 25 to n + 19 cycles, where 'n' is the number of iterations.

image name

Table 2: Output.

image name

Table 3: Cycle count.

image name

Table 4: Code size (Bytes).

Sine, cosine computation for input angle
Sine and cosine of the input angles is calculated using CORDIC. If the initial Y component of rotation transform is set to zero the rotation mode reduces to:

image name

Where, K is the CORDIC Gain. By setting initial X component to 0.60725 the rotation process produces an unscaled version of sine and cosine term. Since the rotational angle is limited to "90o and +90o additional rotation is required. This is done by exploiting the symmetry property of the sine wave.

 First Page Previous Page 1 • 2 • 3 • 4 Next Page Last Page



Comment on "Implement trigonometric functions in..."
Comments:  
*  You can enter [0] more charecters.
*Verify code:
 
 
Webinars

Seminars

Visit Asia Webinars to learn about the latest in technology and get practical design tips.

 

Go to top             Connect on Facebook      Follow us on Twitter      Follow us on Orkut

 
Back to Top