← All problems

CORDIC Sin/Cos

Hard · Sequential · SystemVerilog

Compute the sine and cosine of an input angle using the iterative CORDIC (COordinate Rotation DIgital Computer) rotation-mode algorithm in signed fixed-point arithmetic.

**Angle encoding**

{angle} is a {WIDTH}-bit signed integer whose full range maps linearly to $[-\pi, \pi)$, with the most-negative value representing $-\pi$ and the most-positive value representing just below $\pi$. For {WIDTH} $= 16$: the value $0$ represents $0$ radians, $8192$ represents $\pi/2$, $-8192$ represents $-\pi/2$, and $16383$ represents just below $\pi$.

**Output encoding**

{cos_out} and {sin_out} are signed fixed-point values in Q1.(WIDTH-2) format. The integer value representing $1.0$ is $2^{(\text{WIDTH}-2)}$: for {WIDTH} $= 16$, $1.0$ corresponds to the integer value $16384$.

**CORDIC algorithm**

Open this challenge in the editor →