Microcontrollers, embedded systems and FPGAs · Part 36 of 36
FPGAs and hardware description languages
Expert 19 min
How FPGAs implement logic with LUTs and flip-flops, writing Verilog, simulation and synthesis, open-source toolchains and when to choose an FPGA.
What you will learn
- You can explain LUTs, flip-flops and routing in an FPGA.
- You can read and write simple Verilog for combinational and sequential logic.
- You can describe the FPGA design flow and when an FPGA beats a microcontroller.
Before this: UART, I²C and SPI
Hardware you can rewrite
A microcontroller runs instructions one after another. An FPGA (field-programmable gate array) instead becomes the circuit you describe: thousands to millions of small logic blocks wired together by a configurable network. Everything runs truly in parallel, with timing precise to the clock cycle.

Inside an FPGA
- LUTs (look-up tables): a 4- to 6-input LUT is a tiny memory holding the truth table of any function of its inputs — so it can be any gate combination (lesson "Boolean algebra").
- Flip-flops after each LUT store state (lesson "Flip-flops, counters and clocks").
- Programmable routing connects blocks.
- Hard blocks: block RAM, DSP multipliers, PLLs for clocks, high-speed transceivers, sometimes whole processor cores (SoC FPGAs).
Most FPGAs load their configuration from flash at power-up (SRAM-based); some keep it on-chip.
Describing hardware: Verilog
You don't draw gates; you describe them in a hardware description language (Verilog/SystemVerilog or VHDL). It looks like code, but every statement becomes hardware that exists all the time.
// combinational: a 2-input XOR
module xor2(input wire a, input wire b, output wire y);
assign y = a ^ b;
endmodule
// sequential: a 4-bit counter with synchronous reset
module counter(input wire clk, input wire rst, output reg [3:0] q);
always @(posedge clk) begin
if (rst) q <= 4'd0;
else q <= q + 4'd1;
end
endmodule
Key ideas: assign describes continuous logic; always @(posedge clk) describes flip-flops updated on the clock edge; use non-blocking <= in clocked blocks so all flip-flops update together. A for loop in Verilog builds repeated hardware — it doesn't iterate in time.
The design flow
- Write HDL and a testbench.
- Simulate (Icarus Verilog, Verilator, vendor simulators) and look at waveforms — the step most beginners skip and most bugs are found in.
- Synthesise: turn HDL into LUTs and flip-flops (Yosys, vendor tools).
- Place and route onto the specific chip (nextpnr, vendor tools) and check timing (lesson on setup/hold).
- Generate the bitstream and program the FPGA.
Open-source toolchains — Yosys, nextpnr and Project IceStorm/Trellis/Apicula — support Lattice iCE40 and ECP5 and Gowin parts fully, and are increasingly used beyond hobby projects. Vendor tools (AMD Vivado, Intel/Altera Quartus, Lattice Radiant) cover the big devices.

FPGA or microcontroller?
Choose an FPGA when you need massive parallelism or exact timing: many fast I/O channels, custom video or sensor interfaces, real-time signal processing at MHz rates, prototyping a chip (ASIC), or hardware acceleration. Choose a microcontroller for everything else: it's cheaper, uses less power and is easier to program. Many designs combine both, or use an SoC FPGA with built-in processor cores.
Practise without hardware
Ohmforge's Logic designer turns truth tables into minimal circuits, Karnaugh maps and Verilog, and its logic simulator reads a synthesisable Verilog subset, shows timing diagrams and exports VCD files — a good way to try the ideas in this lesson before buying a board.
Try it: Logic gate trainer
Toggle the inputs of a gate, watch the output, and fill in its truth table yourself.
Turn on JavaScript to use this lab. Worked example:
A 3-input XOR is a parity function: the output is 1 when an odd number of inputs is 1 — exactly what assign y = a ^ b ^ c; describes, and what a single LUT in an FPGA implements.
Key points
- FPGAs implement your circuit with LUTs, flip-flops, routing and hard blocks; everything runs in parallel.
- HDLs (Verilog, VHDL) describe hardware:
assignfor logic,always @(posedge clk)with<=for flip-flops. - Flow: HDL + testbench → simulation → synthesis → place and route + timing → bitstream.
- Open toolchains (Yosys, nextpnr) support Lattice and Gowin parts; vendors cover large devices.
- Use FPGAs for parallelism and exact timing; microcontrollers for most other tasks.
Flashcards
- Question: What is a LUT in an FPGA?
- Answer: A small memory storing the truth table of a logic function of its inputs.
- Question: Which Verilog assignment should you use in clocked blocks?
- Answer: Non-blocking (<=).
- Question: What does synthesis do?
- Answer: Turns HDL into a netlist of the FPGA’s logic elements.
- Question: Name two open-source FPGA tools.
- Answer: Yosys (synthesis) and nextpnr (place and route).
Check yourself
Think about your answer, then open it. In the app the quiz is interactive, earns points and brings back what you missed.
Order the FPGA design flow.
Show the answer
Write HDL and testbench → Simulate → Synthesise → Place and route → Generate bitstream
Describe, verify, map to logic, place on the chip, program.
Source: Yosys documentation / Harris & Harris ch. 4
How many different Boolean functions can a 4-input LUT implement?
Show the answer
65536
2^(2^4) = 2^16 = 65,536.
Source: Harris & Harris, 5.6
What does always @(posedge clk) q <= d; describe?
- A D flip-flop
- A combinational XOR
- A latch transparent while clk is high
- A clock generator
Show the answer
A D flip-flop
An edge-triggered assignment infers a flip-flop.
Source: IEEE 1364-2005
When is an FPGA usually a better choice than a microcontroller?
- Many parallel high-speed I/O channels
- Cycle-exact custom timing
- A battery thermometer sending data once an hour
- Prototyping an ASIC
Show the answer
Many parallel high-speed I/O channels; Cycle-exact custom timing; Prototyping an ASIC
A simple low-power sensor suits a microcontroller.
Source: Harris & Harris, 5.6
Sources
- Digital Design and Computer Architecture (RISC-V ed.), Harris & Harris, Morgan Kaufmann, 2021
- MIT OpenCourseWare 6.004 Computation Structures, MIT, 2017
- IEEE 1364-2005 Standard for Verilog Hardware Description Language, IEEE, 2005
- Yosys Open SYnthesis Suite documentation, YosysHQ, 2025
Facts checked on 2026-11-30. Skillgrove lessons are free learning material — no certificate and no accreditation.