Skip to content
You Start with one site
Amounts in Start with one site
Engineering · Embedded Systems & Electronics

FPGA and Digital Design with Verilog

You already use UARTs, timers and CPU cores. In nine lessons you build them in Verilog, prove them in simulation, run them on a real FPGA, and take one to a chip layout.

Found this useful?
The 8-bit CPU of lesson 7 after its program: eight instructions in program memory, the state machine of fetch, decode and execute halted on HALT, and the registers pc 7, r0 15, r1 0, r2 3 and r3 1. Five passes of adding three give 15.

A microcontroller runs your instructions one after another. Hardware does everything at the same time, and that one difference trips up almost every programmer who comes to Verilog. A logic bug on a breadboard costs a rewire; the same bug in a chip costs a respin and months. When two unrelated clocks meet, a bug appears that you cannot reproduce.

In this course you describe hardware and prove it correct in simulation before it touches a board. Each lesson builds a block you have only configured before: a state machine, a UART, a FIFO, a small CPU. The last lesson takes a design through the open ASIC flow to a layout you can open and inspect.

How each lesson goes
  1. 1Describe the hardwareModules, wires and registers that all run at the same time.
  2. 2Prove it in simulationA self-checking testbench prints one pass or fail line.
  3. 3Build it for the FPGASynthesis, place and route, pins, then a bitstream.
  4. 4Read the timingPASS at 27 MHz, and how much headroom is left.
You will be able to
  1. Write Verilog that becomes real gates and flip-flops, and prove it with self-checking testbenches
  2. Run a design on an FPGA, meet its timing, and pass data safely between clocks
  3. Build a UART, a FIFO and a small CPU, and take a design through the ASIC flow to a layout

New to this? Know digital logic? Start with lesson 1: gates, a 4-bit adder and a counter, all in simulation.

You need Icarus Verilog and GTKWave for lessons 1 to 3. From lesson 4, a Tang Nano 9K (or an iCE40 board) and the open FPGA tools.

The engineering behind it

When a signal is too fast for a processor, the logic is built in hardware instead.

Lessons
Lesson 1 · 15 minVerilog FundamentalsThe gates you built by hand, then a 4-bit adder and a counter, as Verilog modules in simulation.ModulesWires and registersBlocking and non-blockingHierarchy Lesson 2 · 12 minSimulation and TestbenchesA testbench that walks all 256 input pairs of the adder and prints one pass or fail line.StimulusSelf-checkingWaveformsPlanted bugs Lesson 3 · 14 minState Machines in VerilogA traffic light that keeps time, and the timing bug nearly every first attempt contains.Moore and MealyEncodingTwo-block styleTicks Lesson 4 · 14 minFirst Design on a Real FPGABlink, then a debounced button counter, on a real board, with the timing report read.LUTsPin constraintsDebouncingMax frequency Lesson 5 · 12 minBuilding MCU PeripheralsA PWM generator, a UART transmitter and receiver, and an SPI master, from a counter, a shift register and a small FSM.PWMUARTSPIBaud divisor Lesson 6 · 12 minMemory, FIFOs, and Clock Domain CrossingA dual-clock FIFO that passes data from a 100 MHz writer to a 27 MHz reader.Block RAMMetastabilitySynchronisersGray code Lesson 7 · 11 minBuilding a Mini CPUAn 8-bit CPU with six instructions runs a program: five passes adding three, then it stops at 15.Instruction setDatapathFetch, decode, executeAssembly by hand Lesson 8 · 15 minFPGA and MCU Co-designSplit a motor-control system between an FPGA and a microcontroller, joined by SPI registers.PartitioningSoft coresSPI slaveRegister bank Lesson 9 · 15 minFrom FPGA to ASIC with Sky130 and LibreLaneA counter through the open ASIC flow to a GDSII layout, then the numbers that say if it can be made.Sky130LibreLaneSignoffGDSII
More about this course

Every number has a reason

An FPGA has no notion of seconds, only clock edges. Each number in the Verilog comes from the clock, the protocol or the physics of a flip-flop.

  • 135,000,000 ticksfive seconds of red light at 27 MHz, kept as a parameter, not buried in the logicState machines
  • 234 clocks per bit27,000,000 / 115,200: compute it from the real clock, never an assumed oneUART
  • 256 clocksan 8-bit counter wraps every 256 clocks, so the PWM runs at about 105 kHz whatever the dutyPWM
  • Two flip-flopsa signal that changes inside the setup and hold window leaves one flip-flop undecided for an unpredictable timeClock domains
  • 62.11 MHzthe headroom over a 27 MHz clock; if it drops close to the target, the design is fragileTiming

A microcontroller first. An FPGA when you can name why.

Microcontroller
One thing at a time
  • Decisions, sequencing, connectivity
  • Reflash in seconds
  • Lowest cost and power

The default for most designs.

FPGA
Every block runs every cycle
  • Many parallel channels, custom protocols
  • Cycle-exact timing, in nanoseconds
  • Highest cost, power and effort

When you can name the requirement a microcontroller misses.

The tools

Icarus Verilog and GTKWaveSimulate and read waveforms. Lessons 1 to 3 need no board.
Yosys and nextpnrSynthesis and place and route, with no vendor licence.
Tang Nano 9KAbout 8,600 LUTs and a 27 MHz clock. iCE40 boards also work.
Sky130 and LibreLaneThe open ASIC flow, from RTL to a GDSII layout.
Text you can compareDesigns and testbenches are plain Verilog files.
Windows, Mac and LinuxThe open tools run on every system.

Honest limits. The last lesson ends with a layout you can inspect, not a chip. The routes to real silicon changed in 2025, and the lesson says how to check them.

Before you start

  • Digital logic: gates, Boolean algebra, flip-flops and counters
  • Some programming, for example C on a microcontroller
  • No board for lessons 1 to 3
  • A Tang Nano 9K or an iCE40 board from lesson 4
The full course notes

You already use UARTs, timers, PWM channels, and CPU cores every time you program a microcontroller. This course teaches you to build them. You will describe digital hardware in Verilog, prove it works in simulation, run it on a real FPGA, and finish by pushing a design through the open-source ASIC flow to a manufacturable layout. #fpga #verilog #digitaldesign

What You Will Learn

Describe hardware, not software

Write Verilog that synthesises into real gates and flip-flops. Understand the difference between combinational and sequential logic, blocking and non-blocking assignments, and why hardware is parallel by nature.

Verify before you build

Write self-checking testbenches and read waveforms, so a design is proven correct in simulation before it ever touches a board.

Run it on real silicon

Take a Verilog design through synthesis, place and route, and timing on a low-cost FPGA using a fully open toolchain.

Build the blocks inside an MCU

Create the peripherals you normally take for granted, a UART, a PWM generator, an SPI master, and even a small CPU, from scratch in hardware.

Lessons

Lesson 1: Verilog Fundamentals

Start here. Modules, ports, wires and registers, combinational versus sequential logic, and your first testbench. Practical: recreate logic gates and a 4-bit adder in Verilog and simulate them.

Lesson 2: Simulation and Testbenches

Open lesson. Why you simulate first, testbench structure, stimulus, self-checking assertions, and waveform analysis. Practical: write a self-checking testbench and inspect signals in GTKWave.

Lesson 3: State Machines in Verilog

Open lesson. Finite state machines, Moore versus Mealy, state encoding, and the clean two-block coding style. Practical: a traffic-light controller and a protocol-decoder FSM.

Lesson 4: First Design on a Real FPGA

Open lesson. FPGA architecture (LUTs, flip-flops, block RAM), the open toolchain, pin constraints, and timing. Practical: blink and a debounced counter on an iCE40 board.

Lesson 5: Building MCU-Style Peripherals

Open lesson. PWM generators, UART transmit and receive, SPI, and shift registers in pure hardware. Practical: a UART transmitter and a PWM LED dimmer running on the FPGA.

Lesson 6: Memory, FIFOs, and Clock-Domain Crossing

Open lesson. Inferring block RAM, building FIFOs, metastability, synchronisers, and crossing clock domains safely. Practical: a dual-clock FIFO passing data between two clock domains.

Lesson 7: Building a Mini CPU

Open lesson. Datapath, ALU, register file, program counter, and instruction decode for a tiny instruction set. Practical: an 8-bit CPU that executes a small program from memory.

Lesson 8: FPGA plus MCU Co-Design

Open lesson. When to choose FPGA versus MCU versus DSP, system-on-chip concepts, soft cores, and interfacing an FPGA to an MCU. Practical: an FPGA accelerator that talks to an STM32 or ESP32 over SPI.

Lesson 9: From FPGA to ASIC

Open lesson. The ASIC flow from RTL through synthesis, floorplan, place and route, to GDSII, using the Sky130 PDK and LibreLane. Practical: take an earlier Verilog block all the way to a manufacturable layout.

Prerequisites

Tools and Hardware

Open simulation toolchain

Icarus Verilog for simulation and GTKWave for waveform viewing. Both are free, cross-platform, and used from Lesson 1, so you can complete the first three lessons with no hardware at all.

Open FPGA toolchain

Yosys for synthesis, nextpnr for place and route, and the board flashing tools. A fully open flow with no vendor licences.

A low-cost FPGA board

A Tang Nano 9K (roughly 15 to 20 USD) is the recommended board from Lesson 4 onward, with iCE40 boards such as the iCEBreaker or iCEstick as a documented alternative. Lessons 1 to 3 need no hardware at all.

Open ASIC toolchain

The Sky130 open process design kit and LibreLane, used in the final lesson to turn RTL into a GDSII layout.

Where This Connects

Comes after: Digital Electronics

Digital Electronics and Logic teaches the logic principles this course assumes. Take it first if gates and flip-flops are new to you.

Pairs with: Embedded Programming

Once you have built peripherals in hardware, the STM32 and ESP32 courses show the software side of the same blocks, and Lesson 8 brings the two worlds together.

Feeds into: Sensor and Actuator Interfacing

Custom hardware interfaces connect naturally to the sensor and actuator interfacing course when you need deterministic, high-speed I/O.

© 2021-2026 SiliconWit®. All rights reserved.

9 lessons, in order.

SiliconWit makes these courses. We also run siliconwit.io, a monitoring service.