
NUC126
Aug. 08, 2018
Page
337
of 943
Rev 1.03
NUC12
6 S
E
RI
E
S
T
E
CH
NI
CA
L R
E
F
E
RE
NCE
MA
NUA
L
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 got by reading DIVQUO and DIVREM register. If CPU reads DIVQUO or DIVREM
before hardware divider calculation finishing, CPU will be held until hardware divider finishing the
calculation. Therefore, CPU can always get valid results after trigger one hardware divider calculation
without software delay.
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. It is noted that the case of dividing the minimum
dividend by -1, the quotient is set to be the minimum negative value since overflow and the remainder
is set to 0. This is the only case the quotient is not represented in a positive number when a negative
number by a negative number.
The following figure 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.10-2 Hardware Divider Operation Flow