Is an FPGA right for your application?
FPGAs are faster than microcontrollers and more flexible than Application Specific Integrated Circuits (ASICs). They can not only be used in place of software but also drastically outperform it. It’s little wonder that these integrated circuits are a compelling option for anyone building an embedded device.
However, for all their advantages, choosing an FPGA can carry a high cost. And, as we’ll see in this article, using hardware instead of software could put your device at odds with compliance in regulated sectors.
What is an FPGA?
A Field-Programmable Gateway Array (FPGA) is an integrated circuit designed to be configured (and reconfigured) after manufacture. It comprises a matrix of logic blocks connected by user-programmable interconnects.
This is distinct from ASICs, which are manufactured for a specific use and are not reconfigurable. And from microcontrollers (MCUs), which have fixed hardware and minimal configuration options.
Crucially, microcontrollers run software via a CPU, whereas FPGAs are programmed at a hardware level and do not require software at all. That being said, some FPGAs come equipped with an MCU core, offering a strong middle ground. Alternatively, the hardware is so versatile that you can program the FPGA fabric to become an MCU.
While an FPGA and microcontroller can perform the same tasks, FPGAs are configured to process data in parallel in a highly optimised way. Speeds can be orders of magnitude higher.
They are good at processing lots of data in relatively simple ways but struggle to process small amounts of data in a more complex fashion. This is where MCUs perform better.
You will find ASICs in mass-produced devices such as mobile phones, routers, and game consoles. FPGAs, on the other hand, are better suited to specialist devices with far smaller manufacturing runs. However, FPGAs may be used to validate an ASIC design before it goes into manufacture, or to develop firmware.
FPGAs are used in specialist applications across a wide range of industries: from medtech and aerospace to automotive and astronomy. In recent years, they’ve also proven hugely beneficial to advancing 5G infrastructure.
Benefits of FPGA
FPGAs are popular pieces of hardware and with good reason. They boast a number of advantages:
Flexibility
The ability to reconfigure FPGAs means engineers can optimise them as a project evolves. The composite logic blocks can even be configured to perform as a softcore CPU. Crucially for embedded devices, an FPGA can be programmed to bridge two interfaces –USB and serial communication, for example—without the need for a host computer.
With an FPGA, you can specify precisely which interfaces you require for the project. For example, if you need ten SPI interfaces and five UARTs but no I2C interfaces, then having exactly that is no problem. With an MCU, you get whatever interfaces come with the chip—there’s no flexibility.
Granularity
The flexible, reconfigurable nature of FPGAs grants them finer precision of control than other digital devices, such as microprocessors. Consequently, they are capable of more complex tasks than other devices. Full control of the clock and signals makes FPGAs particularly well-suited to tasks where timing is essential.
Speed
FPGAs are bare metal; rather than rely on software, they run directly on the hardware. With high bandwidth and the ability to parallel process, they are well-suited to tasks where speed is essential, such as Artificial Intelligence, cryptography, compression, video, audio, and more.
Without the hindrance of an operating system or generic buses, the latency of an FPGA is orders of magnitude better than that of an MCU.
Generous I/O
Most (but not all) FPGA ICs feature a sizeable number of inputs and outputs. They can have more than 1000 configurable pins if needed. This makes them a good candidate for big designs where you have a lot of external circuits to interface with.
What are the disadvantages of FPGA?
While FPGAs are significantly faster than microcontrollers and boast a host of other advantages, they also carry several significant limitations. These must be carefully considered when choosing the right hardware for your embedded device project:
High engineering costs
FPGAs are programmed using Hardware Description Language (HDL) such as VHDL or Verilog. However, this is much more challenging than providing a CPU with instructions, as you would on a microcontroller. One of our senior engineers, who has extensive experience with FPGAs, estimates that the hardware takes three or four times longer to program than a software alternative.
HDL takes a long time to compile. It is anywhere from three to ten times slower than an MCU.
Specialist skillset
HDL talent is scarce compared to developers skilled in higher-level languages, such as JavaScript, Python, or C. As a result, a qualified programmer is likely to charge significantly more.
Hiring a strong development team with HDL in its skillset may negate this extra cost. We’re lucky to have several experienced HDL developers on our teams at Bluefruit.
Tool limitations
Each FPGA manufacturer has their own proprietary design tools with no third-party tools available. Tools from the smaller FPGA manufacturers aren’t as well-developed, with fewer features than the larger ones. All the tools have their idiosyncrasies which can cause frustration at times. Typically, the tools needed are free to use for the smaller FPGA parts but can be expensive for the larger parts.
Expensive hardware
FPGAs are significantly more expensive than microcontrollers, which can be sourced at a fraction of the cost, regardless of production scale. Since they’re application-specific, ASICs are expensive to produce in small quantities but are far more cost-effective than FPGAs in mass production.
Typical costs run from £1-£10 at the low end and £300-£10,000 at the high end. By contrast, the cheapest MCUs cost less than 35p.
Vendor lock-in
Although it is fairly easy to port code from one FPGA manufacturer to another, moving between development environments is much more challenging—each vendor’s tools differ significantly.
This can cause significant complications.
Intel recently stopped taking orders for FPGAs from all but the US military and their largest customers. As of February 2023, this is still the case and has caused a lot of issues for their smaller customers.
Can you use an FPGA as software?
FPGAs can feature anywhere from a thousand to over 10 million logic elements, which can be individually programmed and optimised. They can be configured to carry out the same functions as software. You can even create a softcore CPU on an FPGA, though this would face similar speed restrictions as a separate unit.
Of course, all this is a bit problematic as far as compliance is concerned.
Compliance and FPGAs
There are several important requirements when creating embedded software for a device you intend to sell. Industry standards such as medtech’s IEC 62304, aerospace’s DO-178C, and automotive’s ISO 26262 ensure that software development complies with certain rules.
You may be thinking: “FPGAs are hardware. What has software compliance got to do with it?”. So, let’s take a look at this from a medical device perspective:
If an FPGA is integrated into a software architecture and fulfils a key element in how that software operates, it becomes a possible failure route for your software that could directly affect patient safety. IEC 62304 requires risk assessment of your device software and any risks to be documented, mitigated, and tested. It also requires software architecture documentation and testing of that structure, regardless of risks.
That means subjecting your HDL code and processes to the same level of scrutiny as code written for an MCU.
It may be seen as economical to “avoid” IEC 62304 in simpler architectures. However, once it becomes more complex and a potential failure route, it is wise to comply. There are a lot of value and good practice elements within IEC 62304, so compliance will undoubtedly benefit your approach to developing a safety-critical device and the software quality. Ultimately, you run a risk by not complying; what if an auditor believes it should be adhered to, and you must start your development lifecycle again? Retrofitting IEC 62304 is not easy and, sometimes, not possible.
So, just to be clear: when it comes to meeting compliance, it’s prudent to think of your FPGA as software. That means risk management, configuration management, documentation, testing, and anything else required to pass an audit.
If you’re curious about what these medtech requirements look like, take a look at our free IEC 62304 checklist.
FPGA Vs microcontroller
As we have seen, FPGAs are powerful, versatile hardware, but they can run up your engineering and production costs significantly. So, unless superior speeds are critical to your application, there’s a strong possibility that you’d be better off choosing an MCU.
Though slower, MCUs offer:
- Significantly lower unit costs
- Thousands of options to choose from
- Relatively uncomplicated to program
- Low power and ability to sleep
Of course, microcontrollers have disadvantages to consider, too, so it’s vital you make an informed decision.
Choose wisely
Whether it’s an FPGA or microcontroller, Ethernet or Wi-Fi, battery or mains, choosing the right hardware design for your specific application can save you time, money, and heartache. Bluefruit is often approached by teams that have made poor choices early on and are struggling to deal with the consequences.
It is important that you consult with both hardware and software engineers from the start to help you decide the best route. However, while it may be tempting to finalise hardware decisions at the start, it pays to wait.
In fact, the Agile work methodology advocates for deciding as late as possible. Developing a project across several pieces of hardware simultaneously may initially take more time, but identifying the right hardware pays off in the long term, improving performance, reliability, development costs and more.
Do you have a device development project in mind? If so, come and chat with us about it. Whether you’re in the planning stages or already in development, Bluefruit has expert hardware and software specialists, testers, and analysts who can help.
Did you know that we have a monthly newsletter?
If you’d like insights into software development, Lean-Agile practices, advances in technology and more to your inbox once a month—sign up today!
Find out more