VHDL Tutorial
Learn VHDL step by step: 37 lessons in 9 chapters with examples, quizzes, diagrams and projects.
Start learning →
of lessons completed
Getting Started
- What Is VHDL? Learn what VHDL is, how a hardware description language differs from software, where VHDL is used (FPGAs, ASICs) and how to think in parallel circuits.
- The VHDL Design Flow and Tools Follow a VHDL design from idea to chip: write, analyze, elaborate, simulate, synthesize, place and route. Meet GHDL, GTKWave, Vivado, Quartus and ModelSim.
- Your First Design: The Half Adder Write your first VHDL design, a half adder: entity, architecture, concurrent assignments and a simple testbench, plus a C truth-table stand-in to check it.
- VHDL Syntax Basics Learn VHDL syntax: case-insensitivity, identifiers, comments, literals, operators and their precedence, and how to read a VHDL file without getting lost.
Entities and Architectures
- Entity Declarations and Ports Learn the VHDL entity declaration: port names, modes in, out, inout and buffer, vector ports, reading output ports, default values and port-naming habits.
- The Architecture Body Understand the VHDL architecture: declarative part, statement part, dataflow, behavioral and structural styles, multiple architectures and configurations.
- Generics and Constants Make VHDL designs reusable with generics and constants: width parameters, default values, generic map, derived constants, ceil log2 and assertions.
- Structural Design and Components Build bigger circuits from smaller ones in VHDL: component declarations, direct entity instantiation, port map styles, hierarchy and a ripple-carry adder.
- Libraries, Packages and Use Clauses Learn how VHDL organizes code: the work and ieee libraries, use clauses, std_logic_1164 and numeric_std, and how to write your own package with types, constants and functions.
Data Types and Signals
- std_logic and Other Basic Types Learn VHDL's basic types: bit, boolean, integer, time, and the nine-valued std_logic with 0, 1, Z, X, U, L, H, W and dash, plus resolution and type conversion rules.
- Signals and Variables Understand the difference between VHDL signals and variables: when updates take effect, scheduled assignments, initial values, scope and which to choose.
- Vectors, Arrays and Slices Work with VHDL buses: std_logic_vector ranges, indexing, slices, concatenation, aggregates with others, array types, 2D arrays and attributes like 'range and 'length.
- Numeric Arithmetic with numeric_std Do arithmetic in VHDL the standard way with numeric_std: unsigned and signed types, to_unsigned, to_integer, resize, overflow, comparisons and shifting.
- Subtypes, Enumerations and Records Define your own VHDL types: subtypes with constraints, enumerations for states and opcodes, records for grouped signals, type attributes and encoding choices.
Concurrent and Sequential Code
- Concurrent Signal Assignments Describe combinational logic in VHDL with concurrent assignments: simple, conditional when/else and selected with/select assignments, multiplexers, decoders and priority logic.
- Processes and Sensitivity Lists Master the VHDL process: how it wakes up, sensitivity lists and process(all), combinational and clocked processes, rising_edge, resets, wait statements and latch traps.
- if, case and Loops in VHDL Write sequential VHDL: if/elsif/else, case with when others, for and while loops, exit and next, and how loops unroll into hardware instead of running over time.
- Generate Statements Create repeated and optional hardware in VHDL with for-generate and if-generate: instance arrays, bus bit-slices, generic-controlled features and case-generate in VHDL-2008.
- Delta Cycles and Simulation Time Understand how VHDL simulation works: simulation time, delta cycles, signal update phases, race-free clock-domain behavior, inertial and transport delays and glitches.
Finite State Machines
- Finite State Machines: Moore and Mealy Learn what a finite state machine is, how Moore and Mealy machines differ, how to draw state diagrams and how the idea maps onto VHDL registers and logic.
- The Two-Process FSM Style Write a clean VHDL state machine with an enumeration type, a clocked state register process and a combinational next-state process, plus a traffic light example.
- State Encoding and Safe Machines Compare binary, one-hot and Gray state encodings in VHDL FSMs, see how many flip-flops each needs and how to recover from illegal states after a glitch.
- A Sequence Detector FSM Design a serial 1011 sequence detector in VHDL as a Mealy and Moore FSM, with state diagram, overlapping detection, and runnable C stand-ins to test it.
Testbenches
- Your First VHDL Testbench Learn what a VHDL testbench is: an entity with no ports, a device under test, signals, stimulus and a simulation clock, with a runnable C model of simulated time.
- Stimulus, Wait and Assert Use wait for, wait until, wait on, assert and report with severity levels to drive inputs and check outputs automatically in a VHDL testbench.
- Clocks, Reset and Self-Checking Testbenches Generate a clock, apply reset, drive a synchronous design and compare it with a reference model in a self-checking VHDL testbench that ends with PASS or FAIL.
- Procedures, Test Vectors and Debugging Structure big VHDL testbenches with procedures, read test vectors from files with textio, debug simulation with waveforms and fix the usual X and U problems.
Synthesis and FPGA
- What Synthesis Does Understand what logic synthesis does with VHDL: the synthesizable subset, elaboration, optimization and technology mapping to LUTs and flip-flops, with C models.
- Inferred Hardware: Registers, Latches and Memories See how VHDL code styles infer flip-flops, latches, multiplexers, shift registers and block RAM, and how to avoid accidental latches with complete assignments.
- Timing and Constraints Learn setup and hold time, critical paths, clock period and slack, how to write a timing constraint, and how to shorten paths with registers in a VHDL design.
- The FPGA Flow, Pins and Your First Board Follow the FPGA flow from VHDL to bitstream: synthesis, place and route, pin constraints, top-level wrapper, switch debouncing, and a first LED blink design.
Design Patterns
- Pipelining for Speed Split long logic paths with pipeline registers in VHDL to raise the clock frequency, understand latency versus throughput and build a pipelined multiply-add.
- Clock Enables and Clock-Domain Crossing Slow parts of a design with clock enables instead of derived clocks, and move signals between clock domains safely with two-flip-flop synchronizers and Gray code.
- FIFOs and Ready/Valid Handshakes Design a synchronous FIFO in VHDL with full and empty flags, then connect producer and consumer with a ready/valid handshake so no data is lost or duplicated.
Projects and Practice
- Project: A Traffic Light Controller Build a complete traffic light controller in VHDL: specification, FSM with per-state timers, pedestrian request, testbench plan and a runnable C model of the design.
- Project: A UART Transmitter Design a UART transmitter in VHDL: frame format, baud-rate tick generator, shift-register FSM, ready/valid interface and a runnable C model that checks the bit stream.
- Practice: An ALU and Exercises Design a parameterized ALU with flags in VHDL using numeric_std, check it against a C reference model, then work through twelve practice exercises with hints.