Verilog basics

Learn Verilog

Build a practical foundation in digital design, simulation, and self-checking testbenches.

What you will learn

Work through the lessons in order. Each lesson introduces one idea, shows a focused example, explains the important lines, and gives you a practical exercise.

Start with the learning path

Verilog describes hardware behavior. You will learn how modules, signals, combinational logic, sequential logic, and testbenches work together before moving into SystemVerilog and UVM.

Lesson 3 of 7: Signals: wire and reg

Learn which Verilog signal type to use for continuous connections and procedural assignments.

wire and_result;
reg  selected_data;

assign and_result = a & b;

always @(*) begin
  selected_data = select ? b : a;
end

What to notice

  • and_result is a wire because assign drives it continuously.
  • selected_data is a reg because an always block assigns it.
Practice: Declare an 8-bit wire named data_bus and an 8-bit reg named stored_data.

How to study each lesson

  1. Read the concept before copying the example.
  2. Predict the output or waveform before running the simulator.
  3. Change one input, parameter, or statement and observe the result.
  4. Use a self-checking assertion or comparison whenever possible.
  5. Keep the smallest working example as evidence for the next lesson.