Module

Module 4: Introduction to Verilog HDL

28 lessons
Start

Modules 1, 2, and 3 covered digital hardware fundamentals: truth tables, Boolean minimization, arithmetic units, flip-flops, and finite state machines.

Module 4 introduces Verilog Hardware Description Language (HDL). Verilog allows digital engineers to model, simulate, and synthesize complex digital circuits using structured text files.

The Hardware Modeling Mindset

Verilog is not a procedural software programming language.

A software program (such as C or Python) executes sequential instructions on a microprocessor. In contrast, a Verilog source file describes physical hardware: logic gates, signal wires, registers, and clock nets.

When an Electronic Design Automation (EDA) tool synthesizes Verilog code, it constructs a permanent digital circuit. All components operate concurrently in real hardware.

Engineers must interpret each line of Verilog code as an arrangement of physical hardware components.

Expected Learning Outcomes

By completing this module, you will design and verify:

  • A gate-level digital network using structural modeling and primitive logic gates.
  • A parameterized $N$-bit ripple-carry adder using continuous assignment dataflow modeling.
  • A 4-to-1 multiplexer implemented across structural, dataflow, and behavioral styles.
  • A 3-to-8 binary decoder with an automated verification testbench.
  • An 8-operation combinational Arithmetic Logic Unit (ALU).

Module Structure

Figure 1 outlines the five sections of Module 4:

Module 4 map
Figure 1: Conceptual map of the five sections comprising Module 4

Section Focus Area Key Technical Topics
4.1 Why HDL Evolution of HDLs, simulation versus synthesis, RTL design flows
4.2 Verilog Basics Module ports, wire and reg data types, vectors, literals, parameters
4.3 Operators Arithmetic, bitwise, logical, reduction, shift, and concatenation operators
4.4 Structural Modeling Primitive gate instantiation, port mapping, and hierarchical interconnects
4.5 Dataflow Modeling Continuous assignment (assign), conditional operators, and style selection

This course uses open-source simulation tools:

  • Icarus Verilog (iverilog): Compiles and simulates Verilog HDL designs.
  • GTKWave: Displays digital signal waveforms from Value Change Dump (.vcd) files.

Installation Instructions

macOS (using Homebrew):

brew install icarus-verilog
brew install --cask gtkwave

Ubuntu / Debian Linux:

sudo apt-get install iverilog gtkwave

Verify the installation by running iverilog -V.

Standard Simulation Workflow

Simulate any Verilog module using three terminal commands:

# 1. Compile the design module and verification testbench
iverilog -o sim tb_module_name.v module_name.v

# 2. Execute the compiled simulation binary to generate the waveform file
vvp sim

# 3. Open the waveform viewer to inspect signal transitions
gtkwave dump.vcd

The testbench must invoke the $dumpfile("dump.vcd") and $dumpvars system tasks to generate the output waveform file.

HDL Coding Conventions

All course code conforms to standard conventions:

Category Standard Convention Example
Design Files Lowercase snake_case with .v extension full_adder.v
Testbench Files Prefix tb_ followed by module name tb_full_adder.v
Timescale Directive First line of every source file `timescale 1ns / 1ps
Nettype Directive Second line of every source file `default_nettype none
Identifier Names Module and signal names use snake_case carry_out, data_in
Parameter Names Parameters and constants use UPPER_CASE DATA_WIDTH, RESET_VAL

The directive `default_nettype none is essential. By default, Verilog implicitly declares misspelled signal names as single-bit wires.

With this directive enabled, the compiler flags any undeclared signal name as a compile error, preventing subtle wiring bugs.

Language Standard

This module teaches the Verilog-2001 standard (IEEE 1364-2001). Verilog-2001 introduced ANSI-style port lists, signed arithmetic, generate blocks, and combined sensitivity lists (always @*).

Module 9 covers modern SystemVerilog extensions (IEEE 1800).

Start with Section 4.1: Why HDL.

In this module

01 From Schematics to Code 4 min 02 Simulation and Synthesis 4 min 03 From RTL to Silicon 4 min 04 Verilog, VHDL and SystemVerilog 4 min 05 Thinking in Hardware 5 min 06 Modules and Ports 5 min 07 wire and reg 5 min 08 Vectors and Arrays 5 min 09 Parameters 6 min 10 Number Literals 5 min 11 Compiler Directives 5 min 12 Style and Conventions 6 min 13 Arithmetic Operators 6 min 14 Relational and Logical Operators 5 min 15 Bitwise and Reduction Operators 5 min 16 Shift and Concatenation Operators 5 min 17 The Conditional Operator 4 min 18 Precedence and Width 5 min 19 Gate Primitives 4 min 20 Module Instantiation 4 min 21 Port Connections in Detail 4 min 22 Hierarchy and Generate 4 min 23 A 4-bit ALU from the Gates Up 7 min 24 Continuous Assignments 4 min 25 Dataflow in Practice 6 min 26 Muxes, Encoders and Decoders 5 min 27 A Parameterised Comparator, Start to Finish 6 min 28 Structural, Dataflow or Behavioural 4 min