SoC
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
  • Arm Cortex M3
  • Contact
Reading: Does cortex M0 have floating point?
SUBSCRIBE
SoCSoC
Font ResizerAa
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Search
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Have an existing account? Sign In
Follow US
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
© S-O-C.ORG, All Rights Reserved.
Arm

Does cortex M0 have floating point?

Eileen David
Last updated: October 5, 2023 9:58 am
Eileen David 9 Min Read
Share
SHARE

The simple answer is no, Cortex-M0 does not have hardware support for floating point operations. The Cortex-M0 is one of the smallest and simplest Arm Cortex-M processor cores, optimized for low-cost and low-power microcontroller applications. It is an entry-level 32-bit ARM Cortex-M processor that only supports a reduced Thumb instruction set without floating point unit (FPU).

Contents
Overview of Cortex-M0Lack of Floating Point UnitSoftware Emulation of Floating PointComparisons to other Cortex-M coresWhen Floating Point is Not NeededWhen Floating Point Becomes NecessaryConclusion

Overview of Cortex-M0

The Cortex-M0 was designed by Arm as an ultra low power 32-bit microcontroller core for embedded applications. It is meant for cost-sensitive and power-constrained devices that only require basic CPU performance. The M0 implements the ARMv6-M architecture and uses the Thumb-2 instruction set, but excludes some instructions like arithmetic operations on 64-bit values. It has a 32-bit single cycle nested vectored interrupt controller (NVIC) and a SysTick timer.

Some key features of Cortex-M0 are:

  • 32-bit RISC architecture, 2-stage pipeline
  • Up to 48MHz clock frequency
  • 32KB to 64KB embedded flash memory
  • 4KB to 16KB SRAM
  • Basic 2-cycle multiplier
  • 24 interrupt channels
  • Memory Protection Unit (MPU)
  • Debug access port

Being an entry-level microcontroller core, the Cortex-M0 focuses on extreme power efficiency and compact footprint rather than performance. It does not include more advanced features like a memory management unit (MMU), floating point unit (FPU), or digital signal processing (DSP) instructions. The lack of FPU is a key limitation in hardware floating point capability.

Lack of Floating Point Unit

The Cortex-M0 processor core does not contain a floating point unit (FPU). The FPU is the hardware component that handles floating point arithmetic and mathematical operations on fractional number values. It is dedicated silicon circuitry optimized for performing calculations on single and double precision floats efficiently.

On most processors, the FPU works in parallel with the main CPU cores to carry out floating point math. But the Cortex-M0 cuts out the FPU entirely from its design. All math operations have to be done by the CPU on integer numbers only. This saves chip area and reduces power consumption, but hampers floating point performance.

Without an FPU, the Cortex-M0 cannot execute the hardware floating point instructions defined in the ARM instruction set. Instructions like VADD, VSUB, VMUL, VDIV, VSQRT, VCVT cannot be directly used by M0 code. The compiler will report errors if such instructions are found during compilation targeting the Cortex-M0. This forces developers to implement math-heavy code using pure integer operations only.

Software Emulation of Floating Point

To enable support for floating point numbers and operations, the Cortex-M0 relies on software libraries that emulate floats and fractional math. This is done by compiling floating point operations into equivalent integer operations that approximate the same results. The downside is much lower performance compared to having dedicated FPU hardware.

Arm provides a software floating point library called M0softfp. It implements single precision (32-bit) floating point support conforming to the IEEE 754 standard. With M0softfp, Cortex-M0 devices can execute operations like float add, subtract, multiply, divide, square root etc. But the operations will be done through software routines, not hardware circuitry.

M0softfp works by representing floats in 32-bit integer format, then providing functions to convert between integer and float values. Math operations are carried out on the integers, but coded to produce floating point results. For division and square root, approximations like Newton-Raphson iteration are used. Transcendental functions like sine, cosine, logarithms etc. are also implemented through numerical approximation algorithms.

The downside of software float emulation is poor performance. Even simple floats operations like add or multiply take hundreds of clock cycles, up to 100X or more cycles than having a hardware FPU. This overhead quickly adds up when doing intensive mathematical computations. So Cortex M0 is not well suited for applications like digital signal processing that rely heavily on floating point math.

Comparisons to other Cortex-M cores

Unlike Cortex-M0, other higher-end Cortex-M cores do contain floating point units. A comparative look at different M class processors highlights the floating point limitations of M0:

  • Cortex-M3: Supports single precision float unit and basic DSP instructions.
  • Cortex-M4: Has single precision FPU and optional double precision FPU.
  • Cortex-M7: Features single and double precision FPU, plus advanced DSP extensios.
  • Cortex-M23: Entry-level FPU for basic floating point needs.
  • Cortex-M33: M23 FPU plus DSP instructions for signal processing.

For applications that absolutely require floating point capability, Cortex-M0 is not the right fit. The M3, M4 or M7 cores are more suitable, at the expense of higher cost, power and complexity. But a significant number of microcontroller use cases like simple control, I/O handling, protocol stacks etc can run just fine without floats.

When Floating Point is Not Needed

There are many embedded and IoT applications where the lack of floating point hardware is not a major handicap. These include:

  • Simple control systems like thermostats, motor controls etc.
  • Low bandwidth sensor interfaces and data acquisition.
  • Actuators, relays, valves, switches, LED/LCD displays.
  • Implementation of communication protocols like SPI, I2C, UART.
  • General purpose I/O management and device drivers.
  • Byte level data processing and packet handling.

In such cases, the Cortex-M0 provides a good blend of compact size, low cost, minor power draw, and adequate integer performance. Floating point math is simply not needed for the application logic. M0 microcontrollers are commonly found in cost-sensitive embedded devices like small appliances, toys, remotes, peripherals etc.

When Floating Point Becomes Necessary

There are also many embedded application scenarios where lack of floating point support on Cortex-M0 becomes a limitation:

  • Digital signal processing algorithms on audio, video, image data.
  • Sensor analytics requiring floating point math operations.
  • Motor control systems with precise real-time requirements.
  • Industrial process control and automation.
  • IoT edge nodes running machine learning inference.
  • Wearables and medical devices doing live signal analysis.

In such cases, Cortex-M0 will struggle due to no hardware FPU. The heavy software floating point overhead can make real-time response difficult. Applications that need both floating point math performance and low power budget may require Cortex-M4 or M7 based microcontrollers.

Conclusion

In summary, the Cortex-M0 is designed as a compact and energy efficient 32-bit MCU core for simple embedded applications. It saves silicon area and power by excluding a floating point unit. All floating point math has to be emulated in software, which is 100X slower than hardware acceleration. This makes Cortex-M0 unsuitable for workloads requiring heavy floating point arithmetic. For simple microcontroller applications not needing floats, Cortex-M0 provides a low cost and low power solution.

However, the lack of FPU does impose a limitation on addressing more complex embedded use cases. For such float-intensive workloads, Cortex-M3, M4 or M7 cores with floating point capability will be more appropriate despite higher cost and power. In the end, the choice comes down to analyzing the application requirements and constraints. The Cortex-M0 satisfies many simple low-end microcontroller needs as long as floating point math performance is not critical.

Newsletter Form (#3)

More ARM insights right in your inbox

 


Share This Article
Facebook Twitter Email Copy Link Print
Previous Article ARM Cortex-M0: Number of Clock Cycles for LDR Instruction
Next Article How to make use of the GCC fixed-point types extension on ARM Cortex-M?
Leave a comment Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

2k Followers Like
3k Followers Follow
10.1k Followers Pin
- Sponsored-
Ad image

You Might Also Like

What is the use of arm cortex M?

The ARM Cortex-M is a group of 32-bit RISC ARM…

6 Min Read

Tradeoffs Between Clock Frequency and Timing Closure in Arm Cortex M1

The Arm Cortex M1 processor is designed to provide high…

9 Min Read

Soft Float vs Hardware Floating Point Tradeoffs on Microcontrollers

When designing a microcontroller system that requires floating point math,…

14 Min Read

Arm Sleep Instruction

Falling asleep and staying asleep can be a challenge for…

8 Min Read
SoCSoC
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
Welcome Back!

Sign in to your account