In this guide, I’m going to walk you through the world of FPGA, an incredible device for implementing digital systems.
This technology isn’t just another method; it’s a game-changer in how you tackle digital system projects, enhancing what you can do in this exciting field.
More...
Don’t have time to read the whole guide right now?
No worries. Let me send you a downloadable PDF so you can read it whenever it’s convenient for you. Just let me know where to send it (takes 5 seconds)
I’ve spent the last 15 years diving deep into FPGA technology, using it for a variety of industrial projects. Each project has revealed more about the incredible potential of FPGAs.
Looking at ongoing global projects and their demands, FPGA stands out as a go-to choice in many cases. So, there’s a growing need for individuals skilled in digital implementation using FPGA.
In the past decade, I’ve interviewed many job candidates for FPGA-related roles in digital implementation at three different companies.
Here’s what I’ve found: there are not enough engineers who know FPGA well, even though it’s a skill that can lead to great job positions and salaries.
So, if you’re aiming to break into this field or boost your career, mastering FPGA is a smart move.
It opens up a lot of doors, whether you’re just entering the job market or aiming to climb higher in your current role.
Even for company managers, understanding FPGA’s potential can lead to more advanced and valuable products.
By the end of this guide, you’ll get a clear picture of what FPGA is and how it’s used.
If FPGA has always seemed like a mysterious topic to you, this is your chance to make a significant professional leap with it.
Now, let’s dive into...
What Exactly Is an FPGA and How Is It Structured?
Remember your digital lab days?
You’d used basic gates like AND, OR, XOR, NOT, and simple chips such as multiplexers, decoders, and flip-flops to build simple digital circuits.
You’d created foundational circuits like adders, counters, and comparators on a breadboard.
Then, you’d test them with tools like a power supply, multimeter, oscilloscope, and sometimes a signal generator.
As you moved to more complex projects, you might have started using microcontrollers like 8051, AVR, or PIC, to implement various routines and functions.
When you were working with gates and basic digital chips, you were essentially building “digital hardware” from the ground up.
But, when you switched to using a microcontroller, you were working with pre-designed “hardware,” that came with its own CPU.
This CPU came with a set of predefined instructions, and you created “software” programs for the microcontroller using these instructions.
So, in the case of microcontrollers, your focus was more on software design.
But why did you need to switch to microcontrollers for more complex routines and algorithms?
The reason is simple: creating such complex systems with just gates and basic chips would have required hundreds, if not thousands, of components.
This approach was impractical due to space limitations on circuit boards and cost concerns.
But is there no efficient way to build a large and complex digital system purely in hardware?
Luckily, there is – and that’s where FPGAs come into play.
Before diving deeper, let’s answer a key question...
What Exactly Is an FPGA?
An FPGA is a special type of chip or IC.
On the outside, it looks pretty similar to other ICs. But the real difference of an FPGA lies inside, not in its external look.
To grasp the concept of an FPGA, let’s look at the following figure.
Here, you see several digital paths made up of various gates. The circuit has three inputs, A, B, and C, and one output, F.
Notice the switches that can alter the signal flow. If the switches are in the state shown in the figure, the output F is:
By changing the state of these switches, you can create new functions. For instance, if we alter the state of switch S1, the output F changes accordingly:
Alright, let’s summarize what we’ve covered so far:
We’ve talked about a collection of digital hardware components, like basic logic gates, along with a set of configurable switches.
By changing the states of these switches, we can create a variety of functions at the system’s output.
In simpler terms, altering these switch states allows us to design different digital circuits directly in hardware.
With this background, we can define FPGAs like this:
What Are FPGAs?
FPGAs are integrated circuits packed with hardware resources, including logic gates and configurable switches. These components enable us to implement a wide range of digital circuits.
Let's dig a bit deeper into the nature of FPGAs.
You might remember from logic circuits, that any logic function can be implemented using memory elements. If that’s a bit hazy, don’t worry, I’ll jog your memory with an example.
Let’s say we want to implement the following three-variable logic function using a memory component:
This function, with three inputs A, B, and C, is a single-bit function. So, there are 2^3=8 different possible states for its inputs.
Each of these states produces either a zero or one at the output. The truth table below shows the output of function F for all possible input combinations.
For instance, if A=1, B=0, and C=1, then the output F equals 1. This specific case is marked in the truth table with a gray background.
There are two main approaches to implementing this function in digital hardware:
1- Using Basic Logic Gates
The diagram below shows how you can build this function using basic logic gates.
2- Using Memory Elements:
For the memory-based approach, you’d use a single-bit memory of eight cells.
This memory has a one-bit output, one-bit input, and a three-bit address line.
Depending on the value (ranging from 0 to 7) you feed into the memory’s address input, the content of the corresponding memory cell is directed to the output.
To implement our example function, we just need to connect the memory address lines to the inputs A, B, and C of the function. The data output of the memory is then used as the output F.
To set this up, we must initialize the memory by storing the values of the function's output (F) for various input combinations, as outlined in the truth table shown earlier.
With this setup, any combination of inputs A, B, and C fed into the circuit will yield an output that matches what we’ve calculated in the truth table.
This memory-based implementation essentially does the same job as the logic gates setup we saw before.
For example, if A=1, B=0, and C=1, the memory will select the sixth cell, and the output F will be 1. This particular case is the one highlighted in gray in the earlier figure.
The key difference between this memory-based approach and using logic gates is flexibility.
By altering the memory’s contents, we can generate new functions, whereas a gate-based circuit is fixed once built.
In FPGA terms, these small memory units used to implement logic functions are known as Look-Up Tables or LUTs.
The way LUTs are built in an FPGA is pretty interesting.
As shown in the figure, by altering the values of A, B, and C (which serve as the memory address lines), one of the memory cells is chosen through 2-to-1 multiplexers and directed to the output.
The red dashed line in the figure indicates how the output is selected when A=1, B=0, and C=1, the scenario we’ve previously highlighted.
Now, at this point, you might wonder, a single LUT can only implement a small function...
How Do We Implement More Complex Circuits?
Let’s imagine you have access to a toolbox with hundreds, maybe even thousands, of LUTs.
Plus, you’ve got a vast network of wires to connect these LUTs in any configuration you choose.
This setup allows you to break down a large circuit into smaller, more manageable functions, with each function being implemented within a LUT.
Then, by strategically connecting these LUTs using the wires, you can piece together the entire main circuit.
In an integrated circuit setting, such as in an FPGA, you obviously can’t physically move the wires around.
Instead, these wires are pre-built within the IC, and you have the flexibility to virtually connect them in various configurations.
Since the optimal wiring layout isn’t known in advance and will vary depending on the circuit you’re designing, a large number of wires are needed between the LUTs.
To facilitate different connections, switch matrices are used. These switch matrices allow you to connect the wires to each other or the LUTs.
The process of figuring out the best path for these wires and connecting them is known as routing.
Imagine an IC crowded with a large number of LUTs and internal wires. The figure below offers a schematic view of such an IC.
You’ll see that the LUTs are arranged in a grid pattern, with numerous wires running between them.
At points where these wires intersect, there’s a network of switches. These switches enable you to connect any intersecting wire to another, simply by programming them.
These switch matrices are digitally controlled, meaning you can program them to connect in various configurations to each other or the LUTs.
With this kind of setup in an IC, you can take a large circuit, divide it into smaller functions, implement each function with an LUT, and then use the programmable switch network to connect these functions appropriately.
This method enables you to implement the desired circuit.
Pro Tip
The IC described in the example above is indeed an FPGA.
An FPGA chip is like a vast ocean of basic hardware resources, all set up to create any digital circuit you can imagine.
Based on what we’ve discussed so far when we say ’hardware resources,’ we’re mainly talking about Look-Up Tables and interconnections (network of wires).
These components are already built into the FPGA chip in a two-dimensional array. By programming the LUTs and the switch matrices, you can implement a wide range of functions.
The process of programming the LUTs and switch matrices to build a circuit in an FPGA is known as configuration.
The real game-changer with FPGAs is their reconfigurability. This means you can reprogram the same FPGA chip over and over to implement different circuits.
But FPGAs aren’t just about LUTs and wires. Sure, these are the primary components you’ll find in an FPGA chip, and they’ve helped us understand the basics of how FPGAs work. Yet, there’s more to them.
You’re probably wondering right now:
How can we break down a digital circuit into smaller functions? And once we’ve done that, how do we implement this decomposed circuit into an FPGA chip?
Don’t worry, I’ll address these questions in a later section of this guide.
For now, let’s zoom in on what’s actually inside a real FPGA and explore the capabilities it offers for implementing digital circuits.
The figure below gives us a glimpse into the inner workings of an FPGA:
Inside an FPGA, you’ll find:
Logic Blocks or Logic Cells (LCs): These are the core building blocks of an FPGA. They’re essentially the LUTs we’ve been talking about.
Each FPGA contains a large number of these LCs.
Although the exact architecture of LCs might vary slightly across different FPGAs, their general structure is quite similar, as shown in the figure below:
As you can see in the figure, an LC is made up of a LUT, a flip-flop, and a multiplexer.
The inclusion of a flip-flop enables the design of synchronous sequential circuits within the FPGA.
Routing Matrix: This resource in the FPGA consists of wires and switch matrices.
As we’ve mentioned before, these can be connected in any configuration you need, either to each other or to the Logic Cells.
I/O Blocks: Right behind each pin of the FPGA, there’s a special circuit known as an I/O Block.
This circuit is programmable, allowing you to use the FPGA pins in various ways: as inputs, outputs, or even both (bidirectional).
Depending on what external devices the pins are connected to, you can set each pin to a specific I/O standard.
For instance, you might adjust the current drive level for output pins or set the I/O voltage level to align with the requirements of the connected device.
Memory Blocks: In digital designs, there’s often a need for temporary storage or RAM.
For example, you might need to store the outcomes of computations for later use, or temporarily hold data generated within the FPGA before sending it to a computer.
Each FPGA includes some pre-built, hardware-based RAM for these kinds of needs.
Multipliers: Multiplication is a frequently used operation in many digital systems, so each FPGA includes several hardware-based multipliers.
While it’s possible to implement multiplication using the LCs and their LUTs, using these dedicated multipliers frees up LC resources for other tasks. Plus, these hardware-based multipliers are much faster compared to those implemented with LUTs.
Clock Resources: In synchronous sequential digital systems, which operate in sync with a clock signal, the clock is incredibly important.
But here’s the thing: an FPGA is a large circuit, and the clock signal needs to travel through long and varied paths to reach every part of the FPGA.
Each path undergoes a different propagation delay, and if you overlook this, it can lead to significant problems in your synchronous circuit.
This is why understanding and managing the FPGA’s clock distribution and its impact is crucial in FPGA-based design.
In FPGAs, the clock resources and the design of clock paths ensure that the clock signal is distributed accurately and synchronously throughout the entire system.
One of the cool features of FPGA clock resources is their ability to generate various frequencies from the main system clock.
Let’s say you have an oscillator on a board with an FPGA that produces a system clock of 50 MHz, but your project needs a clock of 128 MHz.
In an FPGA, you can use a Digital Clock Manager (DCM) in older Xilinx FPGAs or a Mixed-Mode Clock Manager (MMCM) in newer ones to generate the required frequency using the 50 MHz reference.
Basically, you feed the 50 MHz clock into the DCM or MMCM as a reference, and it outputs the new frequency, like 128 MHz, which can then be used as the system clock.
Now that we’ve delved deeper into the nature and structure of FPGAs, let’s explore what we’re really doing when we use them...
Programming or Hardware Design?
Chances are, you’ve worked with a microcontroller at some point, maybe during your university days.
And even if you haven’t, you’ve likely done some programming on your personal computer in a language like C, BASIC, or Pascal.
In all these scenarios, whether it’s programming for microcontrollers or personal computers, you’re interacting with a processor, which includes a CPU.
Each CPU is a piece of pre-built digital hardware that recognizes a specific set of instructions.
For example, a CPU might understand instructions for operations like addition, multiplication, memory transfers, and jumping to a location in memory.
When you’re using a processor, your job is to write software using these pre-defined instructions. So, in essence, when working with microcontrollers and computers, what you’re doing is programming for a processor.
When it comes to FPGAs, it’s a whole different ball game compared to microcontrollers or processors.
Remember, FPGAs are packed with digital hardware resources like LUTs, multipliers, and memory blocks.
But when you first get your hands on an FPGA, these resources don’t have any set function.
Unlike a microcontroller or a processor, there’s no built-in hardware interpreter in an FPGA.
So, at the start, you don’t have any specific, predefined hardware functionality. This means you can’t really "program" an FPGA in the traditional sense.
Imagine you want to add the contents of two registers, A and B. In a microcontroller, you’d just load these values into CPU registers and use an ADD instruction.
But in an FPGA, there’s no ready-made hardware for addition or even registers to hold A and B initially. You have to create these from scratch using the FPGA’s digital resources, like LUTs.
So, when you’re working with an FPGA, you’re actually designing and building hardware, not writing software.
Now that we have a better understanding of FPGAs, let’s dive into a critical question:
What Sets FPGAs Apart From Processors Like AVR, ARM, and DSP?
The differences between FPGAs and traditional processors can be looked at from several angles, some of which you’ve probably picked up from our discussion.
Let me highlight a few key points:
Processors
FPGAs
Now, considering these differences, let’s delve into another important question:
Why Are FPGAs so Fast Compared to Processors?
When it comes to processing speed and executing various control and processing routines, FPGAs generally outpace processors.
This speed difference is a major distinguishing factor between FPGAs and processors.
There are two main reasons for this speed advantage in FPGAs:
1- FPGAs allow a vast number of logic operations to be performed in parallel.
In a processor, assuming there is only one processing core (CPU), only one programming instruction can be executed at a time.
This sequential approach limits how fast algorithms can be executed.
But in FPGAs, it’s a whole different story.
You can perform multiple logic or mathematical operations at the same time because you have the ability to design and implement dedicated hardware for each operation.
FPGAs even allow you to run several complex algorithms concurrently.
Think of it as creating separate mini-hardware units within the FPGA, each handling a different algorithm.
The key here is that these algorithms or functions shouldn’t be dependent on the results of each other to work properly.
The figure below illustrates instruction execution in a processor:
In this setup, the CPU processes one instruction on one piece of data at a time.
For example, it first executes instruction C1 on data D1, then moves on to instruction C2 on data D2.
Now, if these instructions don’t depend on each other’s outcomes, FPGAs can handle them simultaneously.
How? The next figure shows how this processor-based task would look in an FPGA.
In the FPGA, you can create two separate pieces of hardware: one for instruction C1 and another for instruction C2.
Then, you can feed data D1 and D2 to these units at the same time. This parallel processing can vastly speed up the execution of routines and algorithms in FPGAs.
2- Unlike processors, FPGAs don’t have a fixed architecture, so you can customize them precisely for any particular application.
The second factor contributing to the high speed of FPGAs is their flexible architecture.
When using a processor, you’re limited to its CPU and the set of instructions it knows. You have to implement your algorithm with only these limited instructions.
But with FPGAs, since you’re building each piece of hardware from the ground up, you can design it in the most efficient way for your particular needs, optimizing your algorithm for maximum speed.
So, FPGAs have two main strengths: they can perform functions and algorithms simultaneously, and they allow for the optimal design of each function.
These capabilities are what make FPGAs so much faster in running algorithms compared to traditional processors.
By now, you should have a solid grasp of what FPGAs are, how they’re structured, and why they have an edge over processors.
But there’s a big question we haven’t tackled yet...
When working with a processor, we use programming languages to implement routines or algorithms. It’s like using a language to turn an idea in our head into something the processor can understand and execute.
But how does this work with FPGAs?
How do we take a digital circuit we’ve sketched out in our minds or on paper and implement it inside an FPGA?
What tools do we need for that?
So, here’s the big question:
How Do We Describe a Digital Circuit For an FPGA?
There are two primary approaches to accomplishing this task.
The first approach involves using a schematic-based methodology.
In this approach, you draw your circuit design using specialized software tools and then define all the interconnections.
While this might sound easy, it’s not really practical for large circuits.
Imagine trying to draw and manage hundreds of thousands of gates and digital components—it’s a daunting, if not impossible, task.
Even if you managed to draw such a complex circuit, finding and fixing any errors in it would be a massive headache. So, this approach is best left for very small circuits.
So, to describe larger and more complex circuits, we need something else...
Hardware Description Languages (HDLs)
The second method for describing your digital circuit and implementing it on an FPGA is to use a Hardware Description Language.
HDL lets you describe the behavior of digital circuits through its own unique constructs and expressions.
Unlike the schematic approach, HDL can handle the complexity of large circuits, making it the go-to choice for most FPGA designs.
It’s crucial to understand that HDL doesn’t include instructions because instructions are meant for CPUs.
However, in FPGAs, there’s no CPU or even any pre-existing hardware to execute these instructions.
Therefore, HDLs don’t contain instructions as you would typically find in programming languages.
Even though HDLs might look similar to programming languages at first glance, they’re actually all about describing hardware, not providing instructions for a CPU.
To give you a taste of what HDLs are like, let’s take a quick peek at a simple HDL code example.
if C = '0' then F <= A; else F <= B; end if;
At first glance, this code might look like it’s part of a software program, especially with its ’if-then-else’ construct.
The code essentially says: if ’C’ equals ’0’, then ’A’ is assigned to ’F’; else if ’C’ equals ’1’, then ’B’ is assigned to ’F’.
Can you determine which digital logic circuit is described by this code?
You got it! This description corresponds to a 2-to-1 multiplexer, illustrated in the figure below.
So, in this HDL snippet, the "if" condition isn’t a CPU instruction, and the code isn’t a software program. Rather, it’s a way to describe hardware.
When it comes to HDLs for FPGA design, the two big names are VHDL and Verilog.
While they might look different in syntax and structure, both are capable of designing any kind of digital circuit.
FPGA Design Flow
As we touched on earlier, the whole process of digital design with an FPGA is done using specialized software, which enables you to perform the following tasks:
Design Entry
You can input your design into the software using either VHDL or Verilog languages. This is usually done in a text editor.
Simulation
Once you've described your design using an HDL, you need to ensure it functions correctly, and you can do this through simulation.
In a simulation, you typically apply specific inputs to your circuit and expect certain outputs.
By comparing the actual outputs of your designed circuit with your expected outputs, you can determine whether you've implemented the circuit correctly or if there might be a logical error in the design.
Synthesis
Synthesis is the process of implementing the circuit described in HDL, using the hardware resources within the FPGA.
The synthesis tool reads and interprets the VHDL (or Verilog) code, which the designer has written, and builds it using the FPGA’s hardware resources, like LUTs, multipliers, and memory blocks.
Placement
In the placement phase, the specific locations within the FPGA for the hardware resources employed during synthesis are identified.
For instance, if the synthesis process uses 20 out of 4000 available LUTs in an FPGA, the placement process decides exactly which specific 20 LUTs out of the 4000 will be allocated for the circuit implementation.
Routing
After the precise physical locations for each hardware resource used in the design are determined, the next step involves establishing connections between these resources.
This essential task of wiring is performed during the routing phase by specialized software tools.
Configuration
Once we’re done with the synthesis, placement, and routing stages, the outcomes must be loaded onto the FPGA.
How? We generate a binary file, typically with a ’.bit’ extension to configure the FPGA.
But you might wonder, what exactly does this binary file alter in the FPGA when it’s loaded in?
Well, it’s pretty straightforward. The ’.bit’ file determines the content of the LUTs we need for our design. It also lays out all the wiring paths by programming the switch matrices.
Once the FPGA is configured with this file, it is no longer just a chip – it’s transformed into the digital circuit you designed.
FPGA Design Flow Recap
So, in a nutshell, as the digital implementer (that’s you!), you start by describing your circuit using an HDL (design entry).
Then you apply specific inputs to your circuit and compare the actual outputs of your design with your expected outputs to see if your circuit functions correctly (simulation).
The software then implements this description using the hardware resources within the FPGA (synthesis), decides where to place these resources (placement), and then connects them (routing).
The end result of all these steps is then loaded onto the FPGA (configuration) with a configuration file. This turns your FPGA into the digital circuit you’ve described with an HDL.
With all these stages mostly handled by software tools, you might be wondering...
What’s Your Specific Role as the Designer in All This?
As a digital designer and implementer, once you’ve got a solid idea for a digital system and its architecture, there are some key tasks you’ll need to tackle to implement it:
1- Writing Hardware Description Code
Your first task is to write code using one of the HDL languages (VHDL or Verilog). This code is what lays out how your circuit will function.
2- Reviewing Results and Making Adjustments
After the synthesis, placement, and routing stages are done by the software, it’s time to review what it came up with.
Sometimes, the results might not be exactly what you need. Maybe the synthesis process used more resources than your FPGA has, or the circuit’s maximum clock frequency isn’t as high as you need it to be.
You’ll get reports from the software about these issues, and it’s your job to tweak the design to fix these problems.
3- Running Simulations
Before you load your design onto an FPGA, you’ll want to simulate it to make sure it works as expected.
This step is crucial for debugging and resolving any logical errors in your circuit.
4- Final Testing After FPGA Configuration
Once you’ve programmed your FPGA with the .bit file, it’s time for some real-world testing.
There are both software and hardware tools available to help you test your circuit as it runs on the FPGA.
We’ve covered a lot about the design process and the tasks you, as the designer, will handle.
This includes describing the design with HDL, going through synthesis, placement, routing, configuring the FPGA, and finally, simulation and testing.
To successfully implement a digital circuit with an FPGA, you need a mix of skills and software capabilities.
But what’s the bare minimum you need to start working with FPGAs, and how can you begin to build these skills?
What Skills and Tools Do I Need to Get Started?
To get started with FPGAs, here’s what you need to know and have:
Understanding Digital Circuits
Since you’re stepping into the world of hardware design with FPGAs (not software programming), a basic grasp of digital circuits is essential.
You don’t need to be an expert right off the bat; just a foundational understanding of digital logic will do.
As you get more hands-on with FPGAs, you’ll naturally enhance your digital design skills.
Learning an HDL
Your main tool in FPGA implementation is a Hardware Description Language or HDL. Getting familiar with either VHDL or Verilog is a must.
Choosing the Right Software
Next, you’ll need specific software for performing various tasks like synthesis, placement, routing, configuration, simulation, and testing.
Different companies produce FPGAs and their corresponding software tools, so you’ll need to pick one to start with.
Xilinx and Intel (formerly known as Altera) are prominent players in the FPGA industry. In most companies, these are the preferred options.
Looking at their customer base and market presence, Xilinx seems to be the front-runner. So, my recommendation is to initiate your FPGA journey with Xilinx products and software.
Xilinx’s main software for years was ISE. They stopped rolling out new versions after 2013, but it’s still widely used in many companies.
Their newer software is Vivado.
For beginners, I recommend starting with the latest version of ISE. It’s user-friendly and gets you to a practical point in implementation quickly.
Hardware for Hands-On Testing
Once you’re good with an HDL and the ISE software, you’ll be all set to design and simulate various digital circuits.
But to really test your designs, you’ll need a board based on one of Xilinx’s FPGAs. Fortunately, these boards are readily available and reasonably priced.
So, with a basic understanding of digital circuits, knowledge of an HDL, and the right software and hardware, you’ll be well-equipped to start designing digital circuits right from your home, without needing any fancy lab equipment.
What’s Next?
After going through the material we’ve covered, you should now have a good grasp of what FPGAs are, how they’re structured, and the variety of applications they have.
FPGAs are huge in various industries, and with all the investment pouring into this sector, their use is only expected to grow in the future.
If you’re looking to boost your skills in designing and implementing cutting-edge digital systems, and you’re aiming for professional growth and better job prospects, now is a great time to dive into the world of FPGAs.
A great place to start is the FPGATEK website. You can find a lot of free resources there to set you on the right path.
Now is the time to take action.
Thanks for reading, and I’ll talk to you again soon.
- Ahmad
P.S. If you liked what you learned in this article and you want even more in-depth and advanced training for establishing yourself as a prominent figure in the professional FPGA world, then I highly recommend you check out my FPGA Design Blueprint program.
This is THE program that I recommend to anyone looking to break into the exciting world of FPGA and quickly start working on real projects. It’s a complete system that transforms you from a beginner to confidently creating digital systems on actual FPGA boards. It’s everything you need to begin your FPGA adventure.
If this sounds like something you’d find helpful, then click the link below to learn more about the FPGA Design Blueprint.