1.3.7 Divide and Square Root Accelerator (DIVAS)

The Divide and Square Root Accelerator (DIVAS) is a programmable 32-bit signed or unsigned hardware divider and a 32-bit unsigned square root hardware engine. The DIVAS takes dividend and divisor values and returns the quotient and remainder when it is used as divider. The DIVAS takes unsigned input value and returns its square root and remainder when it is used as square root function.

Using The Library

This peripheral library 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 use DIVAS in firmware: Peripheral APIs Operator overloading

Peripheral APIs

DIVAS can be accessed by application program interfaces like any other peripheral. Refer to Library Interface section for API details.

Compiler Operator Overloading

A simpler way of using DIVAS is making it invisible to the programmer. This can be achieved by replacing the back end for compiler intrinsic operators ‘/’ and ‘%’. When compiler compiles the statements containing these operators, it uses DIVAS APIs instead of library generated code automatically. Unfortunately, it is not possible for square root because square root does not have a C intrinsic operator.

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 are the prototypes for EABI division operation in GNUC tool chain:

int __aeabi_idiv(int numerator, int denominator);
unsigned __aeabi_uidiv(unsigned numerator, unsigned denominator);
uint64_t __aeabi_idivmod( int numerator, int denominator);
uint64_t uidiv_return __aeabi_uidivmod( unsigned numerator, unsigned denominator);

By using DIVAS module in the above four functions body, the user can transparently access the DIVAS module when writing normal C code. For example:

void division(int32_t b, int32_t c)
{
   int32_t a;
   a = b / c;
   return a;
}

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.

Library Interface

Divide and Square Root Accelerator peripheral library provides the following interfaces:

Functions

Name Description
DIVAS_Initialize Initializes DIVAS peripheral
DIVAS_DivSigned This function uses the DIVAS peripheral to performs a signed 32-bit division
DIVAS_DivUnsigned This function uses the DIVAS peripheral to performs a unsigned 32-bit division
DIVAS_DivmodSigned This function uses the DIVAS peripheral to performs a signed 32-bit division, and returns both the quotient and remainder as 64-bit number
DIVAS_DivmodUnsigned This function uses the DIVAS peripheral to performs a unsigned 32-bit division, and returns both the quotient and remainder as 64-bit number
DIVAS_SquareRoot This function uses the DIVAS peripheral to perform a square root operation