Continue to Site

# [SOLVED]Cordic ip in xilinx

Status
Not open for further replies.
B

#### Bta241460

##### Guest
I am using cordic ip generated in xilinx vivado for sine and cos.
It is working fine when the angle is 0-90 degree(converted to radians) . whenever the angle is greater than 90 I am getting sine value correct but cosine value is wrong
What could be the reason for this?

Angle range according to Cordic V6.0 product guide is +/- Pi (+/- 180°). Can it be that you are reading negative cos output incorrectly?

B
Points: 2
Thanks for responding,
Iam giving input(phase) as 32 bit
For example 108 degrees after conversion 1.88496 in radians.
This input radians should be in the format of MSB 3 bit integers (2QN==>1sign+2 integer) and remaining bits as fractions
1.88496 in the above format as 32'b001111000.......
Output is 64 bit which includes both sine and cosine values each 32 bit

[63:32] for sine values and the output i got is 32'b00111101.............(1QN- MSB 2 bit integer ==> 1 sign+ 1integer )
format and remaining as fractions.
And the output is correct for this sine value i.e 0.951

[31:0] for cosine values and the output i got is 32'b11101101................(1QN-MSB 2 bit integer ==>1sign+1 integer) format and remaining bits as fractions
Here the output should be -0.309
But I am getting -1.687

Here I am using leds on fpga for verifying the output, input is given directly in the port declaration.

Can anybody help me

Hi

I did not re calculate your values, but your math result of "-1.687" tells me you don't treat it right when the value is negative.

The result is a 32 bit signed integer. A standard one.
Not a "sign plus 31 bit unsigned int"

Let's go for an 8 bit example.
0 will be represented as 0b 0000 0000
1 will be represented as 0b 0000 0001
But -1 will be represented as 0b 1111 1111, (not 0b 1000 0001 as you treat it)

Define sin_i as "signed 32 bit int" // integer sine value of cordic result
Define cos_i as "signed 32 bit"
Define "cos" as "float"
And try this math:
sin = (float)sin_i / 2.0^30 // 30 is the count for fractional bits
cos = (float)cos_i / 2.0^30

(I'd define a structure of 2 x "int32" as 64 bit cordic result)

Klaus

Bta241460

B
Points: 2