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 2 of 7: Modules and Ports

Create a reusable hardware block and connect signals through named input and output ports.

module and_gate (
  input  wire a,
  input  wire b,
  output wire y
);

  assign y = a & b;

endmodule

What to notice

  • input ports carry signals into the module.
  • output ports carry results out of the module.
  • assign continuously drives y whenever a or b changes.
Practice: Change the expression to a | b and verify that the module now behaves as an OR gate.

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.