Software implementations of integer and floating point arithmetic is available as library routines in libgcc.a for both processors. The compiler for both the processors inserts calls to these routines in the code produced, in case the hardware does not support the arithmetic primitive with an instruction. Details of the software implementations of integer and floating point arithmetic for MicroBlaze processors are listed below:
Integer Arithmetic
By default, integer multiplication is done in software using the library function
__mulsi3
. Integer multiplication is done in hardware if the
-mno-xl-soft-mul mb-gcc
option is specified. Integer divide and mod
operations are done in software using the library functions __divsi3 and __modsi3. The
Microblaze processor can also be customized to use a hard divider, in which case the div
instruction is used in place of the __divsi3
library routine. Double
precision multiplication, division and mod functions are carried out by the library
functions __muldi3
, __divdi3
, and
__moddi3
, respectively. The unsigned version of these operations
corresponds to the signed versions described above, but are prefixed with an
__u
instead of __
.
Floating Point Arithmetic
All floating point addition, subtraction, multiplication, division, and conversions are implemented using software functions in the C library.
Thread Safety
The standard C library provided with the Vitis IDE is not built for a multi-threaded environment. STDIO functions like printf()
, scanf()
, and memory management functions like malloc()
and free()
are common examples of functions that are not thread-safe. When using the C library in a multi-threaded environment, proper mutual exclusion techniques must be used to protect thread unsafe functions.