
32.4.1.1.3 Special case: Divide-by-Zero
For both signed and unsigned divides, if the divisor is zero, the MMDVSQ hardware
detects this condition and the CSR[DZ] indicator set. The quotient result is forced to
0x0000_0000. If the remainder is selected as the output of this calculation, it also returns
0x0000_0000. Additionally, if CSR[DZE] = 1, then an attempted read of the Result
register (RES) is error terminated to provide a simple mechanism to signal software of
the divide-by-zero condition.
Integer square root
32.4.1.2.1 Overview
The unsigned square root algorithm begins by creating a 32-bit “one-hot” bit vector
signaling the highest power of four of the contents of the Radicand register (RCND). It
then iterates through an algorithm involving magnitude comparisons of the RCND
register versus the working result plus bit vector summation, conditional decrementing of
the radicand, a 1-bit right shift of the result, and a 2-bit right shift of the one-hot bit
vector.
Processing two bits of the radicand per cycle, the result register finishes with the integer
portion of the square root calculation. The module includes early termination logic so that
the execution time is data dependent, based on the magnitude of the input radicand. See
for more execution time details. Since both algorithms share common
hardware structures, the incremental cost of the square root logic is an extremely small
delta to the basic divide hardware.
The square root algorithm was exhaustively compared (that is, all 2
32
possible input
values) against the standard GNU C library implementation, which converts the unsigned
integer input into a double-precision floating-point number, calculates the double-
precision square root and then converts it back into an unsigned integer. Each input value
calculated identical square root results.
32.4.1.2.2 Square root using Q notation
Consider the use of Q notation for square root calculations returning fractional values.
The following description is taken from
http://en.wikipedia.org/wiki/Q_(number_format)
.
32.4.1.2
Integer square root
K32 L2A Reference Manual, Rev. 2, 01/2020
862
NXP Semiconductors
Summary of Contents for K32 L2A Series
Page 2: ...K32 L2A Reference Manual Rev 2 01 2020 2 NXP Semiconductors...
Page 42: ...K32 L2A Reference Manual Rev 2 01 2020 42 NXP Semiconductors...
Page 122: ...Flash Memory Clock K32 L2A Reference Manual Rev 2 01 2020 122 NXP Semiconductors...
Page 158: ...Debug and security K32 L2A Reference Manual Rev 2 01 2020 158 NXP Semiconductors...
Page 174: ...Module Signal Description Tables K32 L2A Reference Manual Rev 2 01 2020 174 NXP Semiconductors...
Page 246: ...Application information K32 L2A Reference Manual Rev 2 01 2020 246 NXP Semiconductors...
Page 374: ...CMP Trigger Mode K32 L2A Reference Manual Rev 2 01 2020 374 NXP Semiconductors...
Page 384: ...Functional description K32 L2A Reference Manual Rev 2 01 2020 384 NXP Semiconductors...
Page 592: ...Application Information K32 L2A Reference Manual Rev 2 01 2020 592 NXP Semiconductors...
Page 656: ...Functional Description K32 L2A Reference Manual Rev 2 01 2020 656 NXP Semiconductors...
Page 664: ...Functional Description K32 L2A Reference Manual Rev 2 01 2020 664 NXP Semiconductors...
Page 744: ...Functional description K32 L2A Reference Manual Rev 2 01 2020 744 NXP Semiconductors...
Page 762: ...Functional description K32 L2A Reference Manual Rev 2 01 2020 762 NXP Semiconductors...
Page 806: ...Functional description K32 L2A Reference Manual Rev 2 01 2020 806 NXP Semiconductors...
Page 868: ...Integer square root K32 L2A Reference Manual Rev 2 01 2020 868 NXP Semiconductors...
Page 976: ...Functional description K32 L2A Reference Manual Rev 2 01 2020 976 NXP Semiconductors...
Page 1012: ...Functional description K32 L2A Reference Manual Rev 2 01 2020 1012 NXP Semiconductors...
Page 1094: ...Functional description K32 L2A Reference Manual Rev 2 01 2020 1094 NXP Semiconductors...
Page 1132: ...Functional description K32 L2A Reference Manual Rev 2 01 2020 1132 NXP Semiconductors...
Page 1182: ...Functional description K32 L2A Reference Manual Rev 2 01 2020 1182 NXP Semiconductors...
Page 1290: ...Functional description K32 L2A Reference Manual Rev 2 01 2020 1290 NXP Semiconductors...