YAC - Yet Another CORDIC Core: March 30, 2014
YAC - Yet Another CORDIC Core: March 30, 2014
2 IP-Core Description 5
2.1 Port Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Parameter Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3 Mode description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.4 Data Range and Limitations . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.4.1 Circular Vectoring Mode . . . . . . . . . . . . . . . . . . . . . . . 8
2.4.2 Circular Rotation Mode . . . . . . . . . . . . . . . . . . . . . . . 8
2.4.3 Linear Vectoring Mode . . . . . . . . . . . . . . . . . . . . . . . . 8
2.4.4 Linear Rotation Mode . . . . . . . . . . . . . . . . . . . . . . . . 8
2.4.5 Hyperbolic Vectoring Mode . . . . . . . . . . . . . . . . . . . . . 8
2.4.6 Hyperbolic Rotation Mode . . . . . . . . . . . . . . . . . . . . . . 9
2.5 Internal Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.5.1 Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.5.2 Rotation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.6 Testbench . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4 Performance 14
2
Chapter 1
1.1 History
1.3 License
Copyright (c) 2014, Christian Haettich, All rights reserved.
YAC is free software; you can redistribute it and/or modify it under the terms of the
GNU Lesser General Public License as published by the Free Software Foundation; either
3
version 3.0 of the License, or (at your option) any later version.
YAC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PAR-
TICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with
this library. If not, download it from http://www.gnu.org/licenses/lgpl
4
Chapter 2
IP-Core Description
The two files cordic iterative int.vhd and cordic iterative pkg.vhd implements an
iterative CORDIC algorithm in fixed-point format. Iterative means, that the IP-core is
started with a set of input data and after a specific amount of clock cycles, the result is
available. No parallel data can be processed. The following six modes are supported:
• trigonometric rotation
• trigonometric vectoring
• linear rotation
• linear vectoring
• hyperbolic rotation
• hyperbolic vectoring
5
Name Type Direction Size Description
clk std logic input 1 clock
rst std logic input 1 synchronous reset
en std logic input 1 clock-enable
start std logic input 1 start trigger
done std logic output 1 done indicator
mode std logic vector input 4 mode configuration
xi std logic vector input XY WIDTH X input vector
yi std logic vector input XY WIDTH Y input vector
ai std logic vector input A WIDTH + 2 angular input vector
xo std logic vector input XY WIDTH + GUARD BITS X output vector
yo std logic vector input XY WIDTH + GUARD BITS Y output vector
ao std logic vector input A WIDTH + 2 angular output vector
x_i x_o
CORDIC
y_i y_o
a_i a_o
clk
rst
6
Name type size Description
XY WIDTH natural defines the size of x and y input and output vectors
A WIDTH natural defines the size of the angular input and output vectors
GUARD BITS natural defines the number of guard bits
RM GAIN natural defines the precision of the CORDIC gain removal
The angle input ai is defined with a size of A W IDT H + 2. The value β is defined with
β = 2A W IDT H−1
−1 (2.2)
7
Setup Description
ao = atan2(y i , xi ) · β,
mode =( FLAG VEC ROT = 1, VAL MODE CIR ) p
xo = xi + yi2
2
xo = cos(ai /β) · α
mode =( FLAG VEC ROT = 0, VAL MODE CIR )
yo = sin(ai /β) · α
mode =( FLAG VEC ROT = 1, VAL MODE LIN ) ao = z + y/x
mode =( FLAG VEC ROT = 0, VAL MODE LIN ) ao = y + x · z
ao = tanh(yi /xi ) · β,
mode =( FLAG VEC ROT = 1, VAL MODE HYP ) p
xo = x2i − yi2
xo = cosh(ai /β) · α
mode =( FLAG VEC ROT = 0, VAL MODE HYP )
yo = sinh(ai /β) · α
Table 2.3: Mode description (see equation 2.1 and 2.2 for α and β)
8
2.5 Internal Operation
Five states are used do to the CORDIC algorithm. The five states are visualized in a state
diagram in Figure 2.2. After reset, the YAC goes into the ST IDLE state. Only in this
state, the start signal is accepted. After starting the YAC, the state switches from the
ST IDLE state to the ST INIT state. The init state does some initial rotations/flipping.
After initialization, the main rotation starts with the ST ROTATION state (there are a few
cases, where no further rotations are required, see next sections). Every rotation step
is done within two clock cycles: in the first cycle, the angular value is loaded from the
lookup-table and shifted. In addition, the x and y values are shifted. In the second
clock cycle, the results are added according to the CORDIC algorithm. After all required
iterations are done, the state switches to the RM GAIN state, where the CORDIC gain is
removed (depending on the mode). The last state ST DONE is only used to set the done
flag to ’1’ for one clock cycle. After this, the YAC returns to the ST IDLE state.
2.5.1 Initialization
During the initialization state ST INIT, pre-rotations are done, depending on the selected
mode.
Input Description
xi = 0, yi = 0 Fixed result: xo = 0, ao = 0, to support cartesian to polar coordinate
transformations, further processing is skipped
xi = 0, yi > 0 Fixed result: xo = yi , ao = π/2, further processing is skipped
xi = 0, yi < 0 Fixed result: xo = −yi , ao = −π/2, further processing is skipped
xi < 0, yi < 0 Pre-rotation from the third to the first quadrant, the angular register is
initialized with −π and the sign of the x and y register is flipped.
xi < 0, yi ≥ 0 Pre-rotation from the second to the fourth quadrant, the angular register
is initialized with π and the sign of the x and y register is flipped.
√
xi = +α, yi = +α Fixed result: xo = 2 · α, ao = π4 · β , further processing is skipped
√
xi = +α, yi = −α Fixed result: xo = 2 · α, ao = − π4 · β, further processing is skipped
√
xi = −α, yi = +α Fixed result: xo = 2 · α, ao = 3π 4
· β, further processing is skipped
√
xi = −α, yi = −α Fixed result: xo = 2 · α, ao = − 3π 4
· β , further processing is skipped
9
Input Description
ai < − π2 Pre-rotation from the third to the first quadrant, the sign of the x and y
register is flipped, the angular register is initialized with π
π
ai > 2
Pre-rotation from the second to the fourth quadrant, the sign of the x and
y register is flipped, the angular register is initialized with −π
Input Description
xi < 0 Pre-rotation from the left half to the right half, thus the sign of the x and
y register is flipped
2.5.2 Rotation
Hyperbolic Repetitions
The following iteration steps are repeated for convergence of the hyperbolic mode:
2.6 Testbench
A VHDL testbench (cordic iterative tb.vhd) is available which reads from an input file
data. This data is fed into the YAC. In addition, the input file must provide the output
data, which is expected from the YAC processing. The following format is used in the
testbench input-file:
The data must be in the two’s complement with a base of 10. After processing all lines,
the testbench prints some info, how much tests failed.
For generating the test-patterns, the C-model with octave is used. By running the script
cordic iterative test.m, an entry in the testbech data file is done for every cordic
calculation.
10
'1' INIT
rt=
sta
ROTATE
ues
IDLE
val
put
l in
cia
spe
for
DONE
done='1' RM_GAIN
11
Chapter 3
For using the C-model, open octave or Matlab and compile the C-Model with
mex cordic iterative.c Afterwards, the C-model can be used in Octave/Matlab with the
function call
[ x o, y o, a o, it ] = cordic iterative( x i, y i, a i, mode, XY WIDTH, ANGLE WIDTH,
GUARD BITS, RM GAIN ).
The input and output arguments reflect almost the ports and parameters of the VHDL
toplevel implementation, except that there is no done, start clk and rst port in the C-
model. In addition, the last argument provides the number of iterations, which are done.
The input arguments x i, y i, and a i can be 1xN vectors with N elements. In this
case, this three input arguments must have the same size. All output arguments will also
have the same size 1xN.
Another point is the input and output size of the angular values (ai and ao ) Because
within this YAC, β represents the angle 1, the input and output with of ai and ao is
A WIDTH+2, which allows to process angle values within −π...π
12
3.1.1 Input data width versus iterations
The number of iterations depends on the width of the input data. Input data with X
bit require X + 1 rotations [4]. This requires, that the number of iterations are adapted.
One solution might be to detect the size of the input data and use this information for
the CORDIC processing. In YAC, a different sheme was chosen: the rotations are done
until
• the angular register is 0 or doesn’t change (in case of the rotation mode)
This results in a dynamic iterations adaption, depending the the input data width.
13
Chapter 4
Performance
The performance is evaluated through the matlab script cordic iterative test.m.
14
Chapter 5
• Performance optimization
• circuit optimizations
• numerical optimizations
15
Bibliography
[1] Andraka, Ray; A survey of CORDIC algorithms for FPGA based computers
[2] Hu, Yu Hen; CORDIC-Based VLSI Architectures for Digital Signal Processing
16