This driver for Atmel® | SMART ARM®-based microcontrollers provides an interface for the configuration and management of the device's Divide and Square Root Accelerator functionality.
The following peripherals are used by this module:
The following devices can use this module:
The outline of this documentation is as follows:
There are no prerequisites for this module.
This driver provides an interface for the Divide and Square Root Accelerator on the device.
The DIVAS is a programmable 32-bit signed or unsigned hardware divider and a 32-bit unsigned square root hardware engine. When running signed division, both the input and the result will be in two's complement format. The result of signed division is that the remainder has the same sign as the dividend and the quotient is negative if the dividend and divisor have opposite signs. When the square root input register is programmed, the square root function starts and the result will be stored in the Remainder register.
There are two ways to calculate the results:
The operation is implemented automatically by EABI (Enhanced Application Binary Interface). EABI is a standard calling convention, which is defined by ARM. The four functions interface can implement division and mod operation in EABI.
The following prototypes for EABI division operation in ICCARM tool chain:
The following prototypes for EABI division operation in GNUC tool chain:
No matter what kind of tool chain, by using DIVAS module in the four functions body, the user can transparently access the DIVAS module when writing normal C code. For example:
Similarly, the user can use the "a = b % c;" symbol to implement the operation with DIVAS, and needn't to care about the internal operation process.
When the signed flag is one, both the input and the result will be in two's complement format. The result of signed division is that the remainder has the same sign as the dividend and the quotient is negative if the dividend and divisor have opposite signs.
A divide by zero will cause a fault if the DIVISOR is programmed to zero. The result is that the quotient is zero and the reminder is equal to the dividend.
When the square root input register is programmed, the square root function starts and the result will be stored in the Result and Remainder registers.
There are no special considerations for this module.
For extra information, see Extra Information for DIVAS Driver. This includes:
For a list of examples related to this driver, see Examples for DIVAS Driver.
Modules | |
Quick Start Guide(s) | |
In this section you can find a list of all Quick Start guides related to the SAM Divide and Square Root Accelerator (DIVAS) Driver. | |
Data Structures | |
struct | idiv_return |
DIVAS signed division operator result output structure. More... | |
struct | uidiv_return |
DIVAS unsigned division operator result output structure. More... | |
Functions | |
static void | divas_disable_dlz (void) |
Disables DIVAS leading zero optimization. More... | |
static void | divas_enable_dlz (void) |
Enables DIVAS leading zero optimization. More... | |
Call the DIVAS API Operation | |
In this mode, the way that directly call the DIVAS API implement division or mod operation. | |
int32_t | divas_idiv (int32_t numerator, int32_t denominator) |
Signed division operation. More... | |
uint32_t | divas_uidiv (uint32_t numerator, uint32_t denominator) |
Unsigned division operation. More... | |
int32_t | divas_idivmod (int32_t numerator, int32_t denominator) |
Signed division remainder operation. More... | |
uint32_t | divas_uidivmod (uint32_t numerator, uint32_t denominator) |
Unsigned division remainder operation. More... | |
uint32_t | divas_sqrt (uint32_t radicand) |
Square root operation. More... | |
DIVAS Overload '/' and '' Operation | |
In this mode, the user can transparently access the DIVAS module when writing normal C code. E.g. "a = b / c;" or "a = b % c;" will be translated to a subroutine call, which uses the DIVAS. | |
int32_t | __aeabi_idiv (int32_t numerator, int32_t denominator) |
Signed division operation overload. More... | |
uint32_t | __aeabi_uidiv (uint32_t numerator, uint32_t denominator) |
Unsigned division operation overload. More... | |
uint64_t | __aeabi_idivmod (int32_t numerator, int32_t denominator) |
Signed division remainder operation overload. More... | |
uint64_t | __aeabi_uidivmod (uint32_t numerator, uint32_t denominator) |
Unsigned division remainder operation overload. More... | |
int32_t __aeabi_idiv | ( | int32_t | numerator, |
int32_t | denominator | ||
) |
Signed division operation overload.
Run the signed division operation and return the results.
[in] | numerator | The dividend of the signed division operation |
[in] | denominator | The divisor of the signed division operation |
References divas_idiv().
uint64_t __aeabi_idivmod | ( | int32_t | numerator, |
int32_t | denominator | ||
) |
Signed division remainder operation overload.
Run the signed division operation and return the remainder.
[in] | numerator | The dividend of the signed division operation |
[in] | denominator | The divisor of the signed division operation |
References cpu_irq_enter_critical(), and cpu_irq_leave_critical().
uint32_t __aeabi_uidiv | ( | uint32_t | numerator, |
uint32_t | denominator | ||
) |
Unsigned division operation overload.
Run the unsigned division operation and return the results.
[in] | numerator | The dividend of the unsigned division operation |
[in] | denominator | The divisor of the unsigned division operation |
References divas_uidiv().
uint64_t __aeabi_uidivmod | ( | uint32_t | numerator, |
uint32_t | denominator | ||
) |
Unsigned division remainder operation overload.
Run the unsigned division operation and return the remainder.
[in] | numerator | The dividend of the unsigned division operation |
[in] | denominator | The divisor of the unsigned division operation |
References cpu_irq_enter_critical(), and cpu_irq_leave_critical().
|
inlinestatic |
Disables DIVAS leading zero optimization.
Disable leading zero optimization from the Divide and Square Root Accelerator module. When leading zero optimization is disable, 16-bit division completes in 8 cycles and 32-bit division completes in 16 cycles.
|
inlinestatic |
Enables DIVAS leading zero optimization.
Enable leading zero optimization from the Divide and Square Root Accelerator module. When leading zero optimization is enable, 16-bit division completes in 2-8 cycles and 32-bit division completes in 2-16 cycles.
int32_t divas_idiv | ( | int32_t | numerator, |
int32_t | denominator | ||
) |
Signed division operation.
Run the signed division operation and return the quotient.
[in] | numerator | The dividend of the signed division operation |
[in] | denominator | The divisor of the signed division operation |
References cpu_irq_enter_critical(), and cpu_irq_leave_critical().
Referenced by __aeabi_idiv(), and signed_division().
int32_t divas_idivmod | ( | int32_t | numerator, |
int32_t | denominator | ||
) |
Signed division remainder operation.
Run the signed division operation and return the remainder.
[in] | numerator | The dividend of the signed division operation |
[in] | denominator | The divisor of the signed division operation |
References cpu_irq_enter_critical(), and cpu_irq_leave_critical().
Referenced by signed_division_mod().
uint32_t divas_sqrt | ( | uint32_t | radicand | ) |
Square root operation.
Run the square root operation and return the results.
[in] | radicand | The radicand of the square root operation |
References cpu_irq_enter_critical(), and cpu_irq_leave_critical().
Referenced by squart_root().
uint32_t divas_uidiv | ( | uint32_t | numerator, |
uint32_t | denominator | ||
) |
Unsigned division operation.
Run the unsigned division operation and return the results.
[in] | numerator | The dividend of the unsigned division operation |
[in] | denominator | The divisor of the unsigned division operation |
References cpu_irq_enter_critical(), and cpu_irq_leave_critical().
Referenced by __aeabi_uidiv(), and unsigned_division().
uint32_t divas_uidivmod | ( | uint32_t | numerator, |
uint32_t | denominator | ||
) |
Unsigned division remainder operation.
Run the unsigned division operation and return the remainder.
[in] | numerator | The dividend of the unsigned division operation |
[in] | denominator | The divisor of the unsigned division operation |
References cpu_irq_enter_critical(), and cpu_irq_leave_critical().
Referenced by unsigned_division_mod().