Trigonometry / CORDIC
Utilities for computing trigonometric functions in hardware.
- class tiliqua.cordic.RectToPolarCordic(*args, src_loc_at=0, **kwargs)
Iteratively compute magnitude and phase of complex numbers.
This core uses a CORDIC (Coordinate Rotation Digital Computer) approach to convert rectangular to polar complex numbers using only shifts and adds.
This is useful for extracting power spectra from frequency-domain blocks.
Given a complex number in rectangular coordinates, this core emits:
o.payload.magnitude = S*sqrt(i.payload.real**2 + i.payload.imag**2) o.payload.phase = atan2(i.payload.imag, i.payload.real) / pi S: =1 if 'magnitude_correction' is True, and =K (CORDIC gain) otherwise
- Members:
i (
In(stream.Signature(Block(CQ(shape))))
) – Stream of incoming complex numbers in rectangular coordinates.o (
Out(stream.Signature(Block(Polar(self.internal_shape))))
) – Stream of outgoing complex numbers in polar coordinates.
- K = 1.646760258121
CORDIC gain constant.
- __init__(shape, iterations=None, magnitude_correction=True)
- shapeShape
Shape of fixed-point number to use for incoming
CQ
stream.- iterationsint
Number of iterations of computation. Higher is better accuracy, but requires more clock cycles. This defaults to the number of bits in the provided
shape
.- magnitude_correctionbool
Whether to consume an additional multiplier to correct for the CORDIC gain constant. For some applications, this is not needed and can be used to save a multiplier.