Module 5: Behavioral Verilog for Synthesis
Module 4 described digital circuits by interconnecting gates and evaluating boolean equations. This module introduces behavioral register-transfer level (RTL) modeling. In behavioral modeling, you describe circuit transitions at clock edges while synthesis tools optimize gate implementations.
Fundamental Principles of Behavioral Hardware
Behavioral Verilog uses familiar procedural keywords such as if, case, and for. However, Verilog models physical concurrent hardware, not sequential software programs.
Multiple always blocks execute in parallel. They represent physical digital circuits operating simultaneously under power. If block A assigns a net that block B reads, and block B assigns a net that block A reads, the circuit forms a physical feedback loop. No procedural block waits for another block to complete.
The Two Foundational Assignment Rules
All behavioral RTL design relies on two mandatory rules:
- Clocked Sequential Blocks: Inside edge-triggered blocks (
always @(posedge clk)), use non-blocking assignments (<=) for all register transfers. - Combinational Blocks: Inside combinational procedural blocks (
always @(*)), use blocking assignments (=) for all variable evaluations.
These rules reflect the internal event scheduling algorithm of Verilog simulation engines. Section 5.1 analyzes this scheduling mechanism in detail.
Module Structure
Figure 1 illustrates the six sections of Module 5:
| Section | Topic | Core Technical Concepts |
|---|---|---|
| 5.1 | Procedural Blocks | Concurrency, always and initial, blocking vs non-blocking assignments, event scheduler |
| 5.2 | Sensitivity Lists | Edge-triggered vs level-sensitive lists, always @(*), incomplete lists, latch avoidance |
| 5.3 | Conditional and Case | Branch priority, parallel logic, casez, casex, full case, and parallel case synthesis |
| 5.4 | Loops in RTL | Procedural for loops, loop unrolling, and comparisons with generate blocks |
| 5.5 | Registers and Datapaths | D flip-flops, reset strategies, clock enables, shift registers, and pipelined datapaths |
| 5.6 | Finite State Machines | FSM taxonomy, state encoding styles, Mealy/Moore outputs, and complete worked examples |
Hardware Designs Implemented in This Module
| Design Architecture | Section Reference |
|---|---|
Multi-bit parity generator with for loop |
Section 5.4 |
| D flip-flop with synchronous and asynchronous resets | Section 5.5 |
| Parameterized universal shift register | Section 5.5 |
| Up/down counter with synchronous load and clear | Section 5.5 |
| Pipelined processing datapath with valid handshaking | Section 5.5 |
| Traffic light controller in three FSM coding styles | Section 5.6 |
| Overlapping Mealy serial sequence detector | Section 5.6 |
| Electronic vending machine controller with datapath integration | Section 5.6 |
Every module includes an automated self-checking testbench that exports Value Change Dump (.vcd) waveform files for visual inspection.
Simulation Environment and Tools
Verify all designs using Icarus Verilog (iverilog) and GTKWave:
iverilog -o sim tb_design_name.v design_name.v
vvp sim
gtkwave tb.vcd
Each testbench configures waveform recording inside an initial block:
$dumpfile("tb.vcd");
$dumpvars(0, tb_design_name);
The depth parameter 0 instructs the simulator to record all signal transitions throughout the module hierarchy.
Proceed to Section 5.1: Procedural Blocks to begin behavioral Verilog design.