FPGATEK Get Started With FPGA in 20 Minutes
FPGATEK Get Started With FPGA in 20 Minutes
FPGA
IN 20 MINUTES
BY AHMAD SAGHAFI
Get Started With FPGA
In 20 Minutes
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.
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.
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.
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.
As you moved to more complex projects, you might have started using
microcontrollers like 8051, AVR, or PIC, to implement various routines and
functions.
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.
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.
But is there no efficient way to build a large and complex digital system
purely in hardware?
On the outside, it looks pretty similar to other ICs. But the real difference
of an FPGA lies inside, not in its external look.
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
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:
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.
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.
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 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.
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 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.
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.
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.
The process of figuring out the best path for these wires and connecting
them is known as routing.
You’ll see that the LUTs are arranged in a grid pattern, with numerous
wires running between them.
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.
An FPGA chip is like a vast ocean of basic hardware resources, all set up
to create any digital circuit you can imagine.
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.
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.
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:
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.
Routing Matrix: This resource in the FPGA consists of wires and switch
matrices.
I/O Blocks: Right behind each pin of the FPGA, there’s a special circuit
known as an I/O Block.
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.
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.
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.
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.
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.
PROGRAMMING OR HARDWARE
DESIGN?
And even if you haven’t, you’ve likely done some programming on your
personal computer in a language like C, BASIC, or Pascal.
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.
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.
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.
So, when you’re working with an FPGA, you’re actually designing and
building hardware, not writing software.
There are two main reasons for this speed advantage in FPGAs:
In this setup, the CPU processes one instruction on one piece of data at a
time.
How? The next figure shows how this processor-based task would look in
an FPGA.
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.
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.
HOW DO WE DESCRIBE A
DIGITAL CIRCUIT FOR AN FPGA?
In this approach, you draw your circuit design using specialized software
tools and then define all the interconnections.
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.
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.
To give you a taste of what HDLs are like, let’s take a quick peek at a
simple HDL code example.
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?
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.
Simulation:
Once you've described your design using an HDL, you need to ensure it
functions correctly, and you can do this through simulation.
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.
Configuration:
Once we’re done with the synthesis, placement, and routing stages, the
outcomes must be loaded onto 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.
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...
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.
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.
But what’s the bare minimum you need to start working with FPGAs, and
how can you begin to build these skills?
To get started with FPGAs, here’s what you need to know and have:
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.
Xilinx and Intel (formerly known as Altera) are prominent players in the
FPGA industry. In most companies, these are the preferred options.
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.
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.
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.
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.
- Ahmad
ps. If you liked what you learned in this ebook 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.
If this sounds like something you’d find helpful, then click the link below
to learn more about “The FPGA Design Blueprint”.