Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-I]

Slides:



Advertisements
Similar presentations
Verilog HDL -Introduction
Advertisements

//HDL Example 4-10 // //Gate-level description of circuit of Fig. 4-2 module analysis (A,B,C,F1,F2); input.
Verilog.
The Verilog Hardware Description Language
Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Synchronous Sequential Logic
Combinational Logic.
ELEN 468 Lecture 21 ELEN 468 Advanced Logic Design Lecture 2 Hardware Modeling.
Verilog Intro: Part 1.
Hardware Description Language (HDL)
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part3: Verilog – Part 1.
CSE 341 Verilog HDL An Introduction. Hardware Specification Languages Verilog  Similar syntax to C  Commonly used in  Industry (USA & Japan) VHDL 
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
 HDLs – Verilog and Very High Speed Integrated Circuit (VHSIC) HDL  „ Widely used in logic design  „ Describe hardware  „ Document logic functions.
ENEE 408C Lab Capstone Project: Digital System Design Verilog Tutorial Class Web Site:
Verilog Sequential Circuits Ibrahim Korpeoglu. Verilog can be used to describe storage elements and sequential circuits as well. So far continuous assignment.
ENEE 408C Lab Capstone Project: Digital System Design Spring 2006 Class Web Site:
Reconfigurable Computing (EN2911X, Fall07) Lecture 05: Verilog (1/3) Prof. Sherief Reda Division of Engineering, Brown University
ECEN ECEN475 Introduction to VLSI System Design Verilog HDL.
Verilog Basics Nattha Jindapetch November Agenda Logic design review Verilog HDL basics LABs.
INTRODUCTION TO VERILOG HDL Presented by m.vinoth.
Introduction to FPGA AVI SINGH. Prerequisites Digital Circuit Design - Logic Gates, FlipFlops, Counters, Mux-Demux Familiarity with a procedural programming.
Verilog Intro: Part 2. Procedural Blocks There are two types of procedural blocks in Verilog. – initial for single-pass behavior: initial blocks execute.
ECE 2372 Modern Digital System Design
Digital System 數位系統 Verilog HDL Ping-Liang Lai (賴秉樑)  
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
CH71 Chapter 7 Hardware Description Language (HDL) By Taweesak Reungpeerakul.
ECE/CS 352 Digital System Fundamentals© 2001 C. Kime 1 ECE/CS 352 Digital Systems Fundamentals Spring 2001 Chapters 3 and 4: Verilog – Part 2 Charles R.
Module 1.2 Introduction to Verilog
1 CSE-308 Digital System Design (DSD) N-W.F.P. University of Engineering & Technology, Peshawar.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
1 Hardware description languages: introduction intellectual property (IP) introduction to VHDL and Verilog entities and architectural bodies behavioral,
Behavioral Modelling - 1. Verilog Behavioral Modelling Behavioral Models represent functionality of the digital hardware. It describes how the circuit.
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
Introduction to ASIC flow and Verilog HDL
Introduction to Verilog. Data Types A wire specifies a combinational signal. – Think of it as an actual wire. A reg (register) holds a value. – A reg.
Introduction to Verilog
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
Chapter1: Introduction Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 1-1 Chapter 1: Introduction Prof. Ming-Bo.
Verilog Intro: Part 1. Hardware Description Languages A Hardware Description Language (HDL) is a language used to describe a digital system, for example,
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part4: Verilog – Part 2.
Exp#5 & 6 Introduction to Verilog COE203 Digital Logic Laboratory Dr. Ahmad Almulhem KFUPM Spring 2009.
Structural Description
Hardware Description Languages: Verilog
An Introduction to Verilog: Transitioning from VHDL
Verilog Tutorial Fall
Supplement on Verilog FF circuit examples
Hardware Description Languages
Introduction to Verilog
Verilog Introduction Fall
‘if-else’ & ‘case’ Statements
Lecture 2 Supplement Verilog-01
Verilog-HDL-3 by Dr. Amin Danial Asham.
Hardware Description Languages: Verilog
Introduction to Verilog
Behavioral Modeling in Verilog
For NTUEE Undergraduate
Introduction to Verilog
Verilog.
COE 202 Introduction to Verilog
Introduction to Verilog
Supplement on Verilog adder examples
Introduction to Verilog
The Verilog Hardware Description Language
The Verilog Hardware Description Language
Introduction to Verilog
Introduction to Digital IC Design
COE 202 Introduction to Verilog
Reconfigurable Computing (EN2911X, Fall07)
Presentation transcript:

Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-I]

Modules Basic building block in verilog. Declared by keyword “module”. A corresponding keyword “endmodule” must appear at the end of definition. Modules cannot be nested. One module can instantiate another module. Module instantiations are used for: -- connecting different parts of the design -- connecting Test bench to the design.

Structure of a Module

Ports Ports provide interface by which a module can communicate with it’s environment. input – Input port output – Output port inout – Bidirectional port module fulladd4 (sum, c_out, a, b, c_in)

Nets Nets represent connections between hardware elements. They are always driven by some source. Declared by keyword “wire”. It can hold any one of the four values: 0, 1, x, z. Default value for any net type variable is ‘z’ (High impedance).

Registers These correspond to variables in C language. Register data types always retain their value until another value is placed on them. Unlike nets, registers do not need any drivers. Declared by keyword “reg”. It can hold any one of the four values: 0, 1, x, z. Default value for any reg type variable is ‘x’ (unknown).

wire a ; //1-bit wire wire [7:0] bus; //8-bit bus wire [31:0] busA, busB, busC ; //3 buses of 32-bit width reg a; //1-bit register reg [31:0] b; //32-bit register Memories (array of registers) reg [wordsize:0] memory [0:arraysize] reg [3 : 0] mem_a [63:0] ; //sixty-four 4-bit registers mem_a [address] = data_in ; reg mem_b [0 : 4] // five 1-bit registers Number format <size> ’ <base_format> <number_format> 4’b1111 //This is a 4-bit binary number 12’habc //This is a 12-bit hexadecimal number 16’d255 //This is a 16-bit decimal number 23456 //This is a 32-bit decimal number by default `hc3 //This is a 32-bit hexadecimal number `o21 //This is a 32-bit octal number

Default type for input/output/inout is “wire”. “input wire in_1” is same as “input in_1”. “output wire out_1” is same as “output out_1”. A parameter is defined by Verilog as a constant value declared within the module. Syntax: parameter <identifier> = constant; Example: parameter byte_size = 8; reg[byte_size-1:0] A;

Modeling Techniques Behavioral Modeling Data-flow Modeling Gate level Modeling Switch level Modeling

Switch-Level Modeling //CMOS Inverter module not_gate (x, f) ; input x ; output f ; //internal declaration supply1 vdd ; supply0 gnd ; //NOT gate body pmos p1 (f, vdd, x) ; nmos n1 (f, gnd, x) ; endmodule

Gate-Level Modeling Need to model the gate’s: -- Function -- Delay  Verilog provides built-in gate-level primitives: and nand logical AND/NAND or nor logical OR/NOR xor xnor logical XOR/XNOR buf not buffer/Inverter bufif0 notif0 Tristate with low enable bufif1 notif1 Tristate with High enable Primitive_name #delay instance_name (out, in_1, in_2, … ) ; and #1 a1 (out, in_1, in_2) ;

module simple_ckt (x, y, A, B, C) ; input A, B, C ; output x, y ; wire e ; and g1 (e, A, B) ; not g2 (y, C) ; or g3 (x, e, y) ; endmodule

a0 a1 a4 a2 a3 //Gate-level description of 4-to-1- line multiplexer module mux4x1 (I0, I1, I2, I3, s1, s0, y); input I0, I1, I2, I3, s1, s0; output y; //intermediate connections wire NOT_s1, NOT_s0 ; wire y0, y1, y2, y3 ; not n0 (NOT_s0, s0) ; not n1 (NOT_s1, s1) ; and a0 (y0, I0, NOT_s1, NOT_s0) ; and a1 (y1, I1, NOT_s1, s0) ; and a2 (y2, I2, s1, NOT_s0) ; and a3 (y3, I3, s1, s0) ; or a4 (y, y3, y2, y1, y0) ; endmodule y0 a0 y1 a1 a4 y2 a2 y3 a3 NOT_s0 NOT_s1 n1 n0

Gate-level/Structural Modeling 4 bit Full Adder – Half Adder Full Adder (FA)

4 bit Full Adder //Gate-level hierarchical description of 4-bit adder // Description of half adder module halfadder (S, C, x, y); input x, y; output S, C; //Instantiate primitive gates xor (S, x, y); and (C, x, y); endmodule //Description of full adder module fulladder (S, C, x, y, z); input x, y, z; wire S1, D1, D2; //Outputs of first XOR and two AND gates //Instantiate the halfadder halfadder HA1 (S1, D1, x, y), halfadder HA2 (S, D2, S1, z); or g1 (C, D2, D1);

4 bit Full Adder module four_bit_adder (S, C4, A, B, C0); input [3:0] A, B; input C0; output [3:0] S; output C4; wire C1,C2,C3; //Intermediate carries //Instantiate the full adder cells fulladder FA0 (S[0],C1,A[0],B[0],C0), FA1 (S[1],C2,A[1],B[1],C1), FA2 (S[2],C3,A[2],B[2],C2), FA3 (S[3],C4,A[3],B[3],C3); endmodule

Data-flow Modeling Dataflow modeling uses continuous assignments and the keyword “assign”. Syntax: assign <drive_strength> #<delay> <list_of_assignments>; Example: wire out ; assign out = var1 & var2 ; The assignment expression is evaluated as soon as one of the right-hand-side operands changes and the value is assigned to the left-hand-side net. LHS must be net & cannot be reg. RHS can be net/reg.

//Data-flow description of 4-to-1- line multiplexer module mux4x1 (I0, I1, I2, I3, s1, s0, y); input I0, I1, I2, I3, s1, s0; output y; assign y = (~s1 & ~s0 & I0) | (~s1 & s0 & I1) | ( s1 & ~s0 & I2) | ( s1 & s0 & I3) ; endmodule //Using conditional operator module mux2x1 (I0, I1, sel, y); input I0, I1, sel; assign y = sel ? I1 : I0 ;

Behavioral Modeling Used to model the behavior of a design without describing it’s actual hardware structure. Procedural blocks are the basic components for behavioral modeling.

Procedural blocks are like concurrent processes Procedural blocks are like concurrent processes. Statements in a block are executed sequentially, but all within one unit of simulated time. (unless delay is specified) All blocks execute in parallel. initial block – Executes only once. It is NOT synthesizable. Used in test benches. always block - Executes repeatedly. It must have timing control, otherwise it become INFINITE LOOPS. Procedural assignments within initial/always: LHS must be reg & cannot be net. RHS can be net/reg.

//Behavioral description of 4-to-1- line multiplexer module mux4x1_bhv (I0, I1, I2, I3, select, y); input I0, I1, I2, I3; input [1:0] select; output y; reg y; always @ (I0 or I1 or I2 or I3 or select) begin case (select) 2'b00: y = I0; 2'b01: y = I1; 2'b10: y = I2; 2'b11: y = I3; endcase end endmodule Sensitivity list contains signals whose change triggers the execution of the block

Event Control Edge-triggered Event control @ (posedge CLK) //positive edge of CLK Curr_state = Next_state ; Level-triggered Event control @ (A or B) //change in values of A or B out = A & B

Blocking assignment ( = ) a = 1 ; b = a ; c = b ; Non-blocking assignment ( <= ) a <= 1 ; b <= a ; c <= b ; Used to model “Combinational ckt.” Used to model “Sequential ckt.”

Modeling D-Flip Flop //Synchronous Reset //Asynchronous Reset module dff_a (d, clk, rst, q) ; input d, clk, rst ; output q ; reg q ; always @ (posedge clk or negedge rst) if (~rst) q <= 1’b0 ; else q <= d ; endmodule //Synchronous Reset module dff_a (d, clk, rst, q) ; input d, clk, rst ; output q ; reg q ; always @ (posedge clk) if (~rst) q <= 1’b0 ; else q <= d ; endmodule For active high reset: if (rst) For active low reset: if (~rst)