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

Similar documents
101-1 Under-Graduate Project Digital IC Design Flow

Verilog HDL Introduction

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

Verilog Tutorial (Structure, Test)

Graduate Institute of Electronics Engineering, NTU Basic Concept of HDL

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

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

Contents. Appendix D Verilog Summary Page 1 of 16

Lecturer: Chihhao Chao ( 趙之昊 ) Date:

Introduction to Verilog

Online Verilog Resources

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

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

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

Digital Design with FPGAs. By Neeraj Kulkarni

A Verilog Primer. An Overview of Verilog for Digital Design and Simulation

Introduction to Verilog HDL. Verilog 1

Verilog Design Principles

Chapter 2 Using Hardware Description Language Verilog. Overview

Hardware Description Languages (HDLs) Verilog

EN2911X: Reconfigurable Computing Topic 02: Hardware Definition Languages

Verilog Design Principles

Advanced Digital Design with the Verilog HDL

Department of Computer Science and Electrical Engineering. Intro to Verilog II

Design Using Verilog

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

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

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

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

RIZALAFANDE CHE ISMAIL TKT. 3, BLOK A, PPK MIKRO-e KOMPLEKS PENGAJIAN KUKUM. SYNTHESIS OF COMBINATIONAL LOGIC (Chapter 8)

Synthesizable Verilog

EECS150 - Digital Design Lecture 10 Logic Synthesis

EECS150 - Digital Design Lecture 10 Logic Synthesis

Hardware description languages

Introduction to Verilog/System Verilog

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

Hardware description language (HDL)

Combinational Logic Design with Verilog. ECE 152A Winter 2012

Verilog Fundamentals. Shubham Singh. Junior Undergrad. Electrical Engineering

Verilog Design Entry, Synthesis, and Behavioral Simulation

Introduction To Verilog Design. Chun-Hung Chou

C-Based Hardware Design

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

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

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

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

Hardware Description Language VHDL (1) Introduction

Verilog HDL. A Guide to Digital Design and Synthesis. Samir Palnitkar. SunSoft Press A Prentice Hall Title

Introduction to Verilog. Mitch Trope EECS 240 Spring 2004

CSE140L: Components and Design Techniques for Digital Systems Lab

A Brief Introduction to Verilog Hardware Definition Language (HDL)

EEL 4783: HDL in Digital System Design

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

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

CSE140L: Components and Design

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

CSE140L: Components and Design Techniques for Digital Systems Lab. Verilog HDL. Instructor: Mohsen Imani UC San Diego. Source: Eric Crabill, Xilinx

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

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

Introduction to Verilog HDL

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

Advanced Digital Design Using FPGA. Dr. Shahrokh Abadi

Digital Design Using VHDL Using Xilinx s Tool for Synthesis and ModelSim for Verification

Logic Synthesis. EECS150 - Digital Design Lecture 6 - Synthesis

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

EGC220 - Digital Logic Fundamentals

Combinational Logic II

Lab 7 (All Sections) Prelab: Introduction to Verilog

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

ENGN1640: Design of Computing Systems Topic 02: Lab Foundations

Lecture 15: System Modeling and Verilog

Chap 3. Modeling structure & basic concept of Verilog HDL

Synthesis of Combinational and Sequential Circuits with Verilog

Verilog introduction. Embedded and Ambient Systems Lab

ECEN 468 Advanced Digital System Design

Module 4. Design of Embedded Processors. Version 2 EE IIT, Kharagpur 1

ECE 353 Lab 3 (Verilog Design Approach)

Chapter 2a: Structural Modeling

VHDL for Synthesis. Course Description. Course Duration. Goals

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

CSE 591: Advanced Hardware Design and Verification (2012 Spring) LAB #0

structure syntax different levels of abstraction

Here is a list of lecture objectives. They are provided for you to reflect on what you are supposed to learn, rather than an introduction to this

Verilog 1 - Fundamentals

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

Chap 6 Introduction to HDL (d)

Tutorial on Verilog HDL

EE 8351 Digital Logic Circuits Ms.J.Jayaudhaya, ASP/EEE

Verilog Hardware Description Language ROOM: B405

ECE U530 Digital Hardware Synthesis. Course Accounts and Tools

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

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

Under-Graduate Project Logic Design with Behavioral Models

Image Courtesy CS250 Section 2. Yunsup Lee 9/4/09

UNIT V: SPECIFICATION USING VERILOG HDL

Introduction. Why Use HDL? Simulation output. Explanation

Lecture 3: Modeling in VHDL. EE 3610 Digital Systems

DIGITAL SYSTEM DESIGN

Combinational Logic. Prof. Wangrok Oh. Dept. of Information Communications Eng. Chungnam National University. Prof. Wangrok Oh(CNU) 1 / 93

Verilog 1 - Fundamentals

Transcription:

99-1 Under-Graduate Project Verilog Simulation & Debugging Tools Speaker: Shao-Wei Feng Adviser: Prof. An-Yeu Wu Date: 2010/09/28 ACCESS IC LAB

Outline Basic Concept of Verilog HDL Gate Level Modeling Simulation & Verification Summary P. 2

What is Verilog HDL? Hardware Description Language Mixed level modeling Behavioral Algorithmic ( like high level language) Register transfer (Synthesizable) Register Transfer Level (RTL) Describing a system by the flow of data and control signals within and between functional blocks Define the model in terms of cycles, based on a defined clock Structural Gate (AND, OR ) Switch (PMOS, NMOS, JFET ) P. 3

An Example 1-bit Multiplexer to select output sel sel in1 in2 out in1 in2 0 1 out 0 0 0 0 0 0 1 0 0 1 0 1 0 1 1 1 1 0 0 0 if (sel==0) out=in1; else out=in2; 1 0 1 1 1 1 0 0 1 1 1 1 out = (sel in1) + (sel in2) P. 4

Gate Level Description in1 in2 iv_sel n1 a1 a2 a1_o a2_o o 1 out sel iv_sel Gate Level: you see only netlist (gates and wires) in the code P. 5

Verilog Language Rules Verilog is a case sensitive language (with a few exceptions) Identifiers (space-free sequence of symbols) upper and lower case letters from the alphabet digits (0, 1,..., 9) (cannot be the first character) underscore ( _ ) $ symbol (only for system tasks and functions) Max length of 1024 symbols Terminate lines with semicolon ; Single line comments: // A single-line comment goes here Multi-line comments: /* Multi-line comments like this */ P. 6

Verilog HDL Syntax module name in/out port declaration syntax port/wire declaration kernel hardware gate-connection/ behavior P. 7

Module Basic building block in Verilog. Module 1. Created by declaration (can t be nested) 2. Used by instantiation Interface is defined by ports May contain instances of other modules All modules run concurrently P. 8

Instances A module provides a template from which you can create actual objects. When a module is invoked, Verilog creates a unique object from the template. Each object has its own name, variables, parameters and I/O interface. P. 9

Module Instantiation Adder instance example Adder Adder Adder_tree P. 10

Port Connection Connect module port by order list FA1 fa1(c_o, sum, a, b, c_i); Connect module port by name.portname( NetName ) FA1 fa2(.a(a),.b(b),.co(c_o),.ci(c_i),.s(sum)); Recommended P. 11

Value Sets 4-value logic system in Verilog Four values: 0, 1, x or X, z or Z // Not case sensitive here P. 12

Registers Register and Net Keyword : reg, integer, time, real Event-driven modeling Storage element (modeling sequential circuit) Assignment in always block Default value is X Nets Keyword : wire, wand, wor, tri triand, trior, supply0, supply1 Doesn t store value, just a connection input, output, inout are default wire Can t appear in always block assignment Default value is Z P. 13

Wire & Reg reg A variable in Verilog Use of reg data type is not exactly synthesized to a really register. Use of wire & reg When use wire usually use assign and assign does not appear in always block When use reg only use a=b, always appear in always block module test(a,b,c,d); input a,b; output c,d; reg d; assign c=a; always @(b) d=b; endmodule P. 14

Choosing the Correct Data Types An input or inout port must be a net. An output port can be a register data type. A signal assigned a value in a procedural block must be a register data type. P. 15

Number Representation Format: <size> <base_format><number> <size> - decimal specification of number of bits default is unsized and machine-dependent but at least 32 bits <base format> - ' followed by arithmetic base of number <d> <D> - decimal - default base if no <base_format> given <h> <H> - hexadecimal <o> <O> - octal <b> <B> - binary <number> - value given in base of <base_format> _ can be used for reading clarity If first character of sized, binary number 0, 1, x or z, will extend 0, 1, x or z (defined later!) P. 16

Examples: Number Representation 6 b010_111 gives 010111 8 b0110 gives 00000110 4 bx01 gives xx01 16 H3AB gives 0000001110101011 24 gives 0 0011000 5 O36 gives 11110 16 Hx 8 hz gives xxxxxxxxxxxxxxxx gives zzzzzzzz P. 17

Net Concatenations A easy way to group nets Representation {cout, sum} {b[7:4],c[3:0]} {a,b[3:1],c,2 b10} Meanings {cout, sum} {b[7], b[6], b[5], b[4], c[3], c[2], c[1], c[0]} {a, b[3], b[2], b[1], c, 1 b1, 1 b0} {4{2 b01}} 8 b01010101 {{8{byte[7]}},byte} Sign extension P. 18

`define `define RAM_SIZE 16 Compiler Directives Defining a name and gives a constant value to it. `include `include adder.v Including the entire contents of other verilog source file. `timescale `timescale 100ns/1ns Setting the reference time unit and time precision of your simulation. P. 19

System Tasks $monitor $monitor ($time,"%d %d %d",address,sinout,cosout); Displays the values of the argument list whenever any of the arguments change except $time. $display $display ("%d %d %d",address,sinout,cosout); Prints out the current values of the signals in the argument list $finish $finish Terminate the simulation P. 20

Gate Level Modeling ACCESS IC LAB

Steps Gate Level Modeling Develop the boolean function of output Draw the circuit with logic gates/primitives Connect gates/primitives with net (usually wire) HDL: Hardware Description Language Figure out architecture first, then write code. P. 22

Primitives Primitives are modules ready to be instanced Smallest modeling block for simulator Verilog build-in primitive gate and, or, not, buf, xor, nand, nor, xnor prim_name inst_name( output, in0, in1,... ); EX. and g0(a, b, c); User defined primitive (UDP) building block defined by designer P. 23

Case Study 1-bit Full Adder A B Ci A B Co S 0 0 0 0 0 0 0 1 0 1 Co Full Adder Ci 0 1 0 0 1 0 1 1 1 0 1 0 0 0 1 1 0 1 1 0 S 1 1 0 1 0 1 1 1 1 1 P. 24

Case Study 1-bit Full Adder co = (a b) + (b ci) + (ci a); a b b c c a co P. 25

Case Study 1-bit Full Adder a b c sum = a b ci sum a b c sum P. 26

Case Study 1-bit Full Adder Full Adder Connection Instance ins_c from FA_co Instance ins_s from FA_sum a b b c c a full adder carry out connection co a b c sum connection sum P. 27

Timing and Delays ACCESS IC LAB

Delay Specification in Primitives Delay specification defines the propagation delay of that primitive gate. not #10 (out,in); P. 29

Types of Delay Models Distributed Delay Specified on a per element basic Delay value are assigned to individual in the circuit a b c d #5 #7 e f #4 out module and4(out, a, b, c, d); and #5 a1(e, a, b); and #7 a2(f, c, d); and #4 a3(out, e, f); endmodule P. 30

Lumped Delay Types of Delay Models They can be specified as a single delay on the output gate of the module The cumulative delay of all paths is lumped at one location a b c d e f #11 out module and4(out, a, b, c, d); and a1(e, a, b); and a2(f, c, d); and #11 a3(out, e, f); endmodule P. 31

Pin-to-Pin Delay Types of Delay Models Delays are assigned individually to paths from each input to each output. Delays can be separately specified for each input/output path. a b c d e f out Path a-e-out, delay = 9 Path b-e-out, delay =9 Path c-f-out, delay = 11 Path d-f-out, delay = 11 P. 32

Timing Checks setup and hold checks clock data setup time hold time specify $setup(data, posedge clock, 3); endspecify specify $hold(posedge clock, data, 5); endspecify P. 33

Simulation & Verification ACCESS IC LAB

Test Methodology Test bench Systematically verify the functionality of a model. data_i Simulation: (1) detect syntax violations in input ports source code (2) simulate behavior (3) monitor results Design Top Module answer_o output ports Equal? data_o P. 35

Testbench for Full Adder module t_full_add(); reg a, b, cin; // for stimulus waveforms wire sum, c_out; full_add M1 (sum, c_out, a, b, cin); //DUT initial #200 $finish; // Stopwatch initial begin // Stimulus patterns $fsdbdumpfile( t_full_add.fsdb ); $fsdbdumpvars; #10 a = 0; b = 0; cin = 0; // Statements execute in sequence #10 a = 0; b = 1; cin = 0; #10 a = 1; b = 0; cin = 0; #10 a = 1; b = 1; cin = 0; #10 a = 0; b = 0; cin = 1; #10 a = 0; b = 1; cin = 1; #10 a = 1; b = 0; cin = 1; #10 a = 1; b = 1; cin = 1; end endmodule P. 36

Simulation Results MODELING TIP A Verilog simulator assigns an initial value of x to all variables. P. 37

Example: Propagation Delay Unit-delay simulation reveals the chain of events module Add_full (sum, c_out, a, b, c_in); output sum, c_out; input a, b, c_in; wire w1, w2, w3; Add_half M1 (w1, w2, a, b); Add_half M2 (sum, w3, w1, c_in); or #1 M3 (c_out, w2, w3); endmodule module Add_half (sum, c_out, a, b); output sum, c_out; input a, b; xor and endmodule #1 M1 (sum, a, b); // single delay value format #1 M2 (c_out, a, b); // others are possible P. 38

Simulation with delay P. 39

Summary Design module Gate-level or RT-level Real hardware Instance of modules exist all the time Each module has architecture figure Plot architecture figures before you write verilog codes Test bench Feed input data and compare output values versus time Usually behavior level Not real hardware, just like C/C++ P. 40

Note Verilog is a platform Support hardware design (design module) Also support C/C++ like coding (test bench) How to write verilog well Know basic concepts and syntax Get a good reference (a person or some code files) Form a good coding habit Naming rule, comments, format partition (assign or always block) Hardware Combinational circuits 畫圖 (architecture), then 連連看 (coding) Sequential circuits register: element to store data P. 41

Simulation & Debugging Tools ACCESS IC LAB

Verilog Simulator(1/2) P. 43

Verilog Simulator(2/2) Xilinx ISE Inventing the field programmable gate array (FPGA) Verilog Simulation Synthesis for FPGA ModelSim Verilog Simulation Only (But Powerful) P. 44

Xilinx ISE (1/5) Create a New Project File -> New Project Project Name & Location Type of top module (Can choose HDL) P. 45

Xilinx ISE (2/5) Next -> Project Wizard switches to the ``Device Properties'' window Your FPGA specification P. 46

Xilinx ISE (3/5) P. 47

Xilinx ISE (4/5) Project -> Add Source Double click Can modify your code P. 48

Xilinx ISE (5/5) Processes -> Xilinx ISE Simulator P. 49

ModelSim (1/8) There are some packages (for VHDL) in library, you can see then by edit. P. 50

ModelSim (2/8) File \ New \ Project... Insert the project name and location There are Viterbi.cr.mti Viterbi.mpf in the work forder.mpf include information of the project, so when you want to open the project, File \ Open \ Project... Open.mpf Add items to the project P. 51

ModelSim (3/8) Or use File \ Add to Project \ Existing Files... The direction path can not use Chiness. You can add and remove in work space. P. 52

ModelSim (4/8) Compile P. 53

ModelSim (5/8) P. 54

Simulate (Loading) ModelSim (6/8) P. 55

ModelSim (7/8) Open signals window:view \ Signals P. 56

ModelSim (8/8) Add to Wave \ Selected Signals P. 57