VLSI Design 13. Introduction to Verilog

Similar documents
14. Introducton to Verilog

14. Introducton to Verilog

Lecture 20: Hardware Description Languages & Logic Simulation

Synthesizable Verilog

Verilog Tutorial (Structure, Test)

Verilog Overview. The Verilog Hardware Description Language. Simulation of Digital Systems. Simulation of Digital Systems. Don Thomas, 1998, Page 1

What is Verilog HDL? Lecture 1: Verilog HDL Introduction. Basic Design Methodology. What is VHDL? Requirements

Verilog. What is Verilog? VHDL vs. Verilog. Hardware description language: Two major languages. Many EDA tools support HDL-based design

The Verilog Language COMS W Prof. Stephen A. Edwards Fall 2002 Columbia University Department of Computer Science

Verilog Overview. The Verilog Hardware Description Language. Simulation of Digital Systems. Simulation of Digital Systems. Don Thomas, 1998, Page 1

Verilog Overview. The Verilog Hardware Description Language. Simulation of Digital Systems. Simulation of Digital Systems. Don Thomas, 1998, Page 1

N-input EX-NOR gate. N-output inverter. N-input NOR gate

Contents. Appendix D Verilog Summary Page 1 of 16

Lecture 15: System Modeling and Verilog

Chapter 2 Using Hardware Description Language Verilog. Overview

Verilog HDL. Testing & Verification Dept. of Computer Science & Engg,, IIT Kharagpur

EECS150 - Digital Design Lecture 10 Logic Synthesis

Why Should I Learn This Language? VLSI HDL. Verilog-2

Synthesis vs. Compilation Descriptions mapped to hardware Verilog design patterns for best synthesis. Spring 2007 Lec #8 -- HW Synthesis 1

FPGA Design Challenge :Techkriti 14 Digital Design using Verilog Part 1

EECS150 - Digital Design Lecture 10 Logic Synthesis

Computer Aided Design Basic Syntax Gate Level Modeling Behavioral Modeling. Verilog

Logic Synthesis. EECS150 - Digital Design Lecture 6 - Synthesis

Schematic design. Gate level design. 0 EDA (Electronic Design Assistance) 0 Classical design. 0 Computer based language

Online Verilog Resources

Introduction To Verilog Design. Chun-Hung Chou

Introduction to Verilog HDL. Verilog 1

ECE 2300 Digital Logic & Computer Organization. More Sequential Logic Verilog

Synthesis of Language Constructs. 5/10/04 & 5/13/04 Hardware Description Languages and Synthesis

Hardware Description Language VHDL (1) Introduction

Introduction. Why Use HDL? Simulation output. Explanation

ECE 353 Lab 4. Verilog Review. Professor Daniel Holcomb With material by Professor Moritz and Kundu UMass Amherst Fall 2016

EEL 4783: HDL in Digital System Design

Introduction to Digital Design with Verilog HDL

Speaker: Kayting Adviser: Prof. An-Yeu Wu Date: 2009/11/23

CSE140L: Components and Design Techniques for Digital Systems Lab

Verilog Fundamentals. Shubham Singh. Junior Undergrad. Electrical Engineering

CS6710 Tool Suite. Verilog is the Key Tool

CAD for VLSI Design - I. Lecture 21 V. Kamakoti and Shankar Balachandran

Digital Design with FPGAs. By Neeraj Kulkarni

CSE140L: Components and Design

Under-Graduate Project Logic Design with Behavioral Models

Date Performed: Marks Obtained: /10. Group Members (ID):. Experiment # 11. Introduction to Verilog II Sequential Circuits

- 1 of 18 - The Verilog Hardware Description Language - A Behavioural View Overview. The Behavioural Model

EECS 427 Lecture 14: Verilog HDL Reading: Many handouts/references. EECS 427 W07 Lecture 14 1

Verilog HDL. Gate-Level Modeling

Abi Farsoni, Department of Nuclear Engineering and Radiation Health Physics, Oregon State University

Verilog 1 - Fundamentals

Lab 7 (Sections 300, 301 and 302) Prelab: Introduction to Verilog

ECE 353 Lab 4. Verilog Review. Professor Daniel Holcomb UMass Amherst Fall 2017

Verilog Tutorial. Introduction. T. A.: Hsueh-Yi Lin. 2008/3/12 VLSI Digital Signal Processing 2

Introduction to Verilog/System Verilog

CS6710 Tool Suite. Verilog is the Key Tool. Verilog as HDL (AHT) Verilog has a Split Personality. Quick Review. Synthesis

VHDL: RTL Synthesis Basics. 1 of 59

101-1 Under-Graduate Project Digital IC Design Flow

Introduction To HDL. Verilog HDL. Debdeep Mukhopadhyay Dept of CSE, IIT Madras 1

Veriolog Overview. CS/EE 3710 Fall 2010

EN2911X: Reconfigurable Computing Topic 02: Hardware Definition Languages

Lecture 2: Data Types, Modeling Combinational Logic in Verilog HDL. Variables and Logic Value Set. Data Types. Why use an HDL?

FPGA: FIELD PROGRAMMABLE GATE ARRAY Verilog: a hardware description language. Reference: [1]

Spiral 1 / Unit 4 Verilog HDL. Digital Circuit Design Steps. Digital Circuit Design OVERVIEW. Mark Redekopp. Description. Verification.

P-1/P-105. Samir Palnitkar. Prentice-Hall, Inc. INSTRUCTOR : CHING-LUNG SU.

Verilog. Like VHDL, Verilog HDL is like a programming language but:

Chap 6 Introduction to HDL (d)

Chapter 4 :: Topics. Introduction. SystemVerilog. Hardware description language (HDL): allows designer to specify logic function only.

A Brief Introduction to Verilog Hardware Definition Language (HDL)

ECE 4514 Digital Design II. Spring Lecture 2: Hierarchical Design

This Lecture. Some components (useful for the homework) Verilog HDL (will continue next lecture)

Graduate Institute of Electronics Engineering, NTU. Lecturer: Chihhao Chao Date:

ENGN1640: Design of Computing Systems Topic 02: Design/Lab Foundations

Digital Design with SystemVerilog

ECEN 468 Advanced Digital System Design

Chapter 4. Digital Design and Computer Architecture, 2 nd Edition. David Money Harris and Sarah L. Harris. Chapter 4 <1>

Digital Circuit Design and Language. Datapath Design. Chang, Ik Joon Kyunghee University

ENGN1640: Design of Computing Systems Topic 02: Design/Lab Foundations

ECE 353 Lab 3 (Verilog Design Approach)

Lab #1. Topics. 3. Introduction to Verilog 2/8/ Programmable logic. 2. Design Flow. 3. Verilog --- A Hardware Description Language

Hardware description languages

Verilog. Verilog for Synthesis

Combinational Logic Design with Verilog. ECE 152A Winter 2012

yamin/

Speaker: Shao-Wei Feng Adviser: Prof. An-Yeu Wu Date: 2010/09/28

Design Using Verilog

ECEN 449 Microprocessor System Design. Verilog. Texas A&M University

Introduction to Verilog design. Design flow (from the book)

Verilog HDL Introduction

Hardware Description Languages: Verilog. Quick History of HDLs. Verilog/VHDL. Design Methodology. Verilog Introduction. Verilog.

14:332:231 DIGITAL LOGIC DESIGN. Hardware Description Languages

Chapter 4. Digital Design and Computer Architecture, 2 nd Edition. David Money Harris and Sarah L. Harris. Chapter 4 <1>

Hardware Description Languages: Verilog

14:332:231 DIGITAL LOGIC DESIGN. Hardware Description Languages

Brief Introduction of Cell-based Design. Ching-Da Chan CIC/DSD

TOPIC : Verilog Synthesis examples. Module 4.3 : Verilog synthesis

ECEN 449 Microprocessor System Design. Verilog. Texas A&M University

UNIT V: SPECIFICATION USING VERILOG HDL

The Verilog Hardware Description Language

CSE241 VLSI Digital Circuits Winter Recitation 1: RTL Coding in Verilog

P-1/26. Samir Palnitkar. Prentice-Hall, Inc. INSTRUCTOR : CHING-LUNG SU.

Chap 3. Modeling structure & basic concept of Verilog HDL

Verilog for Combinational Circuits

Transcription:

Last module: Sequential circuit design Design styles This module Synthesis Brief introduction to Verilog Synthesis in the Design Flow Designer Tasks Tools Architect Logic Designer Circuit Designer Define Overall Chip C/RTL Model Initial Floorplan Behavioral Simulation Logic Simulation Synthesis Datapath Schematics Cell Libraries Circuit Schematics Circuit Simulation Megacell Blocks Text Editor C Compiler RTL Simulator Synthesis Tools Timing Analyzer Power Estimator Schematic Editor Circuit Simulator Router Synthesis Physical Designer Layout and Floorplan Place and Route Parasitics Extraction DRC/LVS/ERC Place/Route Tools Physical Design and Evaluation Tools D. Z. Pan 1 D. Z. Pan 2 Logic Synthesis Design described in a Hardware Description Language (HDL) Verilog, VHDL Simulation to check for correct functionality Simulation semantics of language Synthesis tool Identifies logic and state elements Technology-indepent optimizations (state assignment, logic minimization) Map logic elements to target technology (standard cell library) Technology-depent optimizations (multi-level optimization, gate strengths, etc.) D. Z. Pan 3 Features of Verilog A concurrent language (syntax similar to C) Models hardware Provides a way to specify concurrent activities Allows timing specifications Originally developed by Gateway Design Automation, acquired by Cadence, now IEEE Standard 1364-1995 (Open Verilog International) D. Z. Pan 4 Applications of Verilog Design Process Cycle Description of design at a higher level Development of formal models System documentation Simulation to uncover errors (bugs) in design Synthesis of designs Design reuse V E R I L O G Behavioral RTL Netlist Specification System Design Logic Level Circuit level Layout D. Z. Pan 5 D. Z. Pan 6 D. Z. Pan 1

Verilog Modes 1. Structural: describes the structure of the hardware components, including how ports of modules are connected together module contents are built in gates (and, or, xor, not, nand, nor, xnor, buf) or other modules previously declared 2. Behavoral: describes what should be done in a module module contents are C-like assignment statements, loops D. Z. Pan 7 Structural Model of Adder Structural models: interconnections of primitive gates (AND, OR, NAND, NOR, etc...) and other modules X Y Z HALF Adder module HA( a, b, s, c) input a,b; output s, c; xor G1 (s, a, b); and G2 (c,a,b); FA1 S1 C1 HALF Adder FA2 C2 module FA(X,Y,Z,S,C input X, Y, Z; output S, C; HA FA1 (X, Y, S1, C HA FA2 (S1,Z, S, C2 or O1 (C, C2, D. Z. Pan 8 O1 S C Specification of Gate-Level Model Gate function Verilog built-in: and, nand, or, nor, xor, xnor, buf, not, etc. Gate specification format example: and #delay inst-name (out,in1, in2,...,ink); Delay and inst-name are optional D. Z. Pan 9 Logic Values A bit can have any of these values 0 representing logic low (false) 1 representing logic high (true) x representing either 0, 1, or z z representing high impedance for tri-state (unconnected inputs are set to z) A B F A 0 0 1 1 0 x x z x B 1 x z 0 x x 0 0 0 0 x x 0 x x F D. Z. Pan 10 Test Generation Test_gen: Generates test and capture the response FA: The design under test Wrapper: Wraps Test_gen and FA into one module Wrapper Test_gen X_o Y_o S_i C_i Input are generated in Test_gen X Y S C FA Response from the adder is read by Test_ge D. Z. Pan 11 module HA( a, b, s, c) input a,b; output s, c; xor G1 (s, a, b); and G2 (c,a,b); module FA(X,Y,Z,S,C); input X, Y, Z; output S, C; HA FA1 (X, Y, S1, C1); HA FA2 (S1,Z, S, C2); or O1 (C, C2, C1); Test Generation, Cont d module test_gen(a,b,c,sum,cout); output input a,b,c; sum, cout; reg a, b; initial $monitor($time," A=%b B=%b Sum=%b Cout=%b", a, b, sum, cout); a = 0; b=0; #5 = 1; #5 b = 1; #5 c = 1; module wrapper; wire a, b, sum, cout; FA(a,b,c,sum,cout); test_gen(a,b,c,sum,cout); - initial tells verilog to execute all statement within once it starts - monitor tells verilog to monitor the list of variables and everytime a var. changes it prints the string D. Z. Pan 12 D. Z. Pan 2

Test Generation, Cont d module test_gen(a,b,c,sum,cout); output input a,b,c; sum, cout; reg a, b; initial $monitor($time," A=%b B=%b a, b, Sum=%b sum, Cout=%b", cout); a = 0; b=0; c=0; #5 a 1; #5 b = 1; #5 c 1; module wrapper; wire a, b, sum, cout; FA(a,b,c,sum,cout); test_gen(a,b,c,sum,cout); cout sum C B A Time 0 5 10 15 D. Z. Pan 13 Behavioral Modeling Behavioral model consists of always and initial constructs All behavioral statements must be within these blocks Many initial/always statements can exist within module initial construct execute once at the start of the simulation initial statements always construct executes at the ning of the simulation and continually loops always @(sensitivity list) statements D. Z. Pan 14 Behavioral Timing Advance time when: #20 delay 20 time units @(list) delay until an event occurs wait: delay until a condition is satisfied @r rega = regb; // load rega when r changes @(posedge r) rega = regb; // load rega on positive edge of r @(negedge r) rega = regb; // load rega on negative edge of r wait(!r) rega = regb; // execution is susped until r is 0 module dff(q,qb,d,clk); input d, clk; output q, qb; reg q; Edge Triggered always @(posedge clk) q = d; // left hand side must be a register not G1 (qb, q); D Q QB D. Z. Pan 15 D. Z. Pan 16 Shift Register Is the order of execution important? module dff(q,d,clk); input d, clk; output q; reg q; always @(posedge clk) q = d; module shift(yo,xi,); input, XI; output YO; dff (d1,xi,); dff (d2,d1,); dff (YO,d2,); XI D Q D Q D Q d1 d2 YO D. Z. Pan 17 Behavioral Statements if( expr ) then statement; else statement; case(selector) val0: stat.; val1: stat.; default: stat; case; for(i=0; i < 10; i=i+1) A = B + i; i=0; while(i < 15) A = B + i; i = i + 1; D. Z. Pan 18 D. Z. Pan 3

Concurrent Constructs @ means wait for a change in value @(a) w = 4; Wait for 'a' to change to resume execution wait(condition) wait( a==1 ) w = 4; wait for a to become 1 to resume execution Another Example module mux(f, sel, b, a); input sel, b, a; output f; reg f; always @(sel or a or b) if( sel == 1 ) f = b; else f = a; assign f = sel? b : a; D. Z. Pan 19 D. Z. Pan 20 Case Statement module function_table(f,a,b,c); input a,b,c; output f; reg f; always @( a or b or c) case( {a,b,c} ) // concatenate a,b,c to form a 3 bit number 3'b000: f = 1'b0; 3'b001: f = 1'b1; 3'b010: f = 1'b0; 3'b011: f = 1'b0; 3'b100: f = 1'b0; 3'b101: f = 1'b1; 3'b110: f = 1'b0; 3'b111: f = 1'b0; case D. Z. Pan 21 module adder(co,su,a,b,ci); input a,b,ci; output co,su; Adder With Delays xor #(4,5) (sum, a, b, cin); // rise time=4, fall time = 5 or #5 (co, ab,bc,ac); // rise time = fall time = 5 and #(4,2) (ab,a,b). // three similar and gates (ac,a,ci), (bc,bci); D. Z. Pan 22 Blocking and Nonblocking Assignments Blocking assignments are executed in the order they are coded sequential execution of statements block the execution of the next statement till the current statement is executed a = b; Nonblocking assignments are executed in parallel execution of next statement is not blocked due to execution of current statement a <= b; D. Z. Pan 23 module adder(co,su,a,b,ci); input a,b,ci; output co,su; Adder With Continuous assign su = a ^ b ^ cin, co = a&b b&cin a&ci ; Another Version with Delays module adder(co,su,a,b,ci); input a,b,ci; output co,su; assign #(5,4) su = a ^ b ^ cin; assign #(10,4) co = a&b b&cin a&ci ; Specifies combinational logic Any time the right hand side changes, the simulator re-evaluates the output D. Z. Pan 24 D. Z. Pan 4

module counter(q, clock, clear); output [3:0] Q; input clock, clear; reg [3:0] Q; Counter always @( posedge clear or negedge clock) if (clear) Q = 4'd0; else Q = (Q + 1) ; // Q = (Q + 1) % 16; counter c1(q, CLOCK, CLEAR); Counter, Cont d initial $monitor($time, " Count Q = %b Clear= %b", Q[3:0],CLEAR); CLEAR = 1'b1; #34 CLEAR = 1'b0; #200 CLEAR = 1'b1; #50 CLEAR = 1'b0; #400 $stop; module stimulus; reg CLOCK, CLEAR; wire [3:0] Q; D. Z. Pan 25 initial CLOCK = 1'b0; forever #10 CLOCK = ~CLOCK; D. Z. Pan 26 Bus Select module select_bus( out, b0, b1, b2, b3, enable, s); parameter n = 16; parameter Z = 16'bz; // define a 16 bit of z output [1:n] out; // n-bit output input [1:n] b0, b1, b2, b3; // n-bit inputs input enable; input [1:2] s; tri [1:n] data; // tri-state net tri [1:n] out = enable? data: Z; // net declaration with // continuous assignment assign data = (s==0)? b0 : Z, // 4 continuous assignment data = (s==1)? b1 : Z, data = (s==2)? b2 : Z, data = (s==3)? b3 : Z; D. Z. Pan 27 Tri-State Latch module tri_latch( q, nq, clk, data, enable); output q, nq; input clk, data, enable; tri q, nq; not #5 (ndata, data); nand #(3, 5) (wa, data, clk), (wb, ndata, clk); nand #(12,15) (ql, nql, wa), (nql, ql, wb); bufif1 #(3,5,13) // rise, fall, change to z q_dr ( q, ql, enable), // when enable = 1, q=ql nq_dr (nq, nql, enable); // when enable = 0, q=ql=z D. Z. Pan 28 User-Defined Primitives primitive mux(mux,cntr,a,b); output mux; input cntr, A, B; table // cntr A B mux 0 1? : 1 ; //? represents don t care 0 0? : 0 ; 1? 0 : 0 ; 1? 1 : 1 ; x 0 0 : 0 ; x 1 1 : 1 ; table primitive D. Z. Pan 29 User-Defined Primitives, Cont d primitive latch(q, clk, data); output q; reg q; input clk, data; table // clk data state output/nxtstate 0 1 :? : 1 ; 0 0 :? : 0 ; 1? :? : - ; // represent no change table primitive primitive D. Z. Pan 30 D. Z. Pan 5

module mult( res, a, b); parameter size = 8, longsize = 16; input [size:1] a, b; output [longsize:1] res; reg [size:1] a, b; reg [longsize:1] res; Looping always @( a or b) :mult reg [longsize:1] shifta, shiftb; shifta = a; shiftb = b; result = 0; repeat (size) if( shiftb[1] ) // check if bit1 == 1 res = res + shifta; shifta = shifta << 1; shiftb = shiftb >> 1; D. Z. Pan 31 module count_ones( res, a); output [3:0] res; reg [3:0] res; input [7:0] a; Looping, Cont d always @(a) :count1s reg [7:0] tempa; res = 0; tempa = a; while(tempa) // while tempa!= 0 if( tempa[0] ) res = res + 1; tempa= tempa>> 1; D. Z. Pan 32 Parallel Blocks Statements executed concurrently Delay values for each statement are relative to the simulation when control enters block Control passed out of the block when the last time-ordered statement is executed Order of statements is not important Parallel block fork #100 r = 100; #50 r = 50; #150 r = 150; join Equivalent sequential block assuming c changes every 50 units: @c r = 50; @c r = 150; @c r = 200; D. Z. Pan 33 More Examples areg is loaded when both A and B occur in any order fork @A; @B; join areg = breg; D. Z. Pan 34 Tasks Task Format Tasks provide a way to execute common procedures at different places They provide the means of breaking a large procedure into smaller ones They make it easy to debug and read the source code task proc_name; input a, b; inout c; output d, e; task <<statement>> This can be enabled by: proc_name(v, w, x, y, z); which performs the following assignment: a = v ; b = w; c = x; Following performed upon completion of the task: x = c; y = d; z = e; D. Z. Pan 35 D. Z. Pan 36 D. Z. Pan 6

Functions Functions differ from tasks in the following ways: They return a value to be used in an expression They must have zero simulation time duration They must have at least one input function [7:0] func_name; input [15:0] a; <<statement>>; func_name = expression; function Function Format To enable this: new_address = b * func_name(old_address) D. Z. Pan 37 D. Z. Pan 38 Latches and Flip-Flops (Flops) Latch is synthesized if you write: always @() if () LatchOut = LatchInput Flop is synthesized with: always @(posedge ) LatchOut = LatchInput D. Z. Pan 39 D. Z. Pan 7