Close or Esc Key

Arduino Projects   |   Raspberry Pi   |   Electronic Circuits   |   AVR   |   PIC   |   8051   |   Electronic Projects

FPGA Vs Microcontrollers - Another Approach to Embedded Design

Submitted By: 


Most engineers start their journey in embedded systems with microcontrollers. With microcontrollers, one gets a complete miniature computing system on a single integrated circuit. The CPU, RAM, ROM and Input / Output peripherals all on a single thumb size SoC. This very popular approach to learning embedded design and development is in fact just the one side of the complete picture. Working with microcontrollers (and microprocessors) is all about software based embedded design. The microcontrollers have their own instruction set which remains fixed in size and operation. While working on microcontrollers, an engineer uses the same instruction set by means of either assembly language or embedded C to solve certain computing tasks in a real-world application.

Working with microcontrollers is quite easy. The popular microcontrollers like AVR, 8051, PIC, ARM etc well expose an engineer to software development aspect of embedded systems. But there is another approach of embedded development as well - Hardware based Embedded Design. Unfortunately, microcontrollers lack capability to expose an engineer to this aspect of embedded development. Here comes the FPGA.   

Field Programmable Gate Arrays (FPGA) was invented in 1984 by Xilinx. These are integrated circuits that contain millions of logic gates that can be electrically configured (i.e. the gates are field programmable) to perform certain tasks. Any computer like microcontroller, microprocessor, graphic processor or Application Specific Integrated Circuit (ASIC) is basically a digital electronic circuit that can perform certain tasks based on an instruction set. The instruction set contains the machine codes that can be implemented by the digital circuitry of the computer on some data where the data is stored and manipulated on registers or memory chips. The FPGA takes the design to hardware level where an engineer can design a (simple) computing device from the architecture level and this simple computer is designed and fabricated to perform a specific application.

Field Programmable Gate Array (FPGA)

Fig. 1: Field Programmable Gate Array (FPGA) for Embedded Systems      

Though, FPGA can be used to design an ALU and other digital circuitry to perform simple computational tasks, it is in fact no match to a microcontroller or microprocessor in computing terms. A microprocessor or microcontroller is  a true computing device with complex architecture. However, FPGA is quite comparable to Application Specific Integrated Circuits where any ASIC function can be custom designed and fabricated on FPGA.    

Microcontrollers let an engineer expertise in high level language or assembly language to design software for a computer but FPGA let an engineer to design a computer (a simple computing device) by own. This hardware based embedded design requires detailed knowledge of digital circuit design and computer architecture. Like microcontrollers are programmed using Assembly Language or a High Level Language (like C), FPGA chips  are programmed using Verilog or VHDL language. Like C Code or assembly code is converted to machine code for execution on respective CPU, VHDL language converts to digital logic blocks that are then fabricated on FPGA chip to design a custom computer for specific application. Using VHDL or Verilog, an engineer designs the data path and ALU hardware from root level. Even a microprocessor or microcontroller can be designed on FPGA provided it has sufficient logic blocks to support such design.

Beginning an embedded systems course with microcontrollers or microprocessors is obvious as it introduces an engineer to how computers work and can be programmed for an application. The FPGA completes the knowledge of embedded design by teaching how the computers (here, by computer, means a digital circuit capable of executing some instructions) are actually designed and fabricated. So, FPGA should be essentially introduced in advanced stage of an embedded design course. In fact, Microcontrollers, FPGA and CPLD (Complex Programmable Logic Devices) are independent embedded systems with their own pros and cons within the embedded engineering discipline.

Advantages of FPGA -

FPGA is not just means to learn about digital design and computer architecture. FPGA chips have some real applications in the embedded systems engineering. FPGA chips offer a true alternative to ASICs. The FPGA has the following advantages that also illustrate its use in the embedded systems -

Multi-Threading - FPGA can process multiple instructions at the same time. They can process instructions in parallel form. This is a big advantage compared to microcontrollers in many applications. The microcontrollers can perform only one instruction at a time and they can execute instructions only sequentially. Due to multi-threading feature, in many applications, the FPGA can process tasks faster compared to any microcontroller. Also, since the processes are logically coded at the hardware level, FPGA is suitable for seriously dedicated applications unlike microcontrollers which have a generic architecture and instruction set at their disposal to solve a task. FPGA's ability to process multiple simple logic operations at high speed make them ideal for several tasks like pre-processing sensor data, cryptography, logic circuit designing, digital audio applications, video streaming etc.

While microcontrollers are best at solving complex computational tasks at slow speeds that may require standard interfaces, the FPGA has an edge when the volume of data to be processed in an application is typically high. All credit to multi-threading feature of the FPGA. Even nowadays many FPGA boards are coming with built-in CPU. So, all needed is design the additional logic for application specific processing.

Flexibility and Scope of Design - Any digital circuit how complex it may be, can be designed on an FPGA chip provided the chip contains the sufficient number of logic blocks to emulate the design. It can be used to design any peripheral and perform any computing task. Such flexibility is not available with the microcontrollers. The microcontrollers comes with a generic computing unit and in-built peripherals like timers, GPIO, Interrupts and serial interfaces. There is no way in case of microcontrollers to alter the chip to suit a dedicated application. However, an FPGA can be programmed to have like 30 timers or 20 channel UART or 50 channel PWM generator or anything. This flexibility to design a chip of own choice and requirement gives great power to an embedded engineer in cases where the sitting computing chip in an application should have a dedicated design.  

Analog Factor - Generally, in any embedded system, controller or processor is coupled with sensors that provide analog input or with actuators that require analog output from the controller or processor. There are Field Programmable Analogue Array (FPAA) which can be programmed to carry analogue values. Many FPGA chips are a combination of FPGA as well as FPAA where the chip can not only be programmed to a digital circuit but also can be programmed to process analogue signals. These mixed signal chips contain ADC (Analog to Digital Converter) or DAC (Digital to Analog Converter) peripherals coupled with analogue signal conditioning blocks. The output pins in this case, can be programmed to have drive strength and slew rate as required by the load at that pin.  So, not only an FPGA chip can be programmed for an analog application, it here again provides flexibility of design to suit a dedicated sensor based application.

Reusability - The FPGA chips can be reprogrammed to emulate any other digital (as well as analog) circuit. It is not that once a circuit is fabricated on the chip, it remains fixed. When the chip is powered on, the digital design as configuration data is loaded on the chip. This happens every time the chip is powered on. The design remains on the chip till it remains powered on. This configuration data can be changed for the next start up, so an entirely new digital design can be emulated on the chip next time. As the chip is reusable, an embedded engineer can experiment with different digital design on the same chip for uncountable times.

Single Chip Solution - The FPGA chips provide single chip solution to an application. While using a microcontroller, it may require to be interfaced with other peripherals (which may not be in-built on the microcontroller), interfaces or ASICs, on FPGA, all required peripherals along with the processor or the controller can be designed on a single chip.

Real-time Processing - The FPGA chips are not generic computing ICs. They are used to fabricate a dedicated computing device on the chip. Unlike, a microcontroller which runs a program (machine code), the data paths and ALU are fabricated on FPGA to solve a specific computing task. So, instead of running a program, the FPGA itself is programmed to operate for a specific computing task. This execution of logic at the hardware level allows real--time processing of data and information. That is why, FPGA is generally used for high speed critical applications where a microcontroller might fail due to its generic architecture and dependency of code to run on fixed architecture and limited instruction set.

With the above advantages, the FPGA is best suited for high speed parallel processing where either the volume of data to be processed is large or the processing chip requires custom peripherals, configurable analog output or execution of a time-critical dedicated application (which would not be otherwise possible on a generic CPU). The FPGA gives an embedded engineer access to complex integrated designs which are otherwise only available at high engineering cost. FPGA is like a mini semiconductor foundry on a credit card size board to get off a good start in the integrated digital design.

In real world, FPGA finds applications in specific verticals where required production volume is not high. It is also extensively used in prototyping ASIC designs with benefit of minimum time to market avoiding the hassle of long fabrication process of ASIC design. The common applications of the FPGA are found in verticals like digital signal processing, image processing, bioinformatics, cryptography, software designed radios, medical imaging, voice recognition, telecommunications, data centres, aerospace electronics and security systems. On the other hand, microcontrollers are widely used in general embedded applications in the verticals like consumer electronics, automobiles, industrial electronics, communication systems, etc.   

Drawbacks of FPGA -         

FPGA has all its advantages and applications but with few drawbacks. These drawbacks account on several factors like economy, design and development. The FPGA technology currently has the following drawbacks -

Cost - FPGA boards are not cheaper. The FPGA board usually comes at a price of  $50 or above. This is many times high compared to any microcontroller board. Many microcontroller boards are available even in less than $10. The high cost of FPGA boards is one reason that it is not a popular approach to start an embedded course with digital design and FPGA. However, since FPGA boards are reusable and can be used hundreds of times, their high cost is just a nominal figure on long term use. So, the cost of an FPGA board goes value for money in case of research and development purposes or prototype purposes. But, on considering FPGA boards for production, their high cost may prove a project expensive beyond reach. In such cases, microcontrollers despite low speeds, generic architecture and lack of multi-threading and real-time processing prove to be viable option for the manufacturers.

FPGA development board

Fig. 2: A FPGA Development Board    

High Power Requirement - Most of the FPGA boards are powered by 48 V backplane. The high power requirement and high power drain by FPGA boards make them unsuitable for many embedded applications. On the other hand, most of the microcontroller boards require 5V or 3.3V supply for their operation. This makes the microcontrollers obvious choice for design of any battery operated portable embedded device.

Volatility - The digital design is passed to an FPGA board as configuration data. When the board is powered on, the board is configured accordingly and begin operating thereafter. The configuration data is either stored on a flash memory in master mode or passed by a processor via a boundary scan (JTAG) interface in slave mode. The configuration data is lost once the board is powered off. This volatile nature in most FPGA boards makes them unsuitable for applications where the board may get power interruptions or suffer from power loss.

Start Up Time - The FPGA boards load configuration data every time they are powered on. This adds significant start up time. However, once the configuration data is loaded, an FPGA board can operate faster compared to a microcontroller. But, the start up time in case of FPGA boards leads to their failure in applications that require time critical action instantly after the embedded device is powered up. Due to start up time as well as volatility of configuration data, FPGA boards are not fit for applications where the embedded device goes on and off frequently. Also, it is not possible to keep an FPGA board always powered on within an embedded device due to its high power requirement.

High Pin Count - The FPGA chips have usually high number of pins. That is why, FPGA is not for size constraint embedded applications where the computing processor or controller should be as compact as possible with minimum number of pins. In contrast, there are many microcontrollers available that have 8-pins or even less and so can be easily used in a small gadget or device.  

Complexity - It is not as easy to work on FPGA as on a microcontroller. Before, starting with FPGA, an engineer must have detailed knowledge of digital design and computer architecture. Then, VHDL or Verilog is more complex to learn compared to any high level programming language for software development or even the assembly language. Though, most of the tools required for development in FPGA are available for free and there are many FPGA boards available at reasonable price (around $50), the tools are complex to use and there is still hard choice to make among available FPGA boards. There are also many complications, traps and cautions in digital design that can be learnt only with practical experience.

Design Limitations - With FPGA, it is only possible to interconnect the logic blocks for a digital design. But, there is no control at gate level and usually the synthesis is non-standard. However, FPGA is of great use in testing an architecture or ASIC design at early stage.

Durability - The FPGA ICs have a short life compared to microcontrollers. While microcontrollers can last inside a device for decades, the FPGA chip within an embedded device may require a replacement in 2 or 5 years.   

The high cost, volatility, start up time, high power requirement, high number of pin counts, short lifetime and design limitations despite complex development process has made FPGA chips less common. They are seen only in high power devices that require dedicated architecture, custom peripherals and critical machine code execution through parallel processing.

Conclusion -

Compared to microcontrollers, FPGA chips have their own advantages and disadvantages. It may not be suitable to use FPGA for a generic or common embedded application but FPGA let access and explore the world of integrated circuit designing which is never possible with microcontrollers. An embedded engineer must work on FPGA after considerable experience with microcontrollers and microprocessors. It will let an engineer explore the very in and outs of the digital world. Until working with microcontrollers and processors, an engineer can only think the software way, but after working on FPGA as well, he can think the hardware way too. By working on FPGA, an engineer access the knowledge how actually the software works on processors and controllers.

Like after building a code from scratch, APIs (Application Programming Interfaces) in software development perspective start feeling like easy handles to program.  The same case goes for assembly language or embedded C after VHDL and Verilog. The assembly languages and high level languages for embedded development will start feeling like APIs  once having experience with VHDL and Verilog. So actually, the FPGA and other similar technologies like CPLD complete and complement the embedded engineering discipline.

In the next article, learn about getting started with FPGA.