
32.4.3 Software interface
The programming model of the MMDVSQ is organized to be similar to the input
arguments passed to software libraries for integer divide and square root functions.
32.4.3.1 Operation activation and result retrieval
The MMDVSQ supports 2 mechanisms for initiating a divide operation:
• The default mechanism is a "fast start" where a write to the DSOR register begins the
divide.
• Alternatively, the start mechanism can begin after a write to the CSR register with
the CSR[SRT] set.
The CSR[DFS] indicator selects the divide start mechanism.
if CSR[DFS] = 0
then a divide is initiated by a write to the DSOR register
else a divide is initiated by a write to the CSR register with CSR[SRT] = 1
A square root calculation is initiated by a write to the RCND register.
For both divide and square root calculations, the result of the operation is retrieved by
reading the RES register. A memory read of this register while the calculation is still
being performed causes the access to be stalled via the insertion of bus wait states until
the new result is loaded into the register. Note a stalled bus cycle cannot be interrupted,
so if system interrupt latency is a concern, the processor should execute a simple wait
loop, for example, polling CSR[BUSY], before reading the RES register. This code
construct is fully interruptible, so interrupt latency is minimized.
32.4.3.2 Context save and restore
Given that multiple memory-mapped register accesses are needed for each divide and
square root calculation, interrupts may occur during the required sequence of operations.
As a result, the MMDVSQ’s programming model can be saved at entry to an interrupt
service routine (ISR) and then restored when redispatching to the interrupted task.
The module’s context can be saved by reading the DEND, DSOR, CSR, and RES
registers and storing them as part of the task state. There is one special consideration for
the task state save. If the last calculation was a zero divide and the divide-by-zero enable
is set (CSR[DZE] = 1), then a read of the RES register is error terminated. To avoid a
zero-divide error termination during a context save, the following sequence can be used:
1. Read DEND, DSOR, and CSR registers and save the values as part of the task state.
Integer square root
K32 L2A Reference Manual, Rev. 2, 01/2020
866
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...