Module

Module 5: Behavioral Verilog for Synthesis

29 lessons
Start

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:

  1. Clocked Sequential Blocks: Inside edge-triggered blocks (always @(posedge clk)), use non-blocking assignments (<=) for all register transfers.
  2. 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:

Module 5 map
Figure 1: Conceptual map of Module 5 sections

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.

In this module

01 Everything Runs at Once 4 min 02 always and initial 4 min 03 Blocking Assignments 5 min 04 Non-Blocking Assignments 5 min 05 The Scheduler 5 min 06 The Sensitivity List 3 min 07 always @(*) 4 min 08 The Missing Signal 3 min 09 Accidental Latches 5 min 10 if and else 4 min 11 case 3 min 12 casez, and Why Not casex 3 min 13 full_case and parallel_case 2 min 14 Priority or Parallel 4 min 15 for Loops and Synthesis 4 min 16 while, repeat and forever 4 min 17 Loops as Hardware Generators 5 min 18 generate for and Procedural for 3 min 19 Inferring Flip-Flops 3 min 20 Reset Strategies: Synchronous and Asynchronous 4 min 21 Clock Enables and Load Signals 4 min 22 Register Design Patterns 4 min 23 Pipeline Registers and Valid Signals 4 min 24 The State Machine in RTL 4 min 25 The One-Process Style 3 min 26 The Two-Process Style 3 min 27 The Three-Process Style 3 min 28 Encoding and Safe State Machines 3 min 29 Three Complete State Machines 7 min