Main Content

Fixed-Point Math Operations in MATLAB and Simulink

R2026b
CORDIC-based and other embedded-optimized math operations for efficient C/C++ and HDL code

The Fixed-Point Designer™ library of blocks provide hardware-efficient implementations of common math and matrix operations using algorithms such as CORDIC. Generate HDL code for designs that incorporate these blocks using HDL Coder™. The Fixed-Point Designer library of functions include CORDIC-based and other hardware-efficient implementations of math operations such as division, exponential operations, and trigonometric functions. Use coder to generate C/C++ code for designs that incorporate these functions.

CORDIC (COordinate Rotation DIgital Computer) based algorithms are some of the most hardware efficient algorithms because they require only iterative shift-add operations. The CORDIC algorithm eliminates the need for explicit multipliers, and is suitable for calculating a variety of functions.

For CORDIC-based implementations of matrix operations, including linear system solvers and matrix decompositions in MATLAB® and Simulink®, see Fixed-Point Matrix Operations in MATLAB and Fixed-Point Matrix Operations in Simulink.

Functions

expand all

cordicsigmoidCORDIC-based approximation of sigmoid activation (Since R2023b)
ceilDivRound the result of division toward positive infinity
fixDivRound the result of division toward zero
floorDivRound the result of division toward negative infinity
nearestDivRound the result of division toward the nearest integer
modByConstantModulus after division by a constant denominator
embblk.divide.cordicDivideCORDIC-based fixed-point divide with bit-exact results to Real Divide HDL Optimized and Complex Divide HDL Optimized blocks (Since R2026a)
fixed.cordicDivideCORDIC-based fixed-point divide
fixed.cordicReciprocalCORDIC-based fixed-point reciprocal
embblk.lookupTableReciprocalLookup table-based fixed-point reciprocal (Since R2026b)
embblk.realReciprocalSqrtCompute reciprocal of square root of real input (Since R2026b)
cordicsqrtCORDIC-based approximation of square root
cordicabsCORDIC-based absolute value
cordicangleCORDIC-based phase angle
cordiccexpCORDIC-based approximation of complex exponential
cordicacosCORDIC-based approximation of inverse cosine
cordicasinCORDIC-based approximation of inverse sine
cordicatan2CORDIC-based four quadrant inverse tangent
cordiccosCORDIC-based approximation of cosine
cordicsinCORDIC-based approximation of sine
cordicsincosCORDIC-based approximation of sine and cosine
cordicsinhcoshCORDIC-based approximation of hyperbolic sine and cosine (Since R2023b)
cordictanhCORDIC-based hyperbolic tangent
cordiccart2polCORDIC-based transformation of Cartesian coordinates to polar
cordicpol2cartCORDIC-based approximation of polar-to-Cartesian conversion
cordicrotateCORDIC-based approximation of rotation of input

Blocks

expand all

CORDIC Sigmoid HDL Optimized blockCORDIC Sigmoid HDL OptimizedCompute CORDIC-based sigmoid activation and generate optimized HDL code (Since R2024a)
Complex Divide HDL Optimized blockComplex Divide HDL OptimizedDivide one input by another using CORDIC algorithm and generate optimized HDL code
Real Divide HDL Optimized blockReal Divide HDL OptimizedDivide one real input by another using CORDIC algorithm and generate optimized HDL code
Divide by Constant HDL Optimized blockDivide by Constant HDL OptimizedDivide input by a constant and round to integer and generate optimized HDL code
Divide by Constant and Round blockDivide by Constant and RoundDivide input by a constant and round to integer
Modulo by Constant HDL Optimized blockModulo by Constant HDL OptimizedPerform mod operation with a constant denominator and generate optimized HDL code
Modulo by Constant blockModulo by ConstantPerform modulo operation with a constant denominator
Normalized Reciprocal HDL Optimized blockNormalized Reciprocal HDL OptimizedComputes normalized reciprocal using CORDIC algorithm and generates optimized HDL code
Real Reciprocal HDL Optimized blockReal Reciprocal HDL OptimizedCompute reciprocal and generate optimized HDL code
Real Reciprocal Square Root HDL Optimized blockReal Reciprocal Square Root HDL OptimizedCompute reciprocal of square root of real input and generate optimized HDL code (Since R2026b)
CORDIC Square Root HDL Optimized blockCORDIC Square Root HDL OptimizedCORDIC-based approximation of square root (Since R2024a)
Complex to Magnitude-Angle blockComplex to Magnitude-AngleCompute magnitude and phase angle of complex signal using CORDIC algorithm
Magnitude-Angle to Complex blockMagnitude-Angle to ComplexConvert magnitude and/or a phase angle signal to complex signal
Exp HDL Optimized blockExp HDL OptimizedCompute base-e exponential of input (Since R2026b)
Log10 HDL Optimized blockLog10 HDL OptimizedCompute base-10 logarithm of input (Since R2026b)
Log2 HDL Optimized blockLog2 HDL OptimizedCompute base-2 logarithm of input (Since R2026b)
Logarithm HDL Optimized blockLogarithm HDL OptimizedCompute arbitrary-base logarithm of input (Since R2026b)
Natural Logarithm HDL Optimized blockNatural Logarithm HDL OptimizedCompute natural (base-e) logarithm of input (Since R2026b)
Pow10 HDL Optimized blockPow10 HDL OptimizedCompute base-10 exponential of input (Since R2026b)
Pow2 HDL Optimized blockPow2 HDL OptimizedCompute base-2 exponential of input (Since R2026b)
Power HDL Optimized blockPower HDL OptimizedCompute arbitrary-base exponential of input (Since R2026b)
Hyperbolic Tangent HDL Optimized blockHyperbolic Tangent HDL OptimizedComputes CORDIC-based hyperbolic tangent and generates optimized HDL code
Trigonometric Function blockTrigonometric FunctionSpecified trigonometric function on input
Screenshot of Euler to NED Transformation HDL Optimized blockEuler to NED Transformation HDL OptimizedComputes Euler to North-East-Down transformation using pipelined or burst architecture and generates optimized HDL code (Since R2022b)
Extract MSB block with one input and one output port.Extract MSBExtract most significant bit (MSB) of input (Since R2026b)

Topics

Featured Examples