Skip to content
Tutorials Center
My learning

Topics

Verilog and SystemVerilog Tutorial

Learn Verilog and SystemVerilog step by step: 37 lessons in 9 chapters with examples, quizzes, diagrams and projects.

Start learning →

of lessons completed

Getting Started

  1. 1 What Is Verilog? Hardware Description Languages Understand what Verilog and SystemVerilog are, how a hardware description language differs from software, and what a simulator and a synthesizer do with your code.
  2. 2 The Verilog Design Flow: From Idea to Chip Walk through the hardware design flow: specification, RTL coding, simulation, synthesis, place and route, timing and programming an FPGA, and how to install free tools.
  3. 3 Your First Verilog Module: A Half Adder Write, read and test your first Verilog design: a half adder module with ports, assign statements, a small testbench, and a C stand-in that checks the truth table.
  4. 4 Verilog Syntax Basics: Tokens, Comments and Naming Learn the lexical rules of Verilog: whitespace, comments, identifiers, keywords, case sensitivity, compiler directives, system tasks and the style habits that keep code clean.

Modules and Data Types

  1. 5 Verilog Modules, Ports and Parameters Learn how Verilog modules are declared and instantiated: port directions, ANSI port style, named connections, parameters, localparam, hierarchy and a runnable C parameter stand-in.
  2. 6 wire, reg, integer and Other Verilog Data Types Understand Verilog nets and variables: wire versus reg, the four logic values 0 1 x z, integer, real, time, tri-state, and a runnable C model of four-state signals.
  3. 7 Verilog Numbers, Literals and Sizes Master Verilog number literals: size, base and value syntax, binary, hex, decimal, x and z digits, underscores, signed literals, truncation and extension, with runnable C checks.
  4. 8 Verilog Vectors, Bit-Selects and Concatenation Learn Verilog vectors: declaring buses, selecting bits and slices, indexed part-selects, concatenation and replication, endianness and arrays, with runnable C bit-manipulation checks.
  5. 9 Verilog Operators: Bitwise, Logical, Reduction and More A complete guide to Verilog operators: arithmetic, bitwise, logical, reduction, shift, relational, equality with x and z, conditional and precedence, with runnable C equivalents.

Combinational Logic

  1. 10 Continuous Assignments with assign in Verilog Learn how the Verilog assign statement describes combinational logic: continuous assignment, expressions, conditional muxes, implicit wires, multiple drivers and delays.
  2. 11 Gate-Level Primitives in Verilog Use Verilog's built-in gate primitives and, or, nand, nor, xor, xnor, not, buf and tri-state buffers: syntax, multiple inputs, instance arrays, delays and when to prefer assign.
  3. 12 Combinational always Blocks: if, case and always @* Write combinational logic in procedural always blocks: sensitivity lists, always @*, always_comb, if/else, case, casez, default values, avoiding latches and a runnable C model.
  4. 13 Multiplexers, Decoders and Encoders in Verilog Design the classic data-routing blocks in Verilog: multiplexers, demultiplexers, decoders, encoders and priority encoders, with code, wide-bus examples and runnable C models.
  5. 14 Adders, Subtractors and a Simple ALU in Verilog Build arithmetic hardware in Verilog: ripple-carry adders, carry-lookahead idea, subtractors with two's complement, comparators, flags and a simple parameterized ALU, with C models.

Sequential Logic

  1. 15 Flip-Flops and always @(posedge clk) in Verilog Learn sequential logic in Verilog: how clocked always blocks describe D flip-flops, registers with enable, edge detection, always_ff, setup and hold timing, with a runnable C clocked-state model.
  2. 16 Blocking vs Non-Blocking Assignments in Verilog Understand Verilog's two procedural assignments: how = and <= are scheduled, why flip-flops need non-blocking, the shift-register trap, race conditions and the golden coding rules.
  3. 17 Synchronous and Asynchronous Reset in Verilog Compare synchronous and asynchronous resets in Verilog, write registers with active-low reset, learn reset recovery, a reset synchronizer, and when a register needs no reset at all.
  4. 18 Counters and Shift Registers in Verilog Design the workhorse sequential blocks in Verilog: binary, up/down, modulo and Gray counters, clock dividers, shift registers, ring and Johnson counters and LFSRs, with C models.
  5. 19 Register Files, RAM and ROM in Verilog Model storage in Verilog: register files, synchronous single and dual-port RAM, ROM with initial contents, read-during-write behavior, latches versus flip-flops and a small FIFO, with C models.

Testbenches

  1. 20 Your First Testbench Learn what a Verilog testbench is, how it instantiates a design under test, drives inputs with initial blocks and delays, and why it has no ports or synthesis.
  2. 21 Stimulus and System Tasks Drive a Verilog design with delays, loops and exhaustive stimulus, and print results with $display, $write, $monitor, $strobe, $time and format specifiers.
  3. 22 Self-Checking Testbenches Build self-checking Verilog testbenches with reference models, check tasks, error counters and pass/fail summaries instead of reading waveforms by eye.
  4. 23 Clocks, Resets, Memories and Files in Testbenches Generate clocks and resets in a Verilog testbench, avoid races at clock edges, load test vectors with $readmem and $fopen, and dump waveforms with $dumpvars.

FSMs and Design

  1. 24 Moore and Mealy State Machines Learn finite state machines in Verilog: states, transitions, Moore and Mealy outputs, state diagrams, and a 101 sequence detector written both ways.
  2. 25 FSM Coding Styles and State Encoding Compare one-, two- and three-process Verilog FSM styles, learn binary, Gray and one-hot state encoding, default states and safe recovery, with a traffic light example.
  3. 26 Datapath and Controller Design Split a Verilog design into a datapath of registers and operators and an FSM controller, with a shift-and-add multiplier and a GCD calculator as worked examples.

SystemVerilog Features

  1. 27 SystemVerilog Data Types: logic, enum, struct and typedef Learn the SystemVerilog data types that replace reg and wire: logic, bit, int, typedef, enum, packed struct, unions and arrays, with C stand-ins for packing.
  2. 28 always_comb, always_ff, Packages and Functions in SystemVerilog Use SystemVerilog always_comb, always_ff and always_latch to state your intent, write unique and priority case statements, and share types and functions with packages.
  3. 29 Interfaces, Modports and Clocking Blocks Bundle signals with SystemVerilog interfaces, restrict direction with modports, share tasks, connect testbenches with virtual interfaces and avoid races with clocking blocks.
  4. 30 Classes and Constrained Randomization Learn SystemVerilog classes for verification: objects, inheritance, rand and randc variables, constraints, randomize(), mailboxes, covergroups and a mini scoreboard.

Synthesis and Verification

  1. 31 The Synthesizable Subset and Common Pitfalls Learn which Verilog constructs synthesize into hardware and which are simulation-only, plus classic bugs: latches, blocking versus non-blocking, width and sign mismatches.
  2. 32 Timing, Metastability and Clock Domain Crossing Understand setup and hold time, critical paths and maximum clock frequency, metastability, two-flop synchronizers, Gray-coded pointers and handshakes for clock domain crossing.
  3. 33 Assertions (SVA) and Functional Coverage Write SystemVerilog assertions with immediate and concurrent assert, property, sequence, implication and delays, and measure test quality with cover and covergroups.

Projects and Practice

  1. 34 Project: An 8-bit ALU with Flags and a Testbench Design an 8-bit Verilog ALU with add, subtract, logic and shift operations and zero, negative, carry and overflow flags, then verify it against a reference model.
  2. 35 Project: A UART Transmitter and Receiver Build a UART in Verilog with a baud rate generator, an 8N1 transmitter FSM and a receiver that samples mid-bit, and study the frame format with C stand-ins.
  3. 36 Project: A Synchronous FIFO Design a synchronous FIFO in Verilog with read and write pointers, full and empty detection using an extra pointer bit, a self-checking testbench and a depth calculation.
  4. 37 Practice: Verilog Exercises and Interview Questions Twelve Verilog practice problems with solutions and common interview questions: encoders, parity, Gray code, LFSR, edge detector, debouncer, clock divider and more.