This user's guide describes the Math Library (MLIB) for the family of ARM Cortex
M4ARM Cortex M33ARM Cortex M33F core-based microcontrollers. This library
contains optimized functions.
1.1.2
Data types
MLIB supports several data types: (un)signed integer, fractional, and accumulator. The
integer data types are useful for general-purpose computation; they are familiar to the
MPU and MCU programmers. The fractional data types enable powerful numeric and
digital-signal-processing algorithms to be implemented. The accumulator data type is a
combination of both; that means it has the integer and fractional portions.
The following list shows the integer types defined in the libraries:
• Unsigned 16-bit integer —<0 ; 65535> with the minimum resolution of 1
• Signed 16-bit integer —<-32768 ; 32767> with the minimum resolution of 1
• Unsigned 32-bit integer —<0 ; 4294967295> with the minimum resolution of 1
• Signed 32-bit integer —<-2147483648 ; 2147483647> with the minimum resolution
of 1
The following list shows the fractional types defined in the libraries:
• Fixed-point 16-bit fractional —<-1 ; 1 - 2
• Fixed-point 32-bit fractional —<-1 ; 1 - 2
-15
> with the minimum resolution of 2
-31
> with the minimum resolution of 2
-15
-31
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors7
Introduction
The following list shows the accumulator types defined in the libraries:
• Fixed-point 16-bit accumulator —<-256.0 ; 256.0 - 2-7> with the minimum
resolution of 2
MLIB uses the types mentioned in the previous section. To enable simple usage of the
algorithms, their names use set prefixes and postfixes to distinguish the functions'
versions. See the following example:
• lss—the types of the function inputs; if all the inputs have the same type as the
output, the inputs are not marked
The input and output types are described in the following table:
Table 1-1. Input/output types
TypeOutputInput
frac16_tF16s
frac32_tF32l
acc32_tA32a
1.1.4Supported compilers
MLIB for the ARM Cortex M4ARM Cortex M33ARM Cortex M33F core is written in C
language or assembly language with C-callable interface depending on the specific
function. The library is built and tested using the following compilers:
• MCUXpresso IDE
• IAR Embedded Workbench
• Keil µVision
MLIB User's Guide, Rev. 5, 12/2020
8NXP Semiconductors
Chapter 1 Library
For the MCUXpresso IDE, the library is delivered in the mlib.a file.
For the Kinetis Design Studio, the library is delivered in the mlib.a file.
For the IAR Embedded Workbench, the library is delivered in the mlib.a file.
For the Keil µVision, the library is delivered in the mlib.lib file.
The interfaces to the algorithms included in this library are combined into a single public
interface include file, mlib.h. This is done to lower the number of files required to be
included in your application.
1.1.5
MLIB for the ARM Cortex M4ARM Cortex M33ARM Cortex M33F core is written in C
language or assembly language with C-callable interface depending on the specific
function. Some functions from this library are inline type, which are compiled together
with project using this library. The optimization level for inline function is usually
defined by the specific compiler setting. It can cause an issue especially when high
optimization level is set. Therefore the optimization level for all inline assembly written
functions is defined by compiler pragmas using macros. The configuration header file
RTCESL_cfg.h is located in: specific library folder\MLIB\Include. The optimization level
can be changed by modifying the macro value for specific compiler. In case of any
change the library functionality is not guaranteed.
Similarly as optimization level the PowerQuad DSP Coprocessor and Accelerator support
can be disable or enable if it has not been done by defined symbol RTCESL_PQ_ON or
RTCESL_PQ_OFF in project setting described in the PowerQuad DSP Coprocessor and
Accelerator support cheaper for specific compiler.
Library configuration
1.1.6
1. The equations describing the algorithms are symbolic. If there is positive 1, the
2. The library functions that round the result (the API contains Rnd) round to nearest
1.2
NXP Semiconductors9
Special issues
number is the closest number to 1 that the resolution of the used fractional type
allows. If there are maximum or minimum values mentioned, check the range
allowed by the type of the particular function version.
(half up).
Library integration into project (MCUXpresso IDE)
MLIB User's Guide, Rev. 5, 12/2020
Library integration into project (MCUXpresso IDE)
This section provides a step-by-step guide on how to quickly and easily include MLIB
into any MCUXpresso SDK example or demo application projects using MCUXpresso
IDE. This example uses the default installation path (C:\NXP\RTCESL
\CM4CM33CM33F_RTCESL_4.6_MCUX). If you have a different installation path, use
that path instead.
1.2.1PowerQuad DSP Coprocessor and Accelerator support
Some LPC platforms (LPC55S6x) contain a hardware accelerator dedicated to common
calculations in DSP applications. This section shows how to turn the PowerQuad (PQ)
support for a function on and off.
1. In the MCUXpresso SDK project name node or in the left-hand part, click Properties
or select Project > Properties from the menu. A project properties dialog appears.
2. Expand the C/C++ Build node and select Settings. See .
3. On the right-hand side, under the MCU C Compiler node, click the Preprocessor
node. See .
Figure 1-1. Defined symbols
4. In the right-hand part of the dialog, click the Add... icon located next to the Defined
symbols (-D) title.
MLIB User's Guide, Rev. 5, 12/2020
10NXP Semiconductors
5. In the dialog that appears (see ), type the following:
• RTCESL_PQ_ON—to turn the PowerQuad support on
• RTCESL_PQ_OFF—to turn the PowerQuad support off
If neither of these two defines is defined, the hardware division and square root
support is turned off by default.
Figure 1-2. Symbol definition
6. Click OK in the dialog.
7. Click OK in the main dialog.
8. Ensure the PowerQuad moduel to be clocked by calling function
RTCESL_PQ_Init(); prior to the first function using PQ module calling.
Chapter 1 Library
See the device reference manual to verify whether the device contains the PowerQuad
DSP Coprocessor and Accelerator support.
1.2.2
Library path variable
To make the library integration easier, create a variable that holds the information about
the library path.
1. Right-click the MCUXpresso SDK project name node in the left-hand part and click
Properties, or select Project > Properties from the menu. A project properties dialog
appears.
2. Expand the Resource node and click Linked Resources. See Figure 1-3.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors11
Library integration into project (MCUXpresso IDE)
Figure 1-3. Project properties
3. Click the New… button in the right-hand side.
4. In the dialog that appears (see Figure 1-4), type this variable name into the Name
box: RTCESL_LOC.
5. Select the library parent folder by clicking Folder…, or just type the following path
into the Location box: C:\NXP\RTCESL\CM4CM33CM33F_RTCESL_4.6_MCUX.
Click OK.
MLIB User's Guide, Rev. 5, 12/2020
12NXP Semiconductors
Chapter 1 Library
Figure 1-4. New variable
6. Create such variable for the environment. Expand the C/C++ Build node and click
Environment.
7. Click the Add… button in the right-hand side.
8. In the dialog that appears (see Figure 1-5), type this variable name into the Name
box: RTCESL_LOC.
9. Type the library parent folder path into the Value box: C:\NXP\RTCESL
\CM4CM33CM33F_RTCESL_4.6_MCUX.
10. Tick the Add to all configurations box to use this variable in all configurations. See
Figure 1-5.
11. Click OK.
12. In the previous dialog, click OK.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors13
Library integration into project (MCUXpresso IDE)
MLIB User's Guide, Rev. 5, 12/2020
14NXP Semiconductors
Chapter 1 Library
Figure 1-5. Environment variable
1.2.3
Library folder addition
To use the library, add it into the Project tree dialog.
1. Right-click the MCUXpresso SDK project name node in the left-hand part and click
New > Folder, or select File > New > Folder from the menu. A dialog appears.
2. Click Advanced to show the advanced options.
3. To link the library source, select the Link to alternate location (Linked Folder)
option.
4. Click Variables..., select the RTCESL_LOC variable in the dialog, click OK, and/or
type the variable name into the box. See Figure 1-6.
5. Click Finish, and the library folder is linked in the project. See Figure 1-7.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors15
Library integration into project (MCUXpresso IDE)
Figure 1-6. Folder link
Figure 1-7. Projects libraries paths
1.2.4
Library path setup
1. Right-click the MCUXpresso SDK project name node in the left-hand part and click
Properties, or select Project > Properties from the menu. The project properties
dialog appears.
2. Expand the C/C++ General node, and click Paths and Symbols.
3. In the right-hand dialog, select the Library Paths tab. See Figure 1-9.
4. Click the Add… button on the right, and a dialog appears.
5. Look for the RTCESL_LOC variable by clicking Variables…, and then finish the
path in the box by adding the following (see Figure 1-8): ${RTCESL_LOC}\MLIB.
6. Click OK, you will see the path added into the list. See Figure 1-9.
MLIB User's Guide, Rev. 5, 12/2020
16NXP Semiconductors
Figure 1-8. Library path inclusion
Chapter 1 Library
Figure 1-9. Library paths
7. After adding the library path, add the library file. Click the Libraries tab. See Figure
1-11.
8. Click the Add… button on the right, and a dialog appears.
9. Type the following into the File text box (see Figure 1-10): :mlib.a
10. Click OK, and you will see the library added in the list. See Figure 1-11.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors17
Library integration into project (MCUXpresso IDE)
Figure 1-10. Library file inclusion
Figure 1-11. Libraries
11. In the right-hand dialog, select the Includes tab, and click GNU C in the Languages
list. See Figure 1-13.
12. Click the Add… button on the right, and a dialog appears. See Figure 1-12.
13. Look for the RTCESL_LOC variable by clicking Variables…, and then finish the
path in the box to be: ${RTCESL_LOC}\MLIB\Include
14. Click OK, and you will see the path added in the list. See Figure 1-13. Click OK.
Figure 1-12. Library include path addition
MLIB User's Guide, Rev. 5, 12/2020
18NXP Semiconductors
Chapter 1 Library
Figure 1-13. Compiler setting
Type the #include syntax into the code where you want to call the library functions. In
the left-hand dialog, open the required .c file. After the file opens, include the following
line into the #include section:
#include "mlib_FP.h"
When you click the Build icon (hammer), the project is compiled without errors.
1.3
Library integration into project (Kinetis Design Studio)
This section provides a step-by-step guide on how to quickly and easily include MLIB
into an empty project or any MCUXpresso SDK example or demo application projects
using Kinetis Design Studio. This example uses the default installation path (C:\NXP
\RTCESL\CM4CM33CM33F_RTCESL_4.6_KDS). If you have a different installation
path, use that path instead. If you want to use an existing MCUXpresso SDK project (for
example the hello_world project) see Library path variable. If not, continue with the next
section.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors19
Library integration into project (Kinetis Design Studio)
1.3.1Library path variable
To make the library integration easier, create a variable that will hold the information
about the library path.
1. Right-click the MyProject01 or MCUXpresso SDK project name node in the lefthand part and click Properties, or select Project > Properties from the menu. A
project properties dialog appears.
2. Expand the Resource node and click Linked Resources. See Figure 1-14.
Figure 1-14. Project properties
3. Click the New… button in the right-hand side.
4. In the dialog that appears (see Figure 1-15), type this variable name into the Name
box: RTCESL_LOC.
5. Select the library parent folder by clicking Folder…, or just type the following path
into the Location box: C:\NXP\RTCESL\CM4CM33CM33F_RTCESL_4.6_KDS.
Click OK.
MLIB User's Guide, Rev. 5, 12/2020
20NXP Semiconductors
Chapter 1 Library
Figure 1-15. New variable
6. Create such variable for the environment. Expand the C/C++ Build node and click
Environment.
7. Click the Add… button in the right-hand side.
8. In the dialog that appears (see Figure 1-16), type this variable name into the Name
box: RTCESL_LOC.
9. Type the library parent folder path into the Value box: C:\NXP\RTCESL
\CM4CM33CM33F_RTCESL_4.6_KDS.
10. Tick the Add to all configurations box to use this variable in all configurations. See
Figure 1-16.
11. Click OK.
12. In the previous dialog, click OK.
Figure 1-16. Environment variable
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors21
Library integration into project (Kinetis Design Studio)
1.3.2Library folder addition
To use the library, add it into the Project tree dialog.
1. Right-click the MyProject01 or MCUXpresso SDK project name node in the lefthand part and click New > Folder, or select File > New > Folder from the menu. A
dialog appears.
2. Click Advanced to show the advanced options.
3. To link the library source, select the option Link to alternate location (Linked
Folder).
4. Click Variables..., select the RTCESL_LOC variable in the dialog, click OK, and/or
type the variable name into the box. See Figure 1-17.
5. Click Finish, and you will see the library folder linked in the project. See Figure
1-18.
Figure 1-17. Folder link
MLIB User's Guide, Rev. 5, 12/2020
22NXP Semiconductors
Chapter 1 Library
Figure 1-18. Projects libraries paths
1.3.3Library path setup
1. Right-click the MyProject01 or MCUXpresso SDK project name node in the lefthand part and click Properties, or select Project > Properties from the menu. A
project properties dialog appears.
2. Expand the C/C++ General node, and click Paths and Symbols.
3. In the right-hand dialog, select the Library Paths tab. See Figure 1-20.
4. Click the Add… button on the right, and a dialog appears.
5. Look for the RTCESL_LOC variable by clicking Variables…, and then finish the
path in the box by adding the following (see Figure 1-19): ${RTCESL_LOC}\MLIB.
6. Click OK, and the path will be visible in the list. See Figure 1-20.
Figure 1-19. Library path inclusion
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors23
Library integration into project (Kinetis Design Studio)
Figure 1-20. Library paths
7. After adding the library path, add the library file. Click the Libraries tab. See Figure
1-22.
8. Click the Add… button on the right, and a dialog appears.
9. Type the following into the File text box (see Figure 1-21): :mlib.a
10. Click OK, and you will see the library added in the list. See Figure 1-22.
Figure 1-21. Library file inclusion
Figure 1-22. Libraries
11. In the right-hand dialog, select the Includes tab, and click GNU C in the Languages
list. See Figure 1-24.
12. Click the Add… button on the right, and a dialog appears. See Figure 1-23.
13. Look for the RTCESL_LOC variable by clicking Variables…, and then finish the
path in the box to be: ${RTCESL_LOC}\MLIB\Include
14. Click OK, and you will see the path added in the list. See Figure 1-24. Click OK.
MLIB User's Guide, Rev. 5, 12/2020
24NXP Semiconductors
Figure 1-23. Library include path addition
Chapter 1 Library
Figure 1-24. Compiler setting
Type the #include syntax into the code. Include the library into the main.c file. In the lefthand dialog, open the Sources folder of the project, and double-click the main.c file.
After the main.c file opens up, include the following line in the #include section:
#include "mlib.h"
When you click the Build icon (hammer), the project will be compiled without errors.
1.4
Library integration into project (Keil µVision)
This section provides a step-by-step guide on how to quickly and easily include MLIB
into an empty project or any MCUXpresso SDK example or demo application projects
using Keil µVision. This example uses the default installation path (C:\NXP\RTCESL
\CM4CM33CM33F_RTCESL_4.6_KEIL). If you have a different installation path, use
that path instead. If any MCUXpresso SDK project is intended to use (for example
hello_world project) go to Linking the files into the project chapter otherwise read next
chapter.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors25
Library integration into project (Keil µVision)
1.4.1NXP pack installation for new project (without MCUXpresso
SDK)
This example uses the NXP MKV46F256xxx15LPC55s69 part, and the default
installation path (C:\NXP\RTCESL\CM4CM33CM33F_RTCESL_4.6_KEIL) is
supposed. If the compiler has never been used to create any NXP MCU-based projects
before, check whether the NXP MCU pack for the particular device is installed. Follow
these steps:
1. Launch Keil µVision.
2. In the main menu, go to Project > Manage > Pack Installer….
3. In the left-hand dialog (under the Devices tab), expand the All Devices > Freescale
(NXP) node.
4. Look for a line called "KVxx Series" and click it.
5. In the right-hand dialog (under the Packs tab), expand the Device Specific node.
6. Look for a node called "Keil::Kinetis_KVxx_DFP." If there are the Install or Update
options, click the button to install/update the package. See Figure 1-25.
7. When installed, the button has the "Up to date" title. Now close the Pack Installer.
Figure 1-25. Pack Installer
MLIB User's Guide, Rev. 5, 12/2020
26NXP Semiconductors
Chapter 1 Library
1.4.2New project (without MCUXpresso SDK)
To start working on an application, create a new project. If the project already exists and
is opened, skip to the next section. Follow these steps to create a new project:
1. Launch Keil µVision.
2. In the main menu, select Project > New µVision Project…, and the Create New
Project dialog appears.
3. Navigate to the folder where you want to create the project, for example C:
\KeilProjects\MyProject01. Type the name of the project, for example MyProject01.
Click Save. See Figure 1-26.
Figure 1-26. Create New Project dialog
4. In the next dialog, select the Software Packs in the very first box.
5. Type 'kv4' into the Search box, so that the device list is reduced to the KV4x devices.
6. Expand the KV4x node.
7. Click the MKV46F256xxx15LPC55s69 node, and then click OK. See Figure 1-27.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors27
Library integration into project (Keil µVision)
Figure 1-27. Select Device dialog
8. In the next dialog, expand the Device node, and tick the box next to the Startup node.
See Figure 1-28.
9. Expand the CMSIS node, and tick the box next to the CORE node.
Figure 1-28. Manage Run-Time Environment dialog
MLIB User's Guide, Rev. 5, 12/2020
28NXP Semiconductors
Chapter 1 Library
10. Click OK, and a new project is created. The new project is now visible in the lefthand part of Keil µVision. See Figure 1-29.
Figure 1-29. Project
11. In the main menu, go to Project > Options for Target 'Target1'…, and a dialog
appears.
12. Select the Target tab.
13. Select Not UsedUse Single Precision in the Floating Point Hardware option. See
Figure 1-29.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors29
Library integration into project (Keil µVision)
Figure 1-30. FPU
1.4.3PowerQuad DSP Coprocessor and Accelerator support
Some LPC platforms (LPC55S6x) contain a hardware accelerator dedicated to common
calculations in DSP applications. This section shows how to turn the PowerQuad (PQ)
support for a function on and off.
1. In the main menu, go to Project > Options for Target 'Target1'…, and a dialog
appears.
2. Select the C/C++ tab. See Figure 1-31.
3. In the Include Preprocessor Symbols text box, type the following:
• RTCESL_PQ_ON—to turn the hardware division and square root support on.
• RTCESL_PQ_OFF—to turn the hardware division and square root support off.
If neither of these two defines is defined, the hardware division and square root
support is turned off by default.
MLIB User's Guide, Rev. 5, 12/2020
30NXP Semiconductors
Chapter 1 Library
Figure 1-31. Preprocessor symbols
4. Click OK in the main dialog.
5. Ensure the PowerQuad moduel to be clocked by calling function
RTCESL_PQ_Init(); prior to the first function using PQ module calling.
See the device reference manual to verify whether the device contains the PowerQuad
DSP Coprocessor and Accelerator support.
1.4.4
Linking the files into the project
To include the library files in the project, create groups and add them.
1. Right-click the Target 1 node in the left-hand part of the Project tree, and select Add
Group… from the menu. A new group with the name New Group is added.
2. Click the newly created group, and press F2 to rename it to RTCESL.
3. Right-click the RTCESL node, and select Add Existing Files to Group 'RTCESL'…
from the menu.
4. Navigate into the library installation folder C:\NXP\RTCESL
\CM4CM33CM33F_RTCESL_4.6_KEIL\MLIB\Include, and select the mlib_FP.h
file. If the file does not appear, set the Files of type filter to Text file. Click Add. See
Figure 1-32.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors31
Library integration into project (Keil µVision)
Figure 1-32. Adding .h files dialog
5. Navigate to the parent folder C:\NXP\RTCESL
\CM4CM33CM33F_RTCESL_4.6_KEIL\MLIB, and select the mlib.lib file. If the
file does not appear, set the Files of type filter to Library file. Click Add. See Figure
1-33.
MLIB User's Guide, Rev. 5, 12/2020
32NXP Semiconductors
Chapter 1 Library
Figure 1-33. Adding .lib files dialog
6. Now, all necessary files are in the project tree; see Figure 1-34. Click Close.
Figure 1-34. Project workspace
1.4.5
Library path setup
The following steps show the inclusion of all dependent modules.
1. In the main menu, go to Project > Options for Target 'Target1'…, and a dialog
appears.
2. Select the C/C++ tab. See Figure 1-35.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors33
Library integration into project (Keil µVision)
3. In the Include Paths text box, type the following path (if there are more paths, they
must be separated by ';') or add it by clicking the … button next to the text box:
Type the #include syntax into the code. Include the library into a source file. In the new
project, it is necessary to create a source file:
1. Right-click the Source Group 1 node, and Add New Item to Group 'Source Group
1'… from the menu.
2.
Select the C File (.c) option, and type a name of the file into the Name box, for
example 'main.c'. See Figure 1-36.
MLIB User's Guide, Rev. 5, 12/2020
34NXP Semiconductors
Chapter 1 Library
Figure 1-36. Adding new source file dialog
3. Click Add, and a new source file is created and opened up.
4. In the opened source file, include the following line into the #include section, and
create a main function:
#include "mlib_FP.h"
int main(void)
{
while(1);
}
When you click the Build (F7) icon, the project will be compiled without errors.
1.5
Library integration into project (IAR Embedded
Workbench)
This section provides a step-by-step guide on how to quickly and easily include the
MLIB into an empty project or any MCUXpresso SDK example or demo application
projects using IAR Embedded Workbench. This example uses the default installation
path (C:\NXP\RTCESL\CM4CM33CM33F_RTCESL_4.6_IAR). If you have a different
installation path, use that path instead. If any MCUXpresso SDK project is intended to
use (for example hello_world project) go to Linking the files into the project chapter
otherwise read next chapter.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors35
Library integration into project (IAR Embedded Workbench)
1.5.1New project (without MCUXpresso SDK)
This example uses the NXP MKV46F256xxx15LPC55S69 part, and the default
installation path (C:\NXP\RTCESL\CM4CM33CM33F_RTCESL_4.6_IAR) is supposed.
To start working on an application, create a new project. If the project already exists and
is opened, skip to the next section. Perform these steps to create a new project:
1. Launch IAR Embedded Workbench.
2. In the main menu, select Project > Create New Project… so that the "Create New
Project" dialog appears. See Figure 1-37.
Figure 1-37. Create New Project dialog
3. Expand the C node in the tree, and select the "main" node. Click OK.
4. Navigate to the folder where you want to create the project, for example, C:
\IARProjects\MyProject01. Type the name of the project, for example, MyProject01.
Click Save, and a new project is created. The new project is now visible in the lefthand part of IAR Embedded Workbench. See Figure 1-38.
MLIB User's Guide, Rev. 5, 12/2020
36NXP Semiconductors
Chapter 1 Library
Figure 1-38. New project
5. In the main menu, go to Project > Options…, and a dialog appears.
6. In the Target tab, select the Device option, and click the button next to the dialog to
select the MCU. In this example, select NXP > KV4x > NXP MKV46F256xxx15.
Select None in the FPU option.> LPC55S69 > NXP LPC55S69_core0. Select
NoneVFPv5 single precision in the FPU option.The DSP instructions group is
required please check the DSP Extensions checkbox if not checked. Click OK. See
Figure 1-39.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors37
Library integration into project (IAR Embedded Workbench)
Figure 1-39. Options dialog
1.5.2
PowerQuad DSP Coprocessor and Accelerator support
Some LPC platforms (LPC55S6x) contain a hardware accelerator dedicated to common
calculations in DSP applications. Only functions runing faster through the PowerQuad
module than the core itself are supported and targeted to be calculated by the PowerQuad
module. This section shows how to turn the PowerQuad (PQ) support for a function on
and off.
MLIB User's Guide, Rev. 5, 12/2020
38NXP Semiconductors
Chapter 1 Library
1. In the main menu, go to Project > Options…, and a dialog appears.
2. In the left-hand column, select C/C++ Compiler.
3. In the right-hand part of the dialog, click the Preprocessor tab (it can be hidden in the
right-hand side; use the arrow icons for navigation).
4. In the text box (at the Defined symbols: (one per line)), type the following (See
Figure 1-40):
• RTCESL_PQ_ON—to turn the PowerQuad support on.
• RTCESL_PQ_OFF—to turn the PowerQuad support off.
If neither of these two defines is defined, the hardware division and square root
support is turned off by default.
Figure 1-40. Defined symbols
5. Click OK in the main dialog.
6. Ensure the PowerQuad moduel to be clocked by calling function
RTCESL_PQ_Init(); prior to the first function using PQ module calling.
See the device reference manual to verify whether the device contains the PowerQuad
DSP Coprocessor and Accelerator support.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors39
Library integration into project (IAR Embedded Workbench)
1.5.3Library path variable
To make the library integration easier, create a variable that will hold the information
about the library path.
1. In the main menu, go to Tools > Configure Custom Argument Variables…, and a
dialog appears.
2. Click the New Group button, and another dialog appears. In this dialog, type the
name of the group PATH, and click OK. See Figure 1-41.
Figure 1-41. New Group
3. Click on the newly created group, and click the Add Variable button. A dialog
appears.
4. Type this name: RTCESL_LOC
5. To set up the value, look for the library by clicking the '…' button, or just type the
installation path into the box: C:\NXP\RTCESL
\CM4CM33CM33F_RTCESL_4.6_IAR. Click OK.
6. In the main dialog, click OK. See Figure 1-42.
MLIB User's Guide, Rev. 5, 12/2020
40NXP Semiconductors
Chapter 1 Library
Figure 1-42. New variable
1.5.4
Linking the files into the project
To include the library files into the project, create groups and add them.
1. Go to the main menu Project > Add Group…
2. Type RTCESL, and click OK.
3. Click on the newly created node RTCESL, go to Project > Add Group…, and create
a MLIB subgroup.
4. Click on the newly created node MLIB, and go to the main menu Project > Add
Files… See Figure 1-44.
5. Navigate into the library installation folder C:\NXP\RTCESL
\CM4CM33CM33F_RTCESL_4.6_IAR\MLIB\Include, and select the mlib.h file. (If
the file does not appear, set the file-type filter to Source Files.) Click Open. See
Figure 1-43.
6. Navigate into the library installation folder C:\NXP\RTCESL
\CM4CM33CM33F_RTCESL_4.6_IAR\MLIB, and select the mlib.a file. If the file
does not appear, set the file-type filter to Library / Object files. Click Open.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors41
Library integration into project (IAR Embedded Workbench)
Figure 1-43. Add Files dialog
7. Now you will see the files added in the workspace. See Figure 1-44.
Figure 1-44. Project workspace
1.5.5
Library path setup
1. In the main menu, go to Project > Options…, and a dialog appears.
2. In the left-hand column, select C/C++ Compiler.
3. In the right-hand part of the dialog, click on the Preprocessor tab (it can be hidden in
the right; use the arrow icons for navigation).
MLIB User's Guide, Rev. 5, 12/2020
42NXP Semiconductors
Chapter 1 Library
4. In the text box (at the Additional include directories title), type the following folder
(using the created variable):
• $RTCESL_LOC$\MLIB\Include
5. Click OK in the main dialog. See Figure 1-45.
Figure 1-45. Library path adition
Type the #include syntax into the code. Include the library included into the main.c file.
In the workspace tree, double-click the main.c file. After the main.c file opens up, include
the following line into the #include section:
#include "mlib_FP.h"
When you click the Make icon, the project will be compiled without errors.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors43
Library integration into project (IAR Embedded Workbench)
MLIB User's Guide, Rev. 5, 12/2020
44NXP Semiconductors
Chapter 2
Algorithms in detail
2.1MLIB_Abs
The
MLIB_Abs functions return the absolute value of the input. The function does not
saturate the output. See the following equation:
Equation 1. Algorithm formula
2.1.1
Available versions
This function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may overflow.
The available versions of the MLIB_Abs function are shown in the following table.
Table 2-1. Function versions
Function nameInput typeResult typeDescription
MLIB_Abs_F16frac16_tfrac16_tAbsolute value of a 16-bit fractional value. The output is within the
range <-1 ; 1).
MLIB_Abs_F32frac32_tfrac32_tAbsolute value of a 32-bit fractional value. The output is within the
range <-1 ; 1).
2.1.2Declaration
The available MLIB_Abs functions have the following declarations:
The MLIB_Add functions return the sum of two addends. The function does not saturate
the output. See the following equation:
Equation 3. Algorithm formula
2.3.1
Available versions
This function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may overflow.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors47
MLIB_Add
• Accumulator output with fractional inputs - the output is the accumulator type, where
the result can be out of the range <-1 ; 1). The inputs are the fractional values only.
• Accumulator output with mixed inputs - the output is the accumulator type, where
the result can be out of the range <-1 ; 1). The inputs are the accumulator and
fractional values. The result may overflow.
The available versions of the MLIB_Add function are shown in the following table.
Table 2-3. Function versions
Function nameInput typeResult
Addend 1Addend 2
MLIB_Add_F16frac16_tfrac16_tfrac16_tAddition of two 16-bit fractional addends. The output is
MLIB_Add_F32frac32_tfrac32_tfrac32_tAddition of two 32-bit fractional addends. The output is
MLIB_Add_A32ssfrac16_tfrac16_tacc32_tAddition of two 16-bit fractional addends; the result is a 32-
MLIB_Add_A32asacc32_tfrac16_tacc32_tA 16-bit fractional addend is added to a 32-bit accumulator.
type
within the range <-1 ; 1).
within the range <-1 ; 1).
bit accumulator. The output may be out of the range <-1 ; 1).
The output may be out of the range <-1 ; 1).
Description
2.3.2Declaration
The available MLIB_Add functions have the following declarations:
The MLIB_Clb functions return the number of leading bits of the input. If the input is 0,
it returns the size of the type minus one.
2.7.1Available versions
This function is available in the following versions:
• Integer output with fractional input - the output is the unsigned integer value when
the input is fractional; the result is greater than or equal to 0.
The available versions of the MLIB_Clb function are shown in the following table.
Table 2-7. Function versions
Function nameInput typeResult typeDescription
MLIB_Clb_U16sfrac16_tuint16_tCounts the leading bits of a 16-bit fractional value. The output is within
the range <0 ; 15>.
MLIB_Clb_U16lfrac32_tuint16_tCounts the leading bits of a 32-bit fractional value. The output is within
the range <0 ; 31>.
2.7.2Declaration
The available MLIB_Clb functions have the following declarations:
MLIB_Div functions return the fractional division of the numerator and
denominator. The function does not saturate the output. See the following equation:
Equation 7. Algorithm formula
2.9.1
Available versions
This function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The function is only defined for: |nominator| < |
denominator|. The function returns undefined results out of this condition.
• Accumulator output - the output is the accumulator type, where the result may be out
of the range <-1 ; 1).
The available versions of the MLIB_Div function are shown in the following table:
Table 2-9. Function versions
Function nameInput typeResult
Num.Denom.
MLIB_Div_F16frac16_tfrac16_tfrac16_tDivision of a 16-bit fractional numerator and denominator. The
MLIB_Div_F16lsfrac32_tfrac16_tfrac16_tDivision of a 32-bit fractional numerator by a 16-bit fractional
MLIB_Div_F16llfrac32_tfrac32_tfrac16_tDivision of a 32-bit fractional numerator and denominator; the
MLIB_Div_F32lsfrac32_tfrac16_tfrac32_tDivision of a 32-bit fractional numerator by a 16-bit fractional
type
output is within the range <-1 ; 1).
denominator; the output is a 16-bit fractional result. The output is
within the range <-1 ; 1).
output is a 16-bit fractional result. The output is within the range
<-1 ; 1).
denominator; the output is a 32-bit fractional result. The output is
within the range <-1 ; 1).
Description
Table continues on the next page...
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors55
MLIB_Div
Table 2-9. Function versions (continued)
Function nameInput typeResult
Num.Denom.
MLIB_Div_F32frac32_tfrac32_tfrac32_tDivision of a 32-bit fractional numerator and denominator. The
MLIB_Div_A32ssfrac16_tfrac16_tacc32_tDivision of a 16-bit fractional numerator and denominator; the
MLIB_Div_A32lsfrac32_tfrac16_tacc32_tDivision of a 32-bit fractional numerator by a 16-bit fractional
MLIB_Div_A32llfrac32_tfrac32_tacc32_tDivision of a 32-bit fractional numerator and denominator; the
MLIB_Div_A32asacc32_tfrac16_tacc32_tDivision of a 32-bit accumulator numerator by a 16-bit fractional
type
output is within the range <-1 ; 1).
output is a 32-bit accumulator result. The output may be out of the
range <-1 ; 1).
denominator; the output is a 32-bit accumulator result. The output
may be out of the range <-1 ; 1).
output is a 32-bit accumulator result. The output may be out of the
range <-1 ; 1).
denominator; the output is a 32-bit accumulator result. The output
may be out of the range <-1 ; 1).
Description
2.9.2Declaration
The available MLIB_Div functions have the following declarations:
The MLIB_DivSat functions return the fractional division of the numerator and
denominator. The function saturates the output. See the following equation:
Equation 8. Algorithm formula
2.10.1
Available versions
This function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may saturate.
• Accumulator output - the output is the accumulator type, where the result may be out
of the range <-1 ; 1).
The available versions of the MLIB_DivSat function are shown in the following table:
Table 2-10. Function versions
Function nameInput typeResult
Num.Denom.
MLIB_DivSat_F16frac16_tfrac16_tfrac16_tDivision of a 16-bit fractional numerator and denominator. The
MLIB_DivSat_F16lsfrac32_tfrac16_tfrac16_tDivision of a 32-bit fractional numerator by a 16-bit fractional
MLIB_DivSat_F16llfrac32_tfrac32_tfrac16_tDivision of a 32-bit fractional numerator and denominator; the
MLIB_DivSat_F32lsfrac32_tfrac16_tfrac32_tDivision of a 32-bit fractional numerator by a 16-bit fractional
MLIB_DivSat_F32frac32_tfrac32_tfrac32_tDivision of a 32-bit fractional numerator and denominator. The
MLIB_DivSat_A32asacc32_tfrac16_tacc32_tDivision of a 32-bit accumulator numerator by a 16-bit fractional
type
output is within the range <-1 ; 1).
denominator; the output is a 16-bit fractional result. The output
is within the range <-1 ; 1).
output is a 16-bit fractional result. The output is within the range
<-1 ; 1).
denominator; the output is a 32-bit fractional result. The output
is within the range <-1 ; 1).
output is within the range <-1 ; 1).
denominator; the output is a 32-bit accumulator result. The
output may be out of the range <-1 ; 1).
Description
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors57
MLIB_Div1Q
2.10.2Declaration
The available MLIB_DivSat functions have the following declarations:
The MLIB_Div1Q functions return the single-quadrant fractional division of the
numerator and denominator. The numerator and denominator must be non-negative
numbers, otherwise the function returns undefined results. The function does not saturate
the output. See the following equation:
Equation 9. Algorithm formula
2.11.1
Available versions
This function is available in the following versions:
MLIB User's Guide, Rev. 5, 12/2020
58NXP Semiconductors
Chapter 2 Algorithms in detail
• Fractional output - the output is the fractional portion of the result; the result is
within the range <0 ; 1). The function is only defined for: nominator < denominator,
and both are non-negative. The function returns undefined results out of this
condition.
• Accumulator output - the output is the accumulator type, where the result is greater
than or equal to 0.
The available versions of the MLIB_Div1Q function are shown in the following table:
Table 2-11. Function versions
Function nameInput typeResult
Num.Denom.
MLIB_Div1Q_F16frac16_tfrac16_tfrac16_tDivision of a non-negative 16-bit fractional numerator and
MLIB_Div1Q_F16lsfrac32_tfrac16_tfrac16_tDivision of a non-negative 32-bit fractional numerator by a non-
MLIB_Div1Q_F16llfrac32_tfrac32_tfrac16_tDivision of a non-negative 32-bit fractional numerator and
MLIB_Div1Q_F32lsfrac32_tfrac16_tfrac32_tDivision of a non-negative 32-bit fractional numerator by a non-
MLIB_Div1Q_F32frac32_tfrac32_tfrac32_tDivision of a non-negative 32-bit fractional numerator and
MLIB_Div1Q_A32ssfrac16_tfrac16_tacc32_tDivision of a non-negative 16-bit fractional numerator and
MLIB_Div1Q_A32lsfrac32_tfrac16_tacc32_tDivision of a non-negative 32-bit fractional numerator by a non-
MLIB_Div1Q_A32llfrac32_tfrac32_tacc32_tDivision of a non-negative 32-bit fractional numerator and
MLIB_Div1Q_A32asacc32_tfrac16_tacc32_tDivision of a non-negative 32-bit accumulator numerator by a
type
denominator. The output is within the range <0 ; 1).
negative 16-bit fractional denominator; the output is a nonnegative 16-bit fractional result. The output is within the range
<0 ; 1).
denominator; the output is a non-negative 16-bit fractional
result. The output is within the range <0 ; 1).
negative 16-bit fractional denominator; the output is a nonnegative 32-bit fractional result. The output is within the range
<0 ; 1).
denominator. The output is within the range <0 ; 1).
denominator; the output is a non-negative 32-bit accumulator
result. The output is greater than or equal to 0.
negative 16-bit fractional denominator; the output is a nonnegative 32-bit accumulator result. The output is greater than or
equal to 0.
denominator; the output is a non-negative 32-bit accumulator
result. The output is greater than or equal to 0.
non-negative 16-bit fractional denominator; the output is a 32-bit
accumulator result. The output is greater than or equal to 0.
Description
2.11.2Declaration
The available MLIB_Div1Q functions have the following declarations:
The MLIB_Div1QSat functions return the fractional division of the numerator and
denominator. The numerator and denominator must be non-negative numbers. The
function saturates the output. See the following equation:
Equation 10. Algorithm formula
2.12.1
Available versions
This function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <0 ; 1). The result may saturate.
• Accumulator output - the output is the accumulator type, where the result is greater
than or equal to 0.
MLIB User's Guide, Rev. 5, 12/2020
60NXP Semiconductors
Chapter 2 Algorithms in detail
The available versions of the MLIB_Div1QSat function are shown in the following table:
Table 2-12. Function versions
Function nameInput typeResult
Num.Denom.
MLIB_Div1QSat_F16frac16_tfrac16_tfrac16_tDivision of a non-negative 16-bit fractional numerator and
MLIB_Div1QSat_F16lsfrac32_tfrac16_tfrac16_tDivision of a non-negative 32-bit fractional numerator by a
MLIB_Div1QSat_F16llfrac32_tfrac32_tfrac16_tDivision of a non-negative 32-bit fractional numerator and
MLIB_Div1QSat_F32lsfrac32_tfrac16_tfrac32_tDivision of a non-negative 32-bit fractional numerator by a
MLIB_Div1QSat_F32frac32_tfrac32_tfrac32_tDivision of a non-negative 32-bit fractional numerator and
MLIB_Div1QSat_A32asacc32_tfrac16_tacc32_tDivision of a non-negative 32-bit accumulator numerator by
type
denominator. The output is within the range <0 ; 1).
non-negative 16-bit fractional denominator; the output is a
non-negative 16-bit fractional result. The output is within the
range <0 ; 1).
denominator; the output is a non-negative 16-bit fractional
result. The output is within the range <0 ; 1).
non-negative 16-bit fractional denominator; the output is a
non-negative 32-bit fractional result. The output is within the
range <0 ; 1).
denominator. The output is within the range <0 ; 1).
a non-negative 16-bit fractional denominator; the output is a
32-bit accumulator result. The output is greater than or
equal to 0.
Description
2.12.2Declaration
The available MLIB_Div1QSat functions have the following declarations:
The MLIB_Mac functions return the sum of the input accumulator, and the fractional
product of two multiplicands. The function does not saturate the output. See the
following equation:
Equation 12. Algorithm formula
2.14.1
Available versions
This function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may overflow.
• Accumulator output with mixed inputs - the output is the accumulator type, where
the result can be out of the range <-1 ; 1). The accumulator is the accumulator type,
the multiplicands are the fractional types. The result may overflow.
The available versions of the MLIB_Mac function are shown in the following table.
Table 2-14. Function versions
Function nameInput typeResult
Accum.Mult. 1Mult. 2
MLIB_Mac_F16frac16_tfrac16_tfrac16_tfrac16_tThe upper 16-bit portion [16..31] of the fractional
MLIB_Mac_F32lssfrac32_tfrac16_tfrac16_tfrac32_tThe 32-bit fractional product (of two 16-bit fractional
MLIB_Mac_F32frac32_tfrac32_tfrac32_tfrac32_tThe upper 32-bit portion [32..63] of the fractional
type
product (of two 16-bit fractional multiplicands) is
added to a 16-bit fractional accumulator. The output
is within the range <-1 ; 1).
multiplicands) is added to a 32-bit fractional
accumulator. The output is within the range <-1 ; 1).
product (of two 32-bit fractional multiplicands) is
added to a 32-bit fractional accumulator. The output
is within the range <-1 ; 1).
Description
Table continues on the next page...
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors63
MLIB_MacSat
Table 2-14. Function versions (continued)
Function nameInput typeResult
Accum.Mult. 1Mult. 2
MLIB_Mac_A32assacc32_tfrac16_tfrac16_tacc32_tThe upper 16-bit portion [16..31] of the fractional
type
product (of two 16-bit fractional multiplicands) is
added to a 32-bit accumulator. The output may be
out of the range <-1 ; 1).
Description
2.14.2Declaration
The available MLIB_Mac functions have the following declarations:
The MLIB_MacSat functions return the sum of the input accumulator and the fractional
product of two multiplicands. The function saturates the output. See the following
equation:
MLIB User's Guide, Rev. 5, 12/2020
64NXP Semiconductors
Chapter 2 Algorithms in detail
Equation 13. Algorithm formula
2.15.1Available versions
This function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may saturate.
The available versions of the MLIB_MacSat function are shown in the following table.
Table 2-15. Function versions
Function nameInput typeResult
Accum.Mult. 1Mult. 2
MLIB_MacSat_F16frac16_tfrac16_tfrac16_tfrac16_tThe upper 16-bit portion [16..31] of the fractional
MLIB_MacSat_F32lssfrac32_tfrac16_tfrac16_tfrac32_tThe 32-bit fractional product (of two 16-bit
MLIB_MacSat_F32frac32_tfrac32_tfrac32_tfrac32_tThe upper 32-bit portion [32..63] of the fractional
type
product (of two 16-bit fractional multiplicands) is
added to a 16-bit fractional accumulator. The
output is within the range <-1 ; 1).
fractional multiplicands) is added to a 32-bit
fractional accumulator. The output is within the
range <-1 ; 1).
product (of two 32-bit fractional multiplicands) is
added to a 32-bit fractional accumulator. The
output is within the range <-1 ; 1).
Description
2.15.2Declaration
The available MLIB_MacSat functions have the following declarations:
MLIB_MacRnd functions return the sum of the input accumulator and the rounded
fractional product of two multiplicands. The round method is the round to nearest. The
function does not saturate the output. See the following equation:
Equation 14. Algorithm formula
2.16.1
Available versions
This function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may overflow.
• Accumulator output with mixed inputs - the output is the accumulator type where the
result can be out of the range <-1 ; 1). The accumulator is the accumulator type, the
multiplicands are the fractional types. The result may overflow.
The available versions of the MLIB_MacRnd function are shown in the following table.
Table 2-16. Function versions
Function nameInput typeResult
Accum.Mult. 1Mult. 2
MLIB_MacRnd_F16frac16_tfrac16_tfrac16_tfrac16_tThe fractional product (of two 16-bit fractional
type
multiplicands), rounded to the upper 16 bits, is
added to a 16-bit fractional accumulator. The
output is within the range <-1 ; 1).
Description
Table continues on the next page...
MLIB User's Guide, Rev. 5, 12/2020
66NXP Semiconductors
Table 2-16. Function versions (continued)
Chapter 2 Algorithms in detail
Function nameInput typeResult
Accum.Mult. 1Mult. 2
MLIB_MacRnd_F32llsfrac32_tfrac32_tfrac16_tfrac32_tThe fractional product (of a 32-bit and 16-bit
MLIB_MacRnd_F32frac32_tfrac32_tfrac32_tfrac32_tThe fractional product (of two 32-bit fractional
MLIB_MacRnd_A32assacc32_tfrac16_tfrac16_tacc32_tThe fractional product (of two 16-bit fractional
type
fractional multiplicand), rounded to the upper 32
bits [16..48], is added to a 32-bit fractional
accumulator. The output is within the range <-1 ;
1).
multiplicands), rounded to the upper 32 bits
[32..63], is added to a 32-bit fractional
accumulator. The output is within the range <-1 ;
1).
multiplicands), rounded to the upper 16 bits
[16..31], is added to a 32-bit accumulator. The
output may be out of the range <-1 ; 1).
Description
2.16.2Declaration
The available MLIB_MacRnd functions have the following declarations:
The MLIB_MacRndSat functions return the sum of the input accumulator and the
rounded fractional product of two multiplicands. The round method is the round to
nearest. The function saturates the output. See the following equation:
Equation 15. Algorithm formula
2.17.1
Available versions
This function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may saturate.
The available versions of the MLIB_MacRndSat function are shown in the following
table.
Table 2-17. Function versions
Function nameInput typeResult
Accum.Mult. 1Mult. 2
MLIB_MacRndSat_F16frac16_tfrac16_tfrac16_tfrac16_tThe fractional product (of two 16-bit fractional
MLIB_MacRndSat_F32llsfrac32_tfrac32_tfrac16_tfrac32_tThe fractional product (of a 32-bit and 16-bit
MLIB_MacRndSat_F32frac32_tfrac32_tfrac32_tfrac32_tThe fractional product (of two 32-bit fractional
type
multiplicands), rounded to the upper 16 bits,
is added to a 16-bit fractional accumulator.
The output is within the range <-1 ; 1).
fractional multiplicands), rounded to the upper
32 bits [16..48], is added to a 32-bit fractional
accumulator. The output is within the range
<-1 ; 1).
multiplicands), rounded to the upper 32 bits
[32..63], is added to a 32-bit fractional
accumulator. The output is within the range
<-1 ; 1).
Description
MLIB User's Guide, Rev. 5, 12/2020
68NXP Semiconductors
Chapter 2 Algorithms in detail
2.17.2Declaration
The available MLIB_MacRndSat functions have the following declarations:
The MLIB_Mac4 functions return the sum of two products of two pairs of multiplicands.
The function does not saturate the output. See the following equation:
Equation 16. Algorithm formula
2.18.1
Available versions
This function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may overflow.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors69
MLIB_Mac4
The available versions of the MLIB_Mac4 function are shown in the following table.
Table 2-18. Function versions
Function nameInput typeResult
Product 1Product 2
Mult. 1Mult. 2Mult. 1Mult. 2
MLIB_Mac4_F32ssssfrac16_tfrac16_tfrac16_tfrac16_tfrac32_tAddition of two 32-bit fractional
type
products (of two 16-bit fractional
multiplicands). The output is within the
range <-1 ; 1).
Description
2.18.2Declaration
The available MLIB_Mac4 functions have the following declarations:
The MLIB_Mac4Sat functions return the sum of two products of two pairs of
multiplicands. The function saturates the output. See the following equation:
Equation 17. Algorithm formula
2.19.1
Available versions
This function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may saturate.
The available versions of the MLIB_Mac4Sat function are shown in the following table.
Table 2-19. Function versions
Function nameInput typeResult
Product 1Product 2
Mult. 1Mult. 2Mult. 1Mult. 2
MLIB_Mac4Sat_F32ssssfrac16_tfrac16_tfrac16_tfrac16_tfrac32_tAddition of two 32-bit fractional
type
products (of two 16-bit fractional
multiplicands). The output is within
the range <-1 ; 1).
Description
2.19.2Declaration
The available MLIB_Mac4Sat functions have the following declarations:
The MLIB_Mac4Rnd functions return the rounded sum of two products of two pairs of
multiplicands. The round method is the round to nearest. The function does not saturate
the output. See the following equation:
Equation 18. Algorithm formula
2.20.1
Available versions
This function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may overflow.
MLIB User's Guide, Rev. 5, 12/2020
72NXP Semiconductors
Chapter 2 Algorithms in detail
The available versions of the MLIB_Mac4Rnd function are shown in the following table.
Table 2-20. Function versions
Function nameInput typeResult
Product 1Product 2
Mult. 1Mult. 2Mult. 1Mult. 2
MLIB_Mac4Rnd_F16frac16_tfrac16_tfrac16_tfrac16_tfrac16_tAddition of two 16-bit fractional products
MLIB_Mac4Rnd_F32frac32_tfrac32_tfrac32_tfrac32_tfrac32_tAddition of two 32-bit fractional products
type
(of two 16-bit fractional multiplicands),
rounded to the upper 16 bits. The output
is within the range <-1 ; 1).
(of two 32-bit fractional multiplicands),
rounded to the upper 32 bits. The output
is within the range <-1 ; 1).
Description
2.20.2Declaration
The available MLIB_Mac4Rnd functions have the following declarations:
The MLIB_Mac4RndSat functions return the rounded sum of two products of two pairs
of multiplicands. The round method is the round to nearest. The function saturates the
output. See the following equation:
Equation 19. Algorithm formula
2.21.1
Available versions
The function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may saturate.
The available versions of the MLIB_Mac4RndSat function are shown in the following
table.
Table 2-21. Function versions
Function nameInput typeResult
Product 1Product 2
Mult. 1Mult. 2Mult. 1Mult. 2
MLIB_Mac4RndSat_F16frac16_tfrac16_tfrac16_tfrac16_tfrac16_tAddition of two 16-bit fractional
MLIB_Mac4RndSat_F32frac32_tfrac32_tfrac32_tfrac32_tfrac32_tAddition of two 32-bit fractional
type
products (of two 16-bit fractional
multiplicands), rounded to the upper
16 bits. The output is within the
range <-1 ; 1).
products (of two 32-bit fractional
multiplicands), rounded to the upper
32 bits. The output is within the
range <-1 ; 1).
Description
2.21.2Declaration
The available MLIB_Mac4RndSat functions have the following declarations:
The MLIB_Mnac functions return the product of two multiplicands minus the input
accumulator. The function does not saturate the output. See the following equation:
Equation 20. Algorithm formula
2.22.1
Available versions
This function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may overflow.
• Accumulator output with mixed inputs - the output is the accumulator type, where
the result can be out of the range <-1 ; 1). The accumulator is the accumulator type,
the multiplicands are the fractional types. The result may overflow.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors75
MLIB_Mnac
The available versions of the MLIB_Mnac function are shown in the following table.
Table 2-22. Function versions
Function nameInput typeResult
Accum.Mult. 1Mult. 2
MLIB_Mnac_F16frac16_tfrac16_tfrac16_tfrac16_tThe 16-bit fractional accumulator is subtracted from
MLIB_Mnac_F32lssfrac32_tfrac16_tfrac16_tfrac32_tThe 32-bit fractional accumulator is subtracted from
MLIB_Mnac_F32frac32_tfrac32_tfrac32_tfrac32_tThe 32-bit fractional accumulator is subtracted from
MLIB_Mnac_A32assacc32_tfrac16_tfrac16_tacc32_tThe 32-bit accumulator is subtracted from the upper
type
the upper 16-bit portion [16..31] of the fractional
product (of two 16-bit fractional multiplicands). The
output is within the range <-1 ; 1).
the 32-bit fractional product (of two 16-bit fractional
multiplicands). The output is within the range <-1 ;
1).
the upper 32-bit portion [32..63] of the fractional
product (of two 32-bit fractional multiplicands). The
output is within the range <-1 ; 1).
16-bit portion [16..31] of the fractional product (of two
16-bit fractional multiplicands). The output may be
out of the range <-1 ; 1).
Description
2.22.2Declaration
The available MLIB_Mnac functions have the following declarations:
The MLIB_MnacSat functions return the product of two multiplicands minus the input
accumulator. The function saturates the output. See the following equation:
Equation 21. Algorithm formula
2.23.1
Available versions
This function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may saturate.
The available versions of the MLIB_MnacSat function are shown in the following table.
Table 2-23. Function versions
Function nameInput typeResult
Accum.Mult. 1Mult. 2
MLIB_MnacSat_F16frac16_tfrac16_tfrac16_tfrac16_tThe 16-bit fractional accumulator is subtracted from
MLIB_MnacSat_F32lss frac32_tfrac16_tfrac16_tfrac32_tThe 32-bit fractional accumulator is subtracted from
MLIB_MnacSat_F32frac32_tfrac32_tfrac32_tfrac32_tThe 32-bit fractional accumulator is subtracted from
type
the upper 16-bit portion [16..31] of the fractional
product (of two 16-bit fractional multiplicands). The
output is within the range <-1 ; 1).
the 32-bit fractional product (of two 16-bit fractional
multiplicands). The output is within the range <-1 ;
1).
the upper 32-bit portion [32..63] of the fractional
product (of two 32-bit fractional multiplicands). The
output is within the range <-1 ; 1).
Description
2.23.2Declaration
The available MLIB_MnacSat functions have the following declarations:
The MLIB_MnacRnd functions return the rounded product of two multiplicands minus
the input accumulator. The round method is the round to nearest. The function does not
saturate the output. See the following equation:
Equation 22. Algorithm formula
2.24.1
Available versions
This function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may overflow.
• Accumulator output with mixed inputs - the output is the accumulator type, where
the result can be out of the range <-1 ; 1). The accumulator is the accumulator type,
the multiplicands are the fractional types. The result may overflow.
MLIB User's Guide, Rev. 5, 12/2020
78NXP Semiconductors
Chapter 2 Algorithms in detail
The available versions of the MLIB_MnacRnd function are shown in the following table.
Table 2-24. Function versions
Function nameInput typeResult
Accum.Mult. 1Mult. 2
MLIB_MnacRnd_F16frac16_tfrac16_tfrac16_tfrac16_tThe 16-bit fractional accumulator is
MLIB_MnacRnd_F32llsfrac32_tfrac32_tfrac16_tfrac32_tThe 32-bit fractional accumulator is
MLIB_MnacRnd_F32frac32_tfrac32_tfrac32_tfrac32_tThe 32-bit fractional accumulator is
MLIB_MnacRnd_A32assacc32_tfrac16_tfrac16_tacc32_tThe 32-bit accumulator is subtracted from
type
subtracted from the fractional product (of two
16-bit fractional multiplicands) rounded to the
upper 16 bits. The output is within the range
<-1 ; 1).
subtracted from the fractional product (of a
32-bit and a 16-bit fractional multiplicand)
rounded to the upper 32 bits [16..48]. The
output is within the range <-1 ; 1).
subtracted from the fractional product (of two
32-bit fractional multiplicands) rounded to the
upper 32 bits [32..63]. The output is within
the range <-1 ; 1).
the fractional product (of two 16-bit fractional
multiplicands) rounded to the upper 16-bits
[16..31]. The output may be out of the range
<-1 ; 1).
Description
2.24.2Declaration
The available MLIB_MnacRnd functions have the following declarations:
The MLIB_MnacRndSat functions return the rounded product of two multiplicands
minus the input accumulator. The round method is the round to nearest. The function
saturates the output. See the following equation:
Equation 23. Algorithm formula
2.25.1
Available versions
This function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may saturate.
The available versions of the MLIB_MnacRndSat function are shown in the following
table.
Table 2-25. Function versions
Function nameInput typeResult
Accum.Mult. 1Mult. 2
MLIB_MnacRndSat_F16frac16_tfrac16_tfrac16_tfrac16_tThe 16-bit fractional accumulator is
MLIB_MnacRndSat_F32llsfrac32_tfrac32_tfrac16_tfrac32_tThe 32-bit fractional accumulator is
MLIB_MnacRndSat_F32frac32_tfrac32_tfrac32_tfrac32_tThe 32-bit fractional accumulator is
type
subtracted from the fractional product (of
two 16-bit fractional multiplicands)
rounded to the upper 16 bits. The output
is within the range <-1 ; 1).
subtracted from the fractional product (of
a 32-bit and a 16-bit fractional
multiplicand) rounded to the upper 32 bits
[16..48]. The output is within the range
<-1 ; 1).
subtracted from the fractional product (of
two 32-bit fractional multiplicands)
rounded to the upper 32 bits [32..63]. The
output is within the range <-1 ; 1).
Description
MLIB User's Guide, Rev. 5, 12/2020
80NXP Semiconductors
Chapter 2 Algorithms in detail
2.25.2Declaration
The available MLIB_MnacRndSat functions have the following declarations:
The MLIB_Msu functions return the fractional product of two multiplicands subtracted
from the input accumulator. The function does not saturate the output. See the following
equation:
Equation 24. Algorithm formula
2.26.1
Available versions
This function is available in the following versions:
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors81
MLIB_Msu
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may overflow.
• Accumulator output with mixed inputs - the output is the accumulator type, where
the result can be out of the range <-1 ; 1). The accumulator is the accumulator type,
the multiplicands are the fractional types. The result may overflow.
The available versions of the MLIB_Msu function are shown in the following table.
Table 2-26. Function versions
Function nameInput typeResult
Accum.Mult. 1Mult. 2
MLIB_Msu_F16frac16_tfrac16_tfrac16_tfrac16_tThe upper 16-bit portion [16..31] of the fractional
MLIB_Msu_F32lssfrac32_tfrac16_tfrac16_tfrac32_tThe 32-bit fractional product (of two 16-bit fractional
MLIB_Msu_F32frac32_tfrac32_tfrac32_tfrac32_tThe upper 32-bit portion [32..63] of the fractional
MLIB_Msu_A32assacc32_tfrac16_tfrac16_tacc32_tThe upper 16-bit portion [16..31] of the fractional
type
product (of two 16-bit fractional multiplicands) is
subtracted from a 16-bit fractional accumulator. The
output is within the range <-1 ; 1).
multiplicands) is subracted from a 32-bit fractional
accumulator. The output is within the range <-1 ; 1).
product (of two 32-bit fractional multiplicands) is
subtracted from a 32-bit fractional accumulator. The
output is within the range <-1 ; 1).
product (of two 16-bit fractional multiplicands) is
subtracted from a 32-bit accumulator. The output
may be out of the range <-1 ; 1).
Description
2.26.2Declaration
The available MLIB_Msu functions have the following declarations:
The MLIB_MsuSat functions return the fractional product of two multiplicands
subtracted from the input accumulator. The function saturates the output. See the
following equation:
Equation 25. Algorithm formula
2.27.1
Available versions
This function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may saturate.
The available versions of the MLIB_MsuSat function are shown in the following table.
Table 2-27. Function versions
Function nameInput typeResult
Accum.Mult. 1Mult. 2
MLIB_MsuSat_F16frac16_tfrac16_tfrac16_tfrac16_tThe upper 16-bit portion [16..31] of the fractional
MLIB_MsuSat_F32lssfrac32_tfrac16_tfrac16_tfrac32_tThe 32-bit fractional product (of two 16-bit
MLIB_MsuSat_F32frac32_tfrac32_tfrac32_tfrac32_tThe upper 32-bit portion [32..63] of the fractional
type
product (of two 16-bit fractional multiplicands) is
subtracted from a 16-bit fractional accumulator.
The output is within the range <-1 ; 1).
fractional multiplicands) is subtracted from a 32-bit
fractional accumulator. The output is within the
range <-1 ; 1).
product (of two 32-bit fractional multiplicands) is
subracted from a 32-bit fractional accumulator.
The output is within the range <-1 ; 1).
Description
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors83
MLIB_MsuRnd
2.27.2Declaration
The available MLIB_MsuSat functions have the following declarations:
The MLIB_MsuRnd functions return the rounded fractional product of two multiplicands
subtracted from the input accumulator. The round method is the round to nearest. The
function does not saturate the output. See the following equation:
Equation 26. Algorithm formula
2.28.1
Available versions
This function is available in the following versions:
MLIB User's Guide, Rev. 5, 12/2020
84NXP Semiconductors
Chapter 2 Algorithms in detail
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may overflow.
• Accumulator output with mixed inputs - the output is the accumulator type, where
the result can be out of the range <-1 ; 1). The accumulator is the accumulator type,
the multiplicands are the fractional types. The result may overflow.
The available versions of the MLIB_MsuRnd function are shown in the following table.
Table 2-28. Function versions
Function nameInput typeResult
Accum.Mult. 1Mult. 2
MLIB_MsuRnd_F16frac16_tfrac16_tfrac16_tfrac16_tThe fractional product (of two 16-bit fractional
MLIB_MsuRnd_F32llsfrac32_tfrac32_tfrac16_tfrac32_tThe fractional product (of a 32-bit and 16-bit
MLIB_MsuRnd_F32frac32_tfrac32_tfrac32_tfrac32_tThe fractional product (of two 32-bit fractional
MLIB_MsuRnd_A32assacc32_tfrac16_tfrac16_tacc32_tThe fractional product (of two 16-bit fractional
type
multiplicands), rounded to the upper 16 bits, is
subtracted from a 16-bit fractional accumulator.
The output is within the range <-1 ; 1).
fractional multiplicands), rounded to the upper
32 bits [16..48], is subtracted from a 32-bit
fractional accumulator. The output is within the
range <-1 ; 1).
multiplicands), rounded to the upper 32 bits
[32..63], is subtracted from a 32-bit fractional
accumulator. The output is within the range <-1 ;
1).
multiplicands), rounded to the upper 16 bits
[16..31], is subtracted from a 32-bit accumulator.
The output may be out of the range <-1 ; 1).
Description
2.28.2Declaration
The available MLIB_MsuRnd functions have the following declarations:
The MLIB_MsuRndSat functions return the rounded fractional product of two
multiplicands subtracted from the input accumulator. The round method is the round to
nearest. The function saturates the output. See the following equation:
Equation 27. Algorithm formula
2.29.1
Available versions
This function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may saturate.
The available versions of the MLIB_MsuRndSat function are shown in the following
table.
Table 2-29. Function versions
Function nameInput typeResult
Accum.Mult. 1Mult. 2
MLIB_MsuRndSat_F16frac16_tfrac16_tfrac16_tfrac16_tThe fractional product (of two 16-bit fractional
MLIB_MsuRndSat_F32llsfrac32_tfrac32_tfrac16_tfrac32_tThe fractional product (of a 32-bit and 16-bit
type
multiplicands), rounded to the upper 16 bits,
is subtracted from a 16-bit fractional
accumulator. The output is within the range
<-1 ; 1).
fractional multiplicands), rounded to the upper
32 bits [16..48], is subtracted from a 32-bit
fractional accumulator. The output is within
the range <-1 ; 1).
Description
Table continues on the next page...
MLIB User's Guide, Rev. 5, 12/2020
86NXP Semiconductors
Table 2-29. Function versions (continued)
Chapter 2 Algorithms in detail
Function nameInput typeResult
Accum.Mult. 1Mult. 2
MLIB_MsuRndSat_F32frac32_tfrac32_tfrac32_tfrac32_tThe fractional product (of two 32-bit fractional
type
multiplicands), rounded to the upper 32 bits
[32..63], is subtracted from a 32-bit fractional
accumulator. The output is within the range
<-1 ; 1).
Description
2.29.2Declaration
The available MLIB_MsuRndSat functions have the following declarations:
The MLIB_Msu4 functions return the subtraction of the products of two multiplicands.
The function does not saturate the output. See the following equation:
Equation 28. Algorithm formula
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors87
MLIB_Msu4
2.30.1Available versions
The function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may overflow.
The available versions of the MLIB_Msu4 function are shown in the following table.
Table 2-30. Function versions
Function nameInput typeResult
Minuend productSubtrahend product
Mult. 1Mult. 2Mult. 1Mult. 2
MLIB_Msu4_F32ssssfrac16_tfrac16_tfrac16_tfrac16_tfrac32_tSubtraction of two 32-bit
type
fractional products (of two 16-bit
fractional multiplicands). The
output is within the range <-1 ;
1).
Description
2.30.2Declaration
The available MLIB_Msu4 functions have the following declarations:
The MLIB_Msu4Rnd functions return the rounded subtraction of two products of two
pairs of multiplicands. The round method is the round to nearest. The function does not
saturate the output. See the following equation:
Equation 30. Algorithm formula
2.32.1
Available versions
This function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may overflow.
MLIB User's Guide, Rev. 5, 12/2020
90NXP Semiconductors
Chapter 2 Algorithms in detail
The available versions of the MLIB_Msu4Rnd function are shown in the following table.
Table 2-32. Function versions
Function nameInput typeResult
Minuend productSubtrahend product
Mult. 1Mult. 2Mult. 1Mult. 2
MLIB_Msu4Rnd_F16frac16_tfrac16_tfrac16_tfrac16_tfrac16_tSubtraction of two 16-bit
MLIB_Msu4Rnd_F32frac32_tfrac32_tfrac32_tfrac32_tfrac32_tSubtraction of two 32-bit
type
fractional products (of two 16-bit
fractional multiplicands), rounded
to the upper 16 bits. The output is
within the range <-1 ; 1).
fractional products (of two 32-bit
fractional multiplicands), rounded
to the upper 32 bits. The output is
within the range <-1 ; 1).
Description
2.32.2Declaration
The available MLIB_Msu4Rnd functions have the following declarations:
The MLIB_Msu4RndSat functions return the rounded subtraction of two products of two
pairs of multiplicands. The round method is the round to nearest. The function saturates
the output. See the following equation:
Equation 31. Algorithm formula
2.33.1
Available versions
This function is available in the following versions:
• Fractional output - the output is the fractional portion of the result; the result is
within the range <-1 ; 1). The result may saturate.
The available versions of the MLIB_Msu4RndSat function are shown in the following
table.
Table 2-33. Function versions
Function nameInput typeResult
Minuend productSubtrahend product
Mult. 1Mult. 2Mult. 1Mult. 2
MLIB_Msu4RndSat_F16frac16_tfrac16_tfrac16_tfrac16_tfrac16_tSubtraction of two 16-bit
MLIB_Msu4RndSat_F32frac32_tfrac32_tfrac32_tfrac32_tfrac32_tSubtraction of two 32-bit
type
fractional products (of two 16bit fractional multiplicands),
rounded to the upper 16 bits.
The output is within the range
<-1 ; 1).
fractional products (of two 32bit fractional multiplicands),
rounded to the upper 32 bits.
The output is within the range
<-1 ; 1).
Description
2.33.2Declaration
The available MLIB_Msu4RndSat functions have the following declarations:
The MLIB_Mul functions return the product of two multiplicands. The function does not
saturate the output. See the following equation:
Equation 32. Algorithm formula
2.34.1
Available versions
This function is available in the following versions:
• Fractional output with fractional inputs - the output is the fractional portion of the
result; the result is within the range <-1 ; 1). The inputs are the fractional values only.
The result may overflow.
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors93
MLIB_Mul
• Fractional output with mixed inputs - the output is the fractional portion of the result;
the result is within the range <-1 ; 1). The inputs are the accumulator and fractional
values. The result may overflow.
• Accumulator output - the output is the accumulator type where the result can be out
of the range <-1 ; 1). The result may overflow.
The available versions of the MLIB_Mul function are shown in the following table:
Table 2-34. Function versions
Function nameInput typeResult
Mult. 1Mult. 2
MLIB_Mul_F16frac16_tfrac16_tfrac16_tProduct of two 16-bit fractional multiplicands; the output are the
MLIB_Mul_F16asacc32_tfrac16_tfrac16_tProduct of a 32-bit accumulator and a 16-bit fractional multiplicand;
MLIB_Mul_F32ssfrac16_tfrac16_tfrac32_tProduct of two 16-bit fractional multiplicands; the result is a 32-bit
MLIB_Mul_F32frac32_tfrac32_tfrac32_tProduct of two 32-bit fractional multiplicands; the output are the
MLIB_Mul_A32acc32_tacc32_tacc32_tProduct of two 32-bit accumulator multiplicands; the output is a 32-
type
upper 16 bits of the results [16..31]. The output is within the range
<-1 ; 1).
the output is a 16-bit fractional portion, which has the upper 16 bits
of the fractional value of the result [16..31]. The output is within the
range <-1 ; 1).
fractional value. The output is within the range <-1 ; 1).
upper 32 bits of the results [16..31]. The output is within the range
<-1 ; 1).
bit accumulator, which has the upper mid bits of the result [16..47].
The output is within the range <-65536.0 ; 65536.0).
Description
2.34.2Declaration
The available MLIB_Mul functions have the following declarations:
The MLIB_MulSat functions return the product of two multiplicands. The function
saturates the output. See the following equation:
Equation 33. Algorithm formula
2.35.1
Available versions
This function is available in the following versions:
• Fractional output with fractional inputs - the output is the fractional portion of the
result; the result is within the range <-1 ; 1). The inputs are the fractional values only.
The result may saturate.
• Fractional output with mixed inputs - the output is the fractional portion of the result;
the result is within the range <-1 ; 1). The inputs are the accumulator and fractional
values. The result may saturate.
• Accumulator output - the output is the accumulator type where the result can be out
of the range <-1;1). The result may overflow.
The available versions of the MLIB_MulSat function are shown in the following table:
Table 2-35. Function versions
Function nameInput typeResult
Mult. 1Mult. 2
MLIB_MulSat_F16frac16_tfrac16_tfrac16_tProduct of two 16-bit fractional multiplicands; the output is the
type
upper 16 bits of the results [16..31]. The output is within the
range <-1 ; 1).
Description
Table continues on the next page...
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors95
MLIB_MulNeg
Table 2-35. Function versions (continued)
Function nameInput typeResult
Mult. 1Mult. 2
MLIB_MulSat_F16asacc32_tfrac16_tfrac16_tProduct of a 32-bit accumulator and a 16-bit fractional
MLIB_MulSat_F32ssfrac16_tfrac16_tfrac32_tProduct of two 16-bit fractional multiplicands; the result is a 32-
MLIB_MulSat_F32frac32_tfrac32_tfrac32_tProduct of two 32-bit fractional multiplicands; the output are the
MLIB_MulSat_A32acc32_tacc32_tacc32_tProduct of two 32-bit accumulator multiplicands; the output is a
type
multiplicand; the output is a 16-bit fractional value, which has
the upper 16 bits of the fractional portion of the result [16..31].
The output is within the range <-1 ; 1).
bit fractional value. The output is within the range <-1 ; 1).
upper 32 bits of the results [16..31]. The output is within the
range <-1 ; 1).
32-bit accumulator, which has the mid bits of the result [16..47].
The output is within the range <-65536.0 ; 65536.0).
Description
2.35.2Declaration
The available MLIB_MulSat functions have the following declarations:
The MLIB_MulNeg functions return the negative product of two multiplicands. The
function does not saturate the output. See the following equation:
Equation 34. Algorithm formula
2.36.1Available versions
This function is available in the following versions:
• Fractional output with fractional inputs - the output is the fractional portion of the
result; the result is within the range <-1 ; 1). The inputs are the fractional values only.
• Fractional output with mixed inputs - the output is the fractional portion of the result;
the result is within the range <-1 ; 1). The inputs are the accumulator and fractional
values. The result may overflow.
• Accumulator output - the output is the accumulator type where the result can be out
of the range <-1;1). The result may overflow.
The available versions of the MLIB_MulNeg function are shown in the following table.
Table 2-36. Function versions
Function nameInput typeResult
Mult. 1Mult. 2
MLIB_MuNegl_F16frac16_tfrac16_tfrac16_tNegative product of two 16-bit fractional multiplicands; the
MLIB_MulNeg_F16asacc32_tfrac16_tfrac16_tNegative product of a 32-bit accumulator and a 16-bit fractional
MLIB_MulNeg_F32ssfrac16_tfrac16_tfrac32_tNegative product of two 16-bit fractional multiplicands; the
MLIB_MulNeg_F32frac32_tfrac32_tfrac32_tNegative product of two 32-bit fractional multiplicands; the
MLIB_MulNeg_A32acc32_tacc32_tacc32_tProduct of two 32-bit accumulator multiplicands; the output is a
type
output are the upper 16 bits of the results [16..31]. The output
is within the range <-1 ; 1).
multiplicand; the output is a 16-bit fractional value, which has
the upper 16 bits of the fractional portion of the result [16..31].
The output is within the range <-1 ; 1).
result is a 32-bit fractional value. The output is within the range
<-1 ; 1).
output are the upper 32 bits of the results [16..31]. The output
is within the range <-1 ; 1).
32-bit accumulator, which has the mid bits of the result
[16..47]. The output is within the range <-65536.0 ; 65536.0).
Description
2.36.2Declaration
The available MLIB_MulNeg functions have the following declarations:
The MLIB_MulNegSat functions return the negative product of two multiplicands. The
function saturates the output. See the following equation:
Equation 35. Algorithm formula
2.37.1
Available versions
This function is available in the following versions:
• Fractional output with mixed inputs - the output is the fractional portion of the result;
the result is within the range <-1 ; 1). The inputs are the accumulator and fractional
values. The result may saturate.
• Accumulator output - the output is the accumulator type where the result can be out
of the range <-1 ; 1). The result may overflow.
MLIB User's Guide, Rev. 5, 12/2020
98NXP Semiconductors
Chapter 2 Algorithms in detail
The available versions of the MLIB_MulNegSat function are shown in the following
table:
Table 2-37. Function versions
Function nameInput typeResult
Mult. 1Mult. 2
MLIB_MulNegSat_F16as acc32_tfrac16_tfrac16_tNegative product of a 32-bit accumulator and a 16-bit fractional
MLIB_MulNegSat_A32acc32_tacc32_tacc32_tNegative product of two 32-bit accumulator multiplicands; the
type
multiplicand; the output is a 16-bit fractional value, which has
the upper 16 bits of the fractional portion of the result [16..31].
The output is within the range <-1 ; 1).
output is a 32-bit accumulator, which has the middle bits of the
result [16..47]. The output is within the range <-65536.0 ;
65536.0).
Description
2.37.2Declaration
The available MLIB_MulNegSat functions have the following declarations:
The MLIB_MulRnd functions return the rounded product of two multiplicands. The
round method is the round to nearest. The function does not saturate the output. See the
following equation:
MLIB User's Guide, Rev. 5, 12/2020
NXP Semiconductors99
MLIB_MulRnd
Equation 36. Algorithm formula
2.38.1Available versions
This function is available in the following versions:
• Fractional output with fractional inputs - the output is the fractional portion of the
result; the result is within the range <-1 ; 1). The inputs are the fractional values only.
The result may overflow.
• Fractional output with mixed inputs - the output is the fractional portion of the result;
the result is within the range <-1 ; 1). The inputs are the accumulator and fractional
values. The result may overflow.
• Accumulator output - the output is the accumulator type where the result can be out
of the range <-1 ; 1). The result may overflow.
The available versions of the MLIB_MulRnd function are shown in the following table:
Table 2-38. Function versions
Function nameInput typeResult
Mult. 1Mult. 2
MLIB_MulRnd_F16frac16_tfrac16_tfrac16_tProduct of two 16-bit fractional multiplicands; the output is
MLIB_MulRnd_F16asacc32_tfrac16_tfrac16_tProduct of a 32-bit accumulator and a 16-bit fractional
MLIB_MulRnd_F32lsfrac32_tfrac16_tfrac32_tProduct of a 32-bit and a 16-bit fractional multiplicand; the
MLIB_MulRnd_F32frac32_tfrac32_tfrac32_tProduct of two 32-bit fractional multiplicands; the output is
MLIB_MulRnd_A32acc32_tacc32_tacc32_tProduct of two 32-bit accumulator multiplicands; the output is
type
rounded to the upper 16 bits of the results [16..31]. The output
is within the range <-1 ; 1).
multiplicand; the output is a 16-bit fractional value, which is
rounded to the upper 16 bits of the fractional portion of the
result [16..31]. The output is within the range <-1 ; 1).
output is rounded to the upper 32 bits of the fractional portion
of the result [16..47]. The output is within the range <-1 ; 1).
rounded to the upper 32 bits of the results [16..31]. The output
is within the range <-1 ; 1).
rounded to the middle bits of the result [16..47]. The output is
within the range <-65536.0 ; 65536.0).
Description
2.38.2Declaration
The available MLIB_MulRnd functions have the following declarations:
MLIB User's Guide, Rev. 5, 12/2020
100NXP Semiconductors
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.