Easy Tutorial
❮ Android Tutorial Gridview Database Implementation ❯

3.2 Verilog Delay

Category Verilog Tutorial

Keywords: Delay, Inertial Delay

The delay in continuous assignment statements is used to control the time delay between any operand change and the assignment of the new value to the left-hand side.

Delay is generally not synthesizable.

The delay of registers can also be controlled, which is explained in the timing control section.

Continuous assignment delay can generally be divided into regular assignment delay, implicit delay, and declared delay.

The following three examples achieve the same function, corresponding to three different ways of writing continuous assignment delays.

// Regular delay, the result of A&B is assigned to Z after a 10-time unit delay
wire Z, A, B;
assign #10 Z = A & B;
// Implicit delay, a wire variable is declared and continuously assigned with a certain delay.
wire A, B;
wire #10 Z = A & B;
// Declared delay, a wire variable is declared with a specified delay. Therefore, all continuous assignments to this variable will be postponed to the specified time. This method is generally not recommended unless for gate-level modeling.
wire A, B;
wire #10 Z;
assign Z = A & B;

Inertial Delay

In the above examples, if either A or B changes, there will be a 10-time unit delay before Z gets the new value. If within these 10 time units, i.e., before Z gets the new value, either A or B changes again, the new value of Z will be calculated based on the current new values of A or B. This is called inertial delay, meaning that signal pulses narrower than the delay will have no effect on the output.

Therefore, when simulating, the delay must be set reasonably to prevent certain signals from not being effectively delayed.

Delay simulation of an AND gate logic with delay.

Example

module time_delay_module(
    input ai, bi,
    output so_lose, so_get, so_normal);

    assign #20 so_lose = ai & bi;
    assign #5 so_get = ai & bi;
    assign so_normal = ai & bi;
endmodule

Testbench reference is as follows:

Example

`timescale 1ns/1ns

module test;
    reg ai, bi;
    wire so_lose, so_get, so_normal;

    initial begin
        ai = 0;
        #25; ai = 1;
        #35; ai = 0; //60ns
        #40; ai = 1; //100ns
        #10; ai = 0; //110ns
    end

    initial begin
        bi = 1;
        #70; bi = 0;
        #20; bi = 1;
    end

    time_delay_module u_wire_delay(
        .ai (ai),
        .bi (bi),
        .so_lose (so_lose),
        .so_get (so_get),
        .so_normal (so_normal));

    initial begin
        forever begin
            #100;
            //$display("---gyc---%d", $time);
            if ($time >= 1000) begin
                $finish;
            end
        end
    end

endmodule

Simulation results are as follows:

The signal so_normal is the normal AND logic.

Since all delays are greater than 5ns, the result of the signal so_get is the AND operation followed by a 5ns delay.

The first part of the signal so_lose is the result of the AND operation followed by a 20ns delay.

Since the second high pulse duration of signal ai is less than 20ns, the signal so_lose will miss the delayed detection of this pulse due to inertial delay, so the second half of the so_lose signal remains 0.

Source Code Download

Download

-1.1 Verilog Tutorial

-1.2 Verilog Introduction

-1.3 Verilog Environment Setup

-1.4 Verilog Design Method

-2.1 Verilog Basic Syntax

-2.2 Verilog Numerical Representation

-2.3 Verilog Data Types

-2.4 Verilog Expressions

-2.5 Verilog Compile Instructions

-3.1 Verilog Continuous Assignment

-4.1 Verilog Process Structure

-4.2 Verilog Process Assignment

-4.3 Verilog Timing Control

-4.4 Verilog Statement Blocks

-4.5 Verilog Conditional Statements

-4.6 Verilog Multi-branch Statements

-4.7 Verilog Loop Statements

-4.8 Verilog Process Continuous Assignment

-5.1 Verilog Modules and Ports

-5.2 Verilog Module Instantiation

-5.3 Verilog Parameterized Instantiation

-6.1 Verilog Functions

-6.2 Verilog Tasks

-6.3 Verilog State Machines

-6.4 Verilog Competition and Hazards

-6.5 Verilog Avoiding Latch

-6.6 Verilog Simulation Stimulus

-6.7 Verilog Pipelining

-7.1 Verilog Divider Design

-7.2 Verilog Parallel FIR Filter Design

-7.3 Verilog Serial FIR Filter Design

-7.4 Verilog CIC Filter Design

-7.5 Verilog FFT Design

-7.6 Verilog DDS Design

-8.1 Verilog Numerical Conversion

-Verilog Advanced Tutorial

WeChat Subscription

English:

❮ Android Tutorial Gridview Database Implementation ❯