Main Content

embblk.divide.cordicDivide

CORDIC-based fixed-point divide with bit-exact results to Real Divide HDL Optimized and Complex Divide HDL Optimized blocks

Since R2026a

Description

y = embblk.divide.cordicDivide(num,den,OutputType) divides num by den with the output data type specified by OutputType using a CORDIC-based algorithm.

example

[y,dbz] = embblk.divide.cordicDivide(num,den,OutputType) additionally returns the Boolean division by zero flag dbz, which indicates whether den is zero.

example

[___] = embblk.divide.cordicDivide(num,den,OutputType,maximumShiftValue) performs the CORDIC-based division operation using the maximum shift value specified by maximumShiftValue.

Note

The fixed.cordicDivide function also performs CORDIC-based fixed-point division, but the output is not bit-exact with the Real Divide HDL Optimized and Complex Divide HDL Optimized blocks. The fixed.cordicDivide function uses larger data types than the embblk.Divide.cordicDivide function, which provides more accurate results but requires additional hardware resources and computation time.

example

Examples

collapse all

num = fi(1,1,16,10);
den = fi(10,1,16,10);
OutputType = numerictype(1,16,10);
y = embblk.divide.cordicDivide(num,den,OutputType)
y = 

    0.0996

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 16
        FractionLength: 10
num = fi([1 1],1,16,10);
den = fi([10 0],1,16,10);
OutputType = numerictype(1,16,10);
[y, dbz] = embblk.divide.cordicDivide(num,den,OutputType)
y = 

    0.0996   31.9990

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 16
        FractionLength: 10

dbz =

  1×2 logical array

   0   1
num = fi(1,1,16,10);
den = fi(10,1,16,10);
maximumShiftValue = 10;
OutputType = numerictype(1,16,10);
y = embblk.divide.cordicDivide(num,den,OutputType, maximumShiftValue)
y = 

    0.0996

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 16
        FractionLength: 10

Input Arguments

collapse all

Numerator, specified as a scalar, vector, matrix, or multidimensional array.

  • If num is a floating-point type, den must also be a floating-point type, and OutputType must specify a floating-point data type.

  • If num is a fixed-point type, den must also be a fixed-point type, and OutputType must specify a fixed-point data type.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi
Complex Number Support: Yes

Denominator, specified as a scalar, vector, matrix, or multidimensional array.

  • If num is a floating-point type, den must also be a floating-point type, and OutputType must specify a floating-point data type.

  • If num is a fixed-point type, den must also be a fixed-point type, and OutputType must specify a fixed-point data type.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi
Complex Number Support: Yes

Data type of the output, specified as a fi object, numerictype object, or Simulink.NumericType object.

  • If num is a floating-point type, den must also be a floating-point type, and OutputType must specify a floating-point data type.

  • If num is a built-in integer type, den must also be a built-in integer type, and OutputType must specify a built-in integer data type.

  • If num is a fixed-point type, den must also be a fixed-point type, and OutputType must specify a fixed-point data type.

Example: fi([],1,16,15)

Example: numerictype(1,16,15)

Example: fixdt(1,16,15)

Maximum shift value of linear vectoring CORDIC, specified as a positive integer-valued scalar. The default value for this parameter is wl - 1, where wl = max(num.WordLength + ~issigned(num), den.WordLength + ~issigned(den)).

Output Arguments

collapse all

Quotient, returned as a scalar, vector, matrix, or multidimensional array.

Divide by zero flag, returned as a scalar, vector, matrix, or multidimensional array. A value of 1 is returned when den is zero. A value of 0 is returned otherwise. For more information, see Division by Zero Behavior.

Tips

The behaviors of the Real Divide HDL Optimized and Complex Divide HDL Optimized blocks are equivalent to

[y,dbz] = embblk.divide.cordicDivide(num,den,OutputType,maximumShiftValue)
when the inputs num and den are real or complex values, respectively. If the input data type is fixed point with binary-point scaling, the function and blocks produce bit-exact results. If the input data type is floating point, the function and block outputs can have small numerical differences.

Algorithms

collapse all

References

[1] Volder, Jack E. “The CORDIC Trigonometric Computing Technique.” IRE Transactions on Electronic Computers EC-8, no. 3 (Sept. 1959): 330–334.

[2] Andraka, Ray. “A Survey of CORDIC Algorithm for FPGA Based Computers.” In Proceedings of the 1998 ACM/SIGDA Sixth International Symposium on Field Programmable Gate Arrays, 191–200. https://dl.acm.org/doi/10.1145/275107.275139.

[3] Walther, J.S. “A Unified Algorithm for Elementary Functions.” In Proceedings of the May 18-20, 1971 Spring Joint Computer Conference, 379–386. https://dl.acm.org/doi/10.1145/1478786.1478840.

[4] Schelin, Charles W. “Calculator Function Approximation.” The American Mathematical Monthly, no. 5 (May 1983): 317–325. https://doi.org/10.2307/2975781.

Extended Capabilities

expand all

Version History

Introduced in R2026a