FPGA Vs Microcontroller: When to use What?
NOTE: This article/blog is Copyright TronicsZone. It cannot be reproduced without prior written approval.
Introduction
Programmable devices such as FPGA, microcontroller, and microprocessor are the most powerful tools available to an electronics engineer today for an Embedded System Design. Knowledge on these devices is essential to a professional, student or hobbyist alike. Working on FPGA or Microcontroller programming allows engineers to completely understand the world of electronic programming. Most of the consumer electronic products currently are designed with microcontroller or FPGA as its central processing unit. From using a single BJT or a single logic device electronics scenario has grown so that we can utilize the performance of millions of transistors and derive thousands of logic’s in a single microcontroller or an FPGA.
Electronic Control and Processing Unit
Electronic devices depend on the central processing unit (CPU) or the control unit. The CPU is like the heart and soul of the whole device. The CPU performs functions like fetch, decode, execute and store. In some cases, the CPU acts as the sole point of communication between the input and the output devices. The overall performance of the device relies on the performance of the CPU. In recent time’s integrated circuits like Microcontrollers, Microprocessors, Application Specific Integrated Circuits (ASIC) and Field programmable Gate Array (FPGA) are preferred to be used as CPU. The selection of a particular IC depends on the application requirement, cost, and performance.
Microprocessor
Microprocessor is an electronic integrated circuit component that works as a CPU alone. No other peripherals such as RAM, ROM, input or output slots are integrated with it. Microprocessor is the basic controlling unit that can be used in an electronic design. If the application is extremely complex and requires a special central control unit, microprocessors are preferred. For example, in computer systems handling advanced robotics or heavy graphics, a dedicated microprocessor is preferred over a microcontroller.
Microcontroller
Microcontroller is an electronic integrated circuit component that combines functions of CPU, RAM, ROM, I/O peripherals on the same board. Microcontrollers are preferred over microprocessors if the application is specific. Example, in an IoT based home automation system microcontroller based boards such as Arduino is preferred over complex microprocessor. Microcontrollers are cheaper than complex microprocessors.
Choosing a Microcontroller over a Microprocessor
Based on the application microcontrollers have some advantages over Microprocessors.
- When the application is low-computational and specific microcontroller is preferred.
- Low cost
- Microcontroller is easy to debug and design
- Robust: Firmware used to program a microcontroller is easy. Open source libraries are available to program a controller. Microprocessor requires an Operating system as in a computer.
Hence in case of specific and simple applications FPGA is preferred over ASIC.
Application Specific Integrated Circuits (ASIC)
As the name suggests ASIC is designed for a sole purpose. For example the CPU in a smart phone is an ASIC. It is designed to work as the smart phone’s CPU and it cannot be reprogrammed to perform any other function. The logic functions in an ASIC cannot be changed to anything else because its digital circuitry is made up of permanently connected gates and flip-flops. The advantages of ASIC over FPGA is that it is cheap since ASIC can be manufactured in large quantities.
Field Programmable Gate Array (FPGA)
It is an integrated circuit that can be programmed on the field to work as per the required design. A FPGA typically contains thousands of Configurable Logic Blocks (CLBs) embedded with a lot of programmable interconnects. The CLBs are made of Look-Up Tables (LUTs), Multiplexers and Flip-Flops. They are programmed to implement complex logic functions. FPGAs also contain dedicated hard-silicon blocks for various functions such as Block RAM, DSP Blocks, External Memory Controllers, Gigabit Transceivers, PLL and many more.
Choosing an FPGA over an ASIC
FPGA has some interesting advantages over ASIC.
- Re-programmable: The Program can be altered anytime. So, an FPGA is reusable
- Robust: Easy to debug and repair. Debugging and reprogramming is almost impossible in an ASIC
- Faster to market: FPGA devices can be launched faster than ASIC, since ASIC requires extensive design steps.
- Usually AISC devices are tested first as FPGA, and only after successful verification, ASIC is designed. FPGA is used as a launch pad for ASIC designs.
Hence in case of specific and simple applications FPGA is preferred over ASIC.
FPGA and Microcontroller
From our previous discussions, it is clear that for consumer specific projects that require customization, FPGA or microcontroller is preferred. Customization is the main advantage of FPGA.
Microcontroller
Microcontroller is a CPU with RAM, ROM, I/O ports and other peripheral devices integrated as one, to perform specific tasks. Some examples of microcontrollers are Arduino microcontroller and Pic Microcontroller.
Programming a Microcontroller
Microcontroller is programmed using assembly language. High-level programming languages are also used such as JavaScript, Python, and C. Steps involved in programming a microcontroller are
- Writing a program code, usually done in C
- Compile the code in a Compiler
- Upload the compiled version of the program to the microcontroller
Microcontroller programming is simple.
Advantages of Microcontroller
- Microcontrollers are simple to program
- Microcontrollers are the best for a simple and hardware specific application. That is if only limited hardware is required
- Microcontrollers are cost effective than FPGA
Disadvantages of Microcontroller
- Microcontrollers can perform limited tasks. Because they have a limited instruction set. The firmware loaded into the controller can make the controller perform only the pre-loaded instructions.
- Microcontroller relies on sequential processing. That is one instruction at a time. Hence programming using interrupts (ISR) becomes complex and hence microcontroller consumes considerable time in executing instructions.
- Hardware is limited. Designer can utilize only the hardware available on the board.
Field Programmable Gate Array
FPGA is an integrated circuit that contains millions of logic gates that can be electrically configured, through programmable interconnects to perform the required task. Xilinx, Intel FPGA packages are available in the market.
Programming a FPGA
FPGA programming is comparatively complex than that of a Microcontroller. FPGA programming requires specialized software such a Xilinx, Intel Quartus. FPGA is programmed using Verilog or VHDL. System Verilog is usually used for verification. FPGA programming follows hardware design flow. Steps in FPGA programming are
- Creating a Verilog code or VHDL code
- Create a module in the software
- Complete pin assignments
- Create an SDC file. SDC file is design constraint file. This file contains timing and design constraints
- Convert netlist into Binary Format
- Place and Route
- Compile the code – Generate a bit file
- Program the FPGA.
- Analyze the report and reprogram.
You can get all of the above done using our reputed FPGA design services.
Advantages of FPGA
- In FPGA the hardware itself is programmable. Meaning new hardware or logical functions can be programed by altering the programmable blocks in the FPGA by installing a new FPGA firmware.
- FPGA does not have a fixed instruction set.
- FPGA process instruction in parallel processing. This capability of FPGAs allows us to control the interrupts effectively by using Finite State Machines (FSMs).
- Trial and error method is possible in FPGA. This allows a steep learning curve.
Disadvantages of FPGA
- It is complex to configure an FPGA. As the designer needs to compile all the codes from scratch and then convert them into machine language.
- Power consumption. Since not all blocks may be utilized for designing an application, FPGA tends to consume more power than a Microcontroller or an ASIC.
- For a simple application, FPGA can be bulky and costly.
- No internal oscillator: Clock for FPGA has to be provided from an external source.
Comparison table: FPGA vs Microcontroller
Criteria | FPGA | Microcontroller |
Flexibility | Hardware and firmware reprogrammable. Superior customization. | Reprogramming is possible in firmware only |
Programming Firmware | Comparatively complex | Simple programming |
Tools | No portability across tools. | Open source tools available |
Cost | Costly | Cost effective |
Processing power/speed | Higher | Lower |
Conclusion
A FPGA can be used if the design requires complex logic and requires high processing ability and if the cost is comparable to the performance achieved. In case of a design that requires limited hardware, and is set to perform only some specific functions, then Microcontroller is preferred. There is no specific criteria to select FPGA or Microcontroller. Each has its own pros and cons. The designer’s discretion based on the design requirement in hand, helps in making the decision of using an FPGA or a microcontroller. We have developed the uncanny ability of choosing the right one for every project we take up here at Tronicszone.
NOTE: This article/blog is Copyright TronicsZone. It cannot be reproduced without prior written approval.