Digital Design with Verilog HDL


The purpose of this part of the course is to:

  1. Bottom-Up Design Flow
  2. Top-Down Design Flow

Why Use an HDL?

Key Features of HDL

Simulation Algorithms

Time Driven

Event Driven

Demand Driven

Different Levels of Abstractions

Architectural/Algorithmic level

Dataflow level

Gate level

Switch level

Register Transfer Logic (RTL) level

Modules


module add4 (s,c4,ci,a,b);

input [3:0] a,b;

input ci;

output [3:0]s;

output c4;

wire [2:0] co;

add a0 (co[0],s[0],a[0],b[0],ci);

add a1 (co[1],s[1],a[1],b[1],co[0]);

add a2 (co[2],s[2],a[2],b[2],co[1]);

add a3 (c4,s[3],a[3],b[0],co[2]);

endmodule


Examples of instantiation


// NOT Gate logic simulation

`timescale 1 us / 10 ns

module inverter(IN,OUT);

output OUT;

not #(1,3) inv1(OUT,IN); // gate instantiation

endmodule


Note: not is a verilog-provided primitive


//NAND Gate simulation model

`timescale 1 us / 10 ns

module nand_gate(IN1,IN2,OUT);

input IN1,IN2;

output OUT;

// gate instantiation

nand #(1,2) nand1(OUT,IN1,IN2);

endmodule
module Top;

wire C ;

reg A,B;

nand_gate nand1(A,B,C); // Instantiation of lower block

// Stimulate the input

initial

begin

A=0; B=0;

#5 B=1;

#5 B=0; A=1;

#5 B=1;

#5 A=0;

#5 B=0;

end

endmodule