
M0A21/M0A23 Series
May 06, 2022
Page
676
of 746
Rev 1.02
M0
A21
/M
0
A
2
3
SE
RIES
TEC
H
NICAL
RE
FEREN
C
E
M
ANUAL
6.18 Hardware Divider (HDIV)
6.18.1 Overview
The hardware divider (HDIV) is useful to the high performance application. The hardware divider is a
signed, integer divider with both quotient and remainder outputs.
6.18.2 Features
Signed (two’s complement) integer calculation
32-bit dividend with 16-bit divisor calculation capacity
32-bit quotient and 32-bit remainder outputs (16-bit remainder with sign extends to 32-bit)
Divided by zero warning flag
Write divisor to trigger calculation
6.18.3 Basic Configuration
Before using the hardware divider, the clock of hardware divider must be enabled. To enable hardware
divider, it needs to set HDIV_EN on AHBCLK[4] to 1.
6.18.4 Functional Description
To use hardware divider, it needs to set dividend first. Then set divisor and the hardware divider will
trigger calculation automatically after divisor written. The calculation results including the quotient and
remainder could be obtained by reading DIVQUO and DIVREM register. User can read quotient and
remainder after one cycle of writing the divisor.
DIV0 flag of DIVSTS will be set if divisor is 0.
The dividend is 32-bit signed integer and divisor is 16-bit signed integer. The quotient is 32-bit signed
integer and the remainder is 16-bit signed integer.
Figure 6.18-1 shows the operation flow of hardware divider. To calculation X / Y, CPU needs to write X
to DIVIDEND register, and then write Y to DIVISOR. CPU can read DIVQUO and DIVREM registers to
get calculation results after DIVISOR been written.
Write X
Write Y
Read Quotient
Read Remainder
X
Y
DIVREM = X mod Y
DIVQUO = X / Y
Hardwar
Divider
CPU
DIVIDEND
DIVISOR
...
...
Calculate when DIVISOR written
CPU can read results without
waiting for ready
Figure 6.18-1 Hardware Divider Operation Flow