Learn / Digital logic / State machines

From Logic Gates to FPGAs and Verilog

ReviewedAdvanced ProAbout 6 min
ABY
In short

From Logic Gates to FPGAs and Verilog: the short answer

An FPGA (field-programmable gate array) is a chip full of small configurable logic blocks, flip-flops, memory and wiring that you connect by loading a configuration file. Instead of placing 74HC chips on a breadboard, you describe the circuit in a hardware description language and the tools build it inside the chip.

Level
Advanced
Time
About 6 min
Topic
Digital logic
You will learn to

Understand what an FPGA is, describe a counter and a state machine in Verilog, and know the simulate, synthesise and program flow.

Before this: State Machines, Binary, Hex and Bits in Practice

An FPGA (field-programmable gate array) is a chip full of small configurable logic blocks, flip-flops, memory and wiring that you connect by loading a configuration file. Instead of placing 74HC chips on a breadboard, you describe the circuit in a hardware description language and the tools build it inside the chip. Unlike a microcontroller, nothing runs step by step: every part of the circuit works at the same time, which makes FPGAs ideal for fast parallel tasks such as video, motor control with precise timing, or custom communication interfaces.

Verilog describes hardware, not a sequence of instructions. A clocked block such as always @(posedge clk) count <= count + 1; describes a register that adds one on every clock edge. The <= (non-blocking) assignment means all registers update together at the edge, just like real flip-flops. Combinational logic uses assign y = a & b; or an always @(*) block. A state machine is a register holding the current state plus a case statement that chooses the next state and the outputs.

The flow has four steps. Simulate first with a testbench (Icarus Verilog and GTKWave are free), because debugging inside a chip is slow. Then synthesise, which turns the code into logic blocks; place and route, which assigns them to locations and checks timing; and finally program the board. Low-cost boards based on Lattice iCE40 and Gowin chips work with the free open-source Yosys and nextpnr tools, and Xilinx and Intel boards with their vendors' free editions. Many Indian universities teach Verilog in a digital design lab, so the same skills carry straight into coursework.

Hardware description, not a program

Verilog describes hardware. Statements do not run one after another; each describes a piece of circuit, and all of them work at the same time. A line such as assign y = a & b describes an AND gate that always exists, and an always block clocked on a rising edge describes flip-flops.

An FPGA is made of small look-up tables, flip-flops and routing, and a design is turned into a configuration for them by synthesis and placement.

Combinational and sequential

Combinational logic depends only on the present inputs. Sequential logic has memory and changes on a clock edge. In clocked blocks use non-blocking assignment (<=), and in combinational blocks use blocking assignment (=) and give every output a value in every case, or the tools create an unwanted latch.

A counter, a shift register and a state machine are the standard building blocks, and most designs are made of them.

Simulate first, then build

Write a testbench that applies inputs and checks the outputs in simulation before programming the chip. The waveform viewer shows what happened at each clock. Check timing reports after building, since a design that works in simulation can fail at the real clock speed. Use the board's single clock and synchronise any external inputs, such as buttons.

Common mistakes
  • Thinking Verilog statements run one after another like a program.
  • Leaving an output unassigned in some case and creating a latch.
  • Skipping simulation and debugging only on the real board.
Advanced lesson · Pro plan

Practise this lesson with Pro

The explanation above is free for everyone. The practice for Advanced lessons in every domain are part of the Pro plan at ₹999 a month.

With Pro you also get: a worked example, a hands-on task, a 3-question check.

Common questions

What will I learn in "From Logic Gates to FPGAs and Verilog"?

Understand what an FPGA is, describe a counter and a state machine in Verilog, and know the simulate, synthesise and program flow.