
ReCORDIC is a compact, iterative hardware accelerator for vector rotation and vectoring calculations. It uses shift, add and subtract operations to perform calculations that would otherwise require trigonometric functions, square roots or general-purpose multiplication.
The design supports two operating modes:
MODE = 0): Rotates an input vector ((x,y)) by an angle (\theta), producing the rotated coordinates.MODE = 1): Calculates the magnitude and phase of an input vector. The magnitude is returned in x, the residual vertical component in y should approach zero, and the phase is returned in z.The accelerator reuses a shared arithmetic datapath and executes one CORDIC iteration per clock cycle. The number of iterations is configurable from 5 to 12, allowing a trade-off between numerical accuracy and execution time. Optional gain compensation uses five shift-add steps to correct the scale factor introduced by the CORDIC algorithm.
The controller includes a pre-rotation step to support angles outside the basic CORDIC convergence range. A BUSY output indicates that a calculation is in progress, and DONE indicates that the result is available.
The input and output words are 16-bit values.
NSEL = ui_in[7:5]. The number of iterations is (N = 5 + NSEL), giving 5–12 iterations.GAIN_COMP = ui_in[4]. Set it to 1 to request gain compensation or 0 to leave the CORDIC gain in the result.Without gain compensation, the X and Y coordinates are scaled by the CORDIC gain. With compensation enabled, the output should more closely match the expected mathematical result.
The design uses the eight ui input pins and eight uo output pins.
| Pin | Signal | Function |
|---|---|---|
ui[0] |
SDI | Serial data input |
ui[1] |
SH_EN | Enables serial shifting while high |
ui[2] |
START | Rising edge starts a calculation |
ui[3] |
MODE | 0 = rotation, 1 = vectoring |
ui[4] |
GAIN_COMP | Enables gain compensation |
ui[7:5] |
NSEL | Selects 5–12 iterations |
uo[1] |
BUSY | High while the controller is processing |
uo[2] |
DONE | High when the result is available |
uo[7:4] |
Iteration counter | Debug indication of the current iteration |
The intended serial transfer uses a 48-bit chain containing X, Y and Z.
Load: Shift 48 bits into the chain, most-significant bit first, in the order X[15:0], Y[15:0], Z[15:0]. Hold SH_EN high during the transfer.
Start: Set MODE, GAIN_COMP and NSEL, then generate a rising edge on START. The controller latches these settings when the operation begins. Do not issue another start while BUSY is high.
Wait: Monitor BUSY until it returns low. The result is then intended to be available, and DONE indicates completion.
Read: The intended interface shifts the 48-bit result out most-significant bit first in the order X, Y and Z. New input data can be shifted in during the same 48-clock transfer.
The serial output and result readback logic must be implemented and verified in the RTL before this protocol can be used on hardware.
rst_n low to reset the controller.rst_n high.START and wait for BUSY to return low.The simulation uses an input vector of ((1,0)) and a rotation angle of approximately (30^\circ). Gain compensation is enabled and 12 iterations are selected.
Input values
The expected result is:
[ x'=1\cos(30^\circ)\approx0.866025 ]
[ y'=1\sin(30^\circ)=0.500000 ]
Simulation output
| Quantity | Expected | Simulated |
|---|---|---|
| X | 0.866025 | 0.865723 |
| Y | 0.500000 | 0.500000 |
| Residual angle Z | Approximately 0° | −0.010986° |
The simulated coordinates are close to the expected values. The small differences are consistent with fixed-point quantization and finite iteration accuracy.
No external hardware is required for RTL simulation. The design uses the Tiny Tapeout digital input, output and clock/reset interfaces.
For physical testing, a compatible Tiny Tapeout carrier board and a means of driving the digital inputs and observing the outputs may be used. No PMOD, LED display, sensor or other external peripheral is required by the design itself.
| # | Input | Output | Bidirectional |
|---|---|---|---|
| 0 | SDI / DSP_IN0 | SDO / DSP_OUT0 | SEL (0 = CORDIC, 1 = DSP) |
| 1 | SH_EN / DSP_IN1 | BUSY / DSP_OUT1 | |
| 2 | START / DSP_IN2 | DONE / DSP_OUT2 | |
| 3 | MODE / DSP_IN3 | 0 / DSP_OUT3 | |
| 4 | GAIN_COMP / DSP_IN4 | ITER0 / DSP_OUT4 | |
| 5 | NSEL0 / DSP_IN5 | ITER1 / DSP_OUT5 | |
| 6 | NSEL1 / DSP_IN6 | ITER2 / DSP_OUT6 | |
| 7 | NSEL2 / DSP_IN7 | ITER3 / DSP_OUT7 |