Module 4: Introduction to Verilog HDL · 4.1 Why HDL?

Simulation and Synthesis

A Verilog source file is processed by two distinct software tools: a logic simulator and a logic synthesizer.

Each tool interprets Verilog syntax with different operational rules. Engineers must understand which language constructs target synthesis and which target simulation testbenches.

The Logic Simulator

A logic simulator is an event-driven software interpreter. The tool creates a mathematical model of the circuit and advances simulated time as events occur.

The simulator executes verification constructs that have no physical hardware equivalent:

  • Explicit time delays (#100)
  • Formatted console display tasks ($display, $monitor)
  • Procedural initial blocks that execute once at time zero
  • Infinite simulation loops (forever)
  • Floating-point data types (real)
  • Signal override commands (force and release)

These constructs allow engineers to build testbenches, generate input stimulus, and verify circuit responses.

The Logic Synthesizer

A logic synthesizer is a hardware compiler. The tool translates Verilog code into physical gate-level netlists targeting ASIC standard cells or FPGA Look-Up Tables.

The synthesizer ignores non-synthesizable constructs or generates compilation errors:

  • Delay Directives: Synthesizers ignore #delay statements. The statement assign #5 y = a & b; synthesizes into an unbuffered AND gate. The physical delay depends exclusively on gate load capacitance and wire resistance.
  • Initial Blocks: Most ASIC synthesis tools reject initial blocks because hardware flip-flops require physical reset pins for initialization.
  • Dynamic Loops: Loops with variable execution limits are rejected because hardware structures require static, predefined transistor bounds.

Register Transfer Level (RTL) as the Common Subset

Register Transfer Level (RTL) represents the common intersection of synthesizable and simulatable Verilog constructs (Figure 1).

RTL as the overlap
Figure 1: Venn diagram showing the RTL synthesizable subset within the Verilog simulation language

RTL code describes synchronous registers and intermediate combinational logic. All synthesizable modules in this course use pure RTL.

Verilog Construct Simulator Support Synthesizer Support Physical Hardware Mapping
Continuous assignment (assign y = a & b;) Supported Supported Combinational logic gate
Clocked procedural block (always @(posedge clk)) Supported Supported Edge-triggered D flip-flops
Combinational procedural block (always @*) Supported Supported Combinational multiplexers and gates
Conditional statements (if / else) Supported Supported Multiplexer or priority encoder
Multi-branch statements (case) Supported Supported Decoder or multiplexer
Bounded loops (for with constant bounds) Supported Supported Unrolled parallel hardware logic
Data nets (wire, reg, parameter) Supported Supported Physical wires, registers, and constants
Power-on blocks (initial) Supported Rejected Testbench execution only
Delay statements (#10) Supported Ignored Simulation timing annotation
System tasks ($display, $finish) Supported Rejected Testbench console logging
Unbounded loops (while with dynamic limit) Supported Error Testbench stimulus generation

Constructs rejected by synthesizers must reside exclusively inside testbench files.

The Simulation-Synthesis Mismatch Hazard

A simulation-synthesis mismatch occurs when simulated behavior differs from synthesized silicon behavior.

Consider this module with an embedded delay:

`timescale 1ns / 1ps
`default_nettype none

// INCORRECT: Non-synthesizable delay inside a design module
module bad_adder (
    input  wire [7:0] a,
    input  wire [7:0] b,
    output wire [8:0] sum
);
    assign #5 sum = a + b; // Simulator enforces 5 ns; synthesizer ignores delay
endmodule

In simulation, sum updates exactly 5 ns after input transitions.

In physical silicon, the synthesis tool ignores the #5 directive. The real hardware delay depends entirely on transistor switching speeds. If downstream circuitry assumes a 5 ns delay, the physical device fails even though simulation tests passed.

Separate synthesizable design logic from simulation testbench harnesses:

`timescale 1ns / 1ps
`default_nettype none

// CORRECT: Synthesizable design module containing pure RTL
module good_adder (
    input  wire [7:0] a,
    input  wire [7:0] b,
    output wire [8:0] sum
);
    assign sum = a + b;
endmodule

Place all simulation directives in a dedicated testbench file:

`timescale 1ns / 1ps
`default_nettype none

// CORRECT: Verification testbench containing simulation constructs
module tb_good_adder;

    reg  [7:0] a, b;
    wire [8:0] sum;

    // Instantiate Device Under Test (DUT)
    good_adder dut (
        .a   (a),
        .b   (b),
        .sum (sum)
    );

    initial begin
        $dumpfile("dump.vcd");
        $dumpvars(0, tb_good_adder);

        a = 8'd100; b = 8'd200; #10;
        $display("sum = %0d (expected 300)", sum);

        a = 8'd255; b = 8'd255; #10;
        $display("sum = %0d (expected 510)", sum);

        $finish;
    end

endmodule

Practical Project Rules

Maintain strict design separation:

  • Design Modules: Use only synthesizable RTL constructs. Design files must not contain #delay, initial, $display, or $finish.
  • Testbench Modules: Use simulation constructs for stimulus generation and checking. Testbench files use the prefix tb_.
  • Automated Linting: Configure EDA linters (such as Verilator) to treat non-synthesizable constructs in design files as fatal compilation errors.

The next article traces the complete digital ASIC and FPGA design flow from RTL description to physical fabrication.

← From Schematics to Code From RTL to Silicon →