FPGA programming has been gaining momentum lately as it offers considerable benefits. It allows you to offload resource-hungry tasks to hardware and thus increase performance. FPGAs can be programmed and reprogrammed according to current needs, which is very cost effective in the long run.
In this article, I explain what an FPGA is, how it can be programmed and how it can be used.
A field-programmable gate array (FPGA) is an integrated circuit that can be programmed for a specific use after it has been manufactured. It may seem similar to microcontrollers and central processing units (CPUs), but the difference is quite significant. Both microcontrollers and CPUs can be programmed using a specific instruction set. But actually, the instruction set is sealed by the manufacturer. However, FPGAs, thanks to adaptive logic modules (ALMs) and programmable interconnects, can be customized to perform specific computing tasks using boolean logic.
All computers are machines that utilize continuous, electrical signals to perform operations using boolean logic. In boolean logic, there are only two values a variable can be assigned: true and false. The first programmable logic circuits were very simple and contained only logic gates. Thanks to De Morgan’s laws, this was enough to perform arbitrary logic functions where zeros and ones were the inputs and outputs. With time, programmable circuits have become more and more powerful. In programmable circuits, you program logic modules that can work as registers, adders, multiplexers or lookup tables.
Each module consist of a programmable lookup table that implements arbitrary boolean operations with a specific number of inputs and outputs, multiplexers (switching elements that select one of the input paths depending on a condition), adders (implementing fast additions and subtractions without engaging combinational logic) and registers (utilized to store boolean values). How the cells work can be changed while the circuit is working. A circuit can be reprogrammed to perform different functions; for example, that of a processor in the ARM architecture, a network interface card, or a video encoder, to name just three.
An adaptive logic module is depicted below.
Fig. 1 Adaptive Logic Module of an Altera/Intel FPGA (source)
FPGA logic modules are connected by routing channels. Some FPGAs’ specific manufacturer models can include static and dynamic on-chip memories, transceivers, and clock-generating modules (particularly PLLs).
In addition, in FPGAs, there are ready components, such as CPU cores, memory controllers, USB controllers, or network cards. These are so popular that there is no need to implement them in the FPGA structure. A contemporary, complex FPGA is depicted below.
Fig. 2 Contemporary, complex FPGA chip (source)
Below, there is a short list of main FPGAs benefits:
- Long-term availability – An FPGA’s functionality lies in its configuration, not in the module itself.
- Shorter time-to-market – with an FPGA on board it is possible to develop the prototypes more quickly in cases when the hardware development relies on the IP core’s design.
- Acceleration – An FPGA enables higher speeds compared to solutions based on general purpose processors.
First and foremost, FPGAs are used to design application-specific integrated circuits (ASICs). First, you design the architecture of such a circuit. Then, you use an FPGA to build and check its prototype. Errors can be corrected. Once the prototype works as expected, an ASIC project is created and manufactured based on the FPGA design. This allows you to save time, as manufacturing an integrated circuit can be a very complex and time-consuming process. It also saves money, as one FPGA can be used to prepare many iterations of the same project. In this context, it is worth mentioning that modern tensor processing units (TPUs) or cryptocurrency miners were first designed as FPGAs and manufactured only after maturing.
FPGAs are also used in real-time systems where response time plays a crucial role. In standard CPUs, response time is not predictable and you do not know precisely when you will receive a response after the trigger appears. To keep the response time within a given range, real-time operating systems are used. Still, in the scenarios where a fast response time (milliseconds or less) is necessary, this falls short. To solve this problem, the requested algorithm needs to be implemented in an FPGA using combinational or sequential logic to ensure a response time that is always the same. Such a real-time system implemented in an FPGA can be modified and moved into manufacturing once it is ready. An integrated circuit created in this way will be much faster and more energy-efficient.
Furthermore, FPGAs are used in projects where hardware configuration is subject to change and a circuit that can be adjusted to these changes is called for. If you change your hardware suppliers and the new hardware does not have the required interface, an FPGA becomes a natural choice.
Apart from that, there is a specific use case where the use of FPGAs shows the most benefits.
Hardware acceleration is the main FPGA use case. In a nutshell, repetitive and computer-intensive tasks are offloaded from general purpose CPUs to dedicated hardware. Enabling display graphics, graphics processing units (GPUs) are the most popular and widely-used hardware for this type of operation. Of course, they can also be used to perform computations, but only of a specific type. In data processing, there are tasks where both CPUs and GPUs fail to meet the requirements, but FPGAs excel.
For hardware acceleration, FPGAs may be utilized in two different ways. The first doesn’t differ from the way GPUs are used. Using interconnects implemented both on FPGAs and the host machine, such as PCI Express, you may feed the design on the FPGA with the input data and receive the processed output. The other way is to utilize an FPGA in a standalone configuration, where the design itself is responsible for receiving input, processing it and sending output. For this use case, many vendors offer families of self-contained FPGAs that implement CPU cores, transceivers, memory controllers and network interfaces on the chip.
Software-Defined Networking (SDN) is a typical use case for hardware acceleration using FPGAs. The basic concept behind SDN is the separation of the control plane—the layer where the network behavior is defined and managed—from the data plane, the layer where the packets are processed. This approach allows you to control the entire network from a single point and have a good view of the network topology. This all means better decision-making (e.g. about more efficient load balancing or better traffic distribution), not only minimizing the risk of mistakes being made but also saving time, as you don’t have to manually configure hundreds of devices.
Usually, operations on network packets such as network address translation, routing packets, tunnel termination, applying flow classification and filtering mechanisms, metering and shaping are performed on CPUs. Using a SmartNIC - an intelligent network interface card - allows you to offload these operations to an FPGA, thereby freeing up the CPU resources to focus on primary tasks.
When using a SmartNIC in an SDN solution, you can offload some virtualized network functions (VNFs), such as firewalls, to hardware. The control plane defines policies, while the data plane, i.e. the SmartNICs, applies these policies to packets and decides which of them should be blocked or passed. IPSec (packet encryption) and VPN are other use cases for SmartNICs. But you’ll gain the most impressive range of options by offloading virtual switches and routers. These include implementing all of the above functions, including firewalls, tunneling, and encryption, as well as more complex tasks like routing and NAT.
Going forward, the FPGA market is set to expand. Major manufacturers of standard CPUs are expanding their product portfolio by acquiring companies specializing in FPGAs. In 2015, Intel bought Altera, a US-based manufacturer of programmable logic devices (PLDs), while last year AMD acquired Xilinx, the company that invented FPGA architecture.
FPGAs will also be more widely used in networking. Apart from programmable logic cells, they will contain highly specialized silicon elements, i.e. network interface controllers. You can also expect network-specific circuits to be developed.
From the developer’s point of view, FPGA circuits contain more logic gates, allowing us to implement more complex functionalities. You will be able to put more network functionalities in a single circuit or piece of hardware equipment. Of course, this will make the entire implementation more complex too.
FPGA programming is not a new solution, but now businesses are uncovering its potential on a larger scale. It allows for developing architecture with a flexibility that can meet more specific project requirements.
Do you want to implement FPGA programming in your company to achieve the best possible results? Trust the experts – at CodiLime, we have completed many FPGA-focused projects. Yours could be next.
Original post date 04/30/2021, update date 08/02/22.