Seyed Masoud Hosseini · Overview · Study log · Weekly summaries · Ideas · Search · Transcript · RSS feed

FPGA & Verilog Design · Lecture 1 of 12 · 15:20

Part 1: What is an FPGA?

Introduction to FPGA Part 1 - What is an FPGA? | Digi-Key Electronics on YouTube

Study guide

What this lecture covers

This opening lecture in the FPGA and Verilog series answers a basic question: what is a field-programmable gate array, and why would you reach for one instead of a microcontroller, microprocessor, or GPU? It sets up the rest of the series by explaining that an FPGA is made of reconfigurable logic cells you wire together like building blocks, rather than a fixed processor running instructions.

By the end, you should understand the kinds of problems FPGAs are good for, know the difference between Verilog and VHDL, and recognize the stages a design passes through - from writing HDL code to uploading a configuration bitstream to the chip. The lecture is conceptual; no code is written yet.

Key ideas

  • FPGA fabric: an FPGA is a grid of programmable logic cells, plus resources like clock networks and block RAM, that can be wired into custom digital circuits.
  • Soft core processor: you can implement your own processor inside the FPGA fabric using open designs such as RISC-V, and modify its behavior since the source is open.
  • When to use an FPGA: cases include needing peripherals a microcontroller lacks, high-throughput signal processing (filtering, FFT), custom parallel hardware, and prototyping before committing to an ASIC.
  • Hardware description language (HDL): languages like Verilog and VHDL describe circuit behavior, not sequential instructions; most of a design executes concurrently rather than line by line.
  • Verilog vs VHDL: both date to the early 1980s and operate at the register transfer level; Verilog is weakly typed with C-like syntax, VHDL is strongly typed and more verbose.
  • IP blocks: closed-source, pre-built hardware modules (like software libraries) that save you from designing complex functions like DSP filters from scratch.
  • Design flow: HDL code moves through simulation, synthesis, place-and-route, and bitstream packaging before it configures the physical FPGA.

Walkthrough

Intro and what an FPGA is (0:00)

The lecture opens by contrasting common but incomplete answers ("FPGAs are fast", "FPGAs are parallel") with a clearer picture: an FPGA is a collection of logic cells you configure and connect, similar to combining Lego bricks. It walks through example applications - LED cube drivers, communications DSP, the FPGA inside a Mercedes-Benz infotainment system, data acquisition in an oscilloscope, and cryptocurrency mining - to show where custom digital logic outperforms a general-purpose processor.

Digital Signal Processing (DSP) (3:57)

This section summarizes the reasons to pick an FPGA over a microcontroller: building peripherals that don't exist off the shelf, implementing an open soft core processor you can customize down to the instruction set, and creating specialized circuits that compute things like the Fast Fourier Transform in far fewer clock cycles than a general-purpose chip would need. FPGAs are also framed as a practical way to prototype logic before committing to a fixed-function ASIC.

Hardware Description Language (HDL) (7:35)

The lecture introduces HDLs as closer to a markup language than a programming language, since a design is not executed sequentially. It compares Verilog and VHDL, notes that both are register-transfer-level languages, and briefly mentions SystemVerilog (used for test benches) and high-level synthesis tools that convert C, C++, or MATLAB into RTL code. It also explains IP blocks as closed-source, reusable hardware components.

Design Flow (11:13)

The lecture walks through the open-source toolchain used for the rest of the series: writing Verilog, simulating with GTKWave, synthesizing with Yosys into a gate-level netlist, running place-and-route with nextpnr to map the netlist onto the target FPGA, packing the result into a binary with icepack, and uploading it with iceprog. It notes that apio wraps all of these tools together, and that the series targets the low-cost Lattice iCE40 FPGA family, specifically the iCEstick board.

Before you watch

  • Some familiarity with binary numbers and basic logic gates (AND, OR, NOT) will help, since the lecture assumes you know what a digital circuit is.
  • No FPGA hardware or software is required for this episode; it's conceptual.

Check your understanding

  1. Why does the lecture argue that "fast" and "parallel" are incomplete descriptions of what an FPGA offers?
  2. What distinguishes an HDL like Verilog from a traditional sequential programming language?
  3. Name two example applications where the lecture says an FPGA can outperform a microcontroller or GPU.
  4. What are the main stages a Verilog design passes through before it runs on the iCEstick?
  5. What is a soft core processor, and why might you want to implement one in FPGA fabric?

Vocabulary

FPGA (field-programmable gate array) (noun)
A chip made of reconfigurable logic that can be wired into different custom circuits.
An FPGA can be reprogrammed to implement a completely different circuit.
logic cell (noun)
A small, basic building block inside an FPGA that can be configured to perform logic functions.
The FPGA fabric is made of many connected logic cells.
reconfigurable (adjective)
Able to be rewired or reprogrammed to behave differently after manufacturing.
The reconfigurable logic can implement many different circuits.
soft core processor (noun)
A processor design implemented using an FPGA's logic instead of being built as a fixed chip.
A soft core processor can be customized because its design is open.
microcontroller (noun)
A small, self-contained computer chip designed for simple embedded tasks.
An FPGA can be a better fit than a microcontroller for certain tasks.
signal processing (noun)
Manipulating and analyzing signals like audio, video, or radio data.
FPGAs are often used for fast signal processing.
Fast Fourier Transform (FFT) (noun)
An algorithm that converts a signal from time into frequency components quickly.
FPGAs can compute a Fast Fourier Transform in very few clock cycles.
ASIC (noun)
A chip custom-built for one specific purpose, unlike a reprogrammable FPGA.
Engineers often prototype a design on an FPGA before building an ASIC.
hardware description language (HDL) (noun)
A language used to describe the structure and behavior of digital hardware.
Verilog is a common hardware description language.
concurrently (adverb)
Happening at the same time, rather than one after another.
Most of an HDL design executes concurrently, not line by line.
register transfer level (RTL) (noun)
A description style for hardware that specifies how data moves between registers each clock cycle.
Verilog and VHDL both operate at the register transfer level.
IP block (noun)
A pre-built, ready-to-use hardware module included in a design.
An IP block saves you from designing a complex filter from scratch.
synthesis (noun)
The process of converting an HDL design into an actual gate-level circuit.
Synthesis turns the Verilog code into hardware logic.
place-and-route (noun)
The step where a synthesized circuit's parts are positioned and wired on the actual chip.
Place-and-route maps the design onto the physical FPGA.
bitstream (noun)
The final binary file that configures an FPGA's hardware.
The bitstream is uploaded to program the FPGA.
microprocessor (noun)
A general-purpose chip that runs software instructions one after another.
An FPGA differs from a microprocessor by not running fixed instructions.
clock network (noun)
The wiring inside a chip that distributes the clock signal to all its parts.
The FPGA fabric includes clock networks alongside its logic cells.
high-throughput (adjective)
Able to process a large amount of data quickly.
FPGAs suit high-throughput signal processing tasks.
prototype (verb)
To build an early test version of something before the final design.
Engineers prototype logic on an FPGA before committing to an ASIC.
weakly typed (adjective)
Allowing values of different kinds to be mixed without strict checking.
Verilog is weakly typed compared to VHDL.
strongly typed (adjective)
Requiring strict matching between the types of values used together.
VHDL is strongly typed and more verbose than Verilog.
verbose (adjective)
Using more words or code than strictly necessary.
VHDL is generally more verbose than Verilog.
markup language (noun)
A language that describes structure or formatting rather than a sequence of actions.
An HDL is compared to a markup language rather than a program.
high-level synthesis (noun)
A tool that automatically converts software code into hardware description code.
High-level synthesis can turn C or MATLAB code into RTL.
outperform (verb)
To do something better or faster than something else.
Custom logic can outperform a general-purpose processor at some tasks.
off the shelf (phrase)
Already made and ready to buy, rather than custom built.
Some peripherals just don't exist off the shelf for a microcontroller.
closed-source (adjective)
Not sharing its internal design or code publicly.
IP blocks are usually closed-source hardware modules.
data acquisition (noun)
The process of capturing and recording measurements from the real world.
An oscilloscope relies on fast data acquisition circuitry.
custom (adjective)
Made specifically for one particular purpose rather than general use.
An FPGA can implement custom parallel hardware.

Chapters

From the YouTube description

A field-programmable gate array (FPGA) is an integrated circuit (IC) that lets you implement custom digital circuits. You can use an FPGA to create optimized digital logic for things like digital signal processing (DSP), machine learning, and cryptocurrency mining. Because of the FPGA’s flexibility, you can often implement entire processors using its digital logic. You can find FPGAs in consumer electronics, satellites, and in servers used to perform specialized calculations.

In this series, we will see how an FPGA works and demonstrate how to create custom digital logic using the Verilog hardware description language (HDL).

In this first episode, we examine why you might use an FPGA over other solutions, such as a microcontroller. Additionally, we present several example FPGA applications and cover the basic design flow for creating a digital design in an FPGA.

A written version of this video can be found here: https://www.digikey.com/en/maker/projects/introduction-to-fpga-part-1-what-is-an-fpga/3ee5f6c8fa594161a655a9f960060893

All code examples and solutions for this series can be found here: https://github.com/ShawnHymel/introduction-to-fpga

You will need an iCE40 development board for this series. Any of the boards supported by apio https://github.com/FPGAwars/apio#supported-boards should work. That being said, I recommend the iCEstick https://www.digikey.com/en/products/detail/lattice-semiconductor-corporation/ICE40HX1K-STICK-EVN/4289604 , which is what I will use in the videos. You will also need a breadboard, jumper wires, and some pushbuttons.

An FPGA is made up of many programmable logic blocks (PLBs) that can be configured and connected together to create a large number of digital circuits. You create your desired digital circuit using an HDL (we will use Verilog). The synthesis tool converts your HDL into a gate-level representation of the circuit. The place-and-route tool converts that representation into actual configuration information for your particular FPGA.

Throughout the series, we will use the apio tool https://github.com/FPGAwars/apio to manage the build and upload process. Apio relies on underlying tools to complete these steps:

- Synthesis: http://yosyshq.net/yosys/
- Simulation: http://gtkwave.sourceforge.net/
- Place and route: https://github.com/YosysHQ/nextpnr
- Package: icepack as part of Project IceStorm: https://github.com/YosysHQ/icestorm
- Upload: iceprog as part of Project IceStorm: https://github.com/YosysHQ/icestorm

Many times, a microcontroller, microprocessor, or graphics processing unit (GPU) is capable of accomplishing the job. However, you sometimes need custom digital logic for your particular application, which is where an FPGA can be helpful. Here are some potential applications:

- Parallel I/O operations
- Data acquisition (DAQ)
- Specialized computations
- Custom processor

Note: while yosys officially supports Verilog-2005, you can find other open source tools capable of synthesizing other HDLs. For example the GHDL project https://github.com/ghdl/ghdl supports VHDL.

In the next episode, we will install the apio toolset and upload our first FPGA design.

Product Links:
https://www.digikey.com/en/products/detail/lattice-semiconductor-corporation/ICE40HX1K-STICK-EVN/4289604

Related Videos:
https://www.youtube.com/watch?v=z8Oldd-nrfs
https://www.youtube.com/watch?v=5kNXX67mchE
https://www.youtube.com/watch?v=iwcxLQ6AB88

Related Project Links:
https://www.digikey.com/en/maker/projects/introduction-to-fpga-part-1-what-is-an-fpga/3ee5f6c8fa594161a655a9f960060893

Related Articles:
https://www.digikey.com/en/pdf/r/renesas-electronics-america/powering-fpga-applications
https://www.digikey.com/en/videos/d/dsp/edge-machine-deep-learning-on-fpga
https://www.digikey.com/en/product-highlight/l/lattice/ice40-fpga-family-developmental-solutions

Learn more:
Maker.io - https://www.digikey.com/en/maker
Digi-Key’s Blog – TheCircuit https://www.digikey.com/en/blog
Connect with Digi-Key on Facebook https://www.facebook.com/digikey.electronics/
And follow us on Twitter https://twitter.com/digikey

Part 2: Getting Started with Yosys, IceStorm, and Apio →