Module 4: Introduction to Verilog HDL
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:
| 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 |
Recommended Simulation Tools
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.