Lecture Note on Verilog, Course #90132300, EE, NTU, C.H Tsai Basic Logic Design with Verilog TA: Chen-han Tsai.

Slides:



Advertisements
Similar presentations
Verilog.
Advertisements

Simulation executable (simv)
Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
ELEN 468 Lecture 21 ELEN 468 Advanced Logic Design Lecture 2 Hardware Modeling.
Chapter 11 Verilog HDL Application-Specific Integrated Circuits Michael John Sebastian Smith Addison Wesley, 1997.
Verilog Intro: Part 1.
Hardware Description Language (HDL)
Combinational Logic with Verilog Materials taken from: Digital Design and Computer Architecture by David and Sarah Harris & The Essentials of Computer.
16/04/20151 Hardware Descriptive Languages these notes are taken from Mano’s book It can represent: Truth Table Boolean Expression Diagrams of gates and.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part3: Verilog – Part 1.
Logic Values 0:logic 0 / false 1:logic 1 / true X:unknown logic value Z:high-impedance.
CSE 341 Verilog HDL An Introduction. Hardware Specification Languages Verilog  Similar syntax to C  Commonly used in  Industry (USA & Japan) VHDL 
1 Hardware description languages: introduction intellectual property (IP) introduction to VHDL and Verilog entities and architectural bodies behavioral,
ENEE 408C Lab Capstone Project: Digital System Design Verilog Tutorial Class Web Site:
ECE 353 Computer Systems Lab I Verilog Hardware Description Language.
Verilog Lab This presentation includes some material that is selected from BUCKNELL VERILOG HANDBOOK. Instructor: Dr. Charles Liu Prepared by John Ren.
Silicon Programming--Intro. to HDLs1 Hardware description languages: introduction intellectual property (IP) introduction to VHDL and Verilog entities.
CSE241 R1 Verilog.1Kahng & Cichy, UCSD ©2003 CSE241 VLSI Digital Circuits Winter 2003 Recitation 1: Verilog Introduction.
Reconfigurable Computing (EN2911X, Fall07) Lecture 05: Verilog (1/3) Prof. Sherief Reda Division of Engineering, Brown University
Computer Organization Lecture Set – 03 Introduction to Verilog Huei-Yung Lin.
University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Digital System Design EEE344 Lecture 3 Introduction to Verilog HDL Prepared by: Engr. Qazi Zia, Assistant Professor EED, COMSATS Attock1.
Guest Lecture by Ben Magstadt CprE 281: Digital Logic.
Guest Lecture by Ben Magstadt CprE 281: Digital Logic.
Programmable Logic Architecture Verilog HDL FPGA Design Jason Tseng Week 2-3.
ECE 2372 Modern Digital System Design
Verilog Language Concepts
CS 3850 Lecture 3 The Verilog Language. 3.1 Lexical Conventions The lexical conventions are close to the programming language C++. Comments are designated.
1 An Update on Verilog Ξ – Computer Architecture Lab 28/06/2005 Kypros Constantinides.
Digital System 數位系統 Verilog HDL Ping-Liang Lai (賴秉樑)  
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.
1 Hardware description languages: introduction intellectual property (IP) introduction to VHDL and Verilog entities and architectural bodies behavioral,
ELEE 4303 Digital II Introduction to Verilog. ELEE 4303 Digital II Learning Objectives Get familiar with background of HDLs Basic concepts of Verilog.
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
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
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Logic Design Dr. Oliver Faust.
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,
CprE 281: Verilog Tutorial Ben Magstadt – Master’s Student Electrical Engineering.
Introduction to Verilog. Structure of a Verilog Program A Verilog program is structured as a set of modules, which may represent anything from a collection.
1 University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Exp#5 & 6 Introduction to Verilog COE203 Digital Logic Laboratory Dr. Ahmad Almulhem KFUPM Spring 2009.
1 A hardware description language is a computer language that is used to describe hardware. Two HDLs are widely used Verilog HDL VHDL (Very High Speed.
Introduction to Verilog COE 202 Digital Logic Design Dr. Muhamed Mudawar King Fahd University of Petroleum and Minerals.
Lecture note ver.1 by Chen-han Tsai ver.2 by Chih-hao Chao
TODAY’S OUTLINE Introduction to Verilog Verilog coding format
University of Maryland Baltimore County Department of Computer Science and Electrical Engineering   CMPE 212 Laboratory (Discussion 2) Hasibul Hasan
Introduction to Verilog
Discussion 2: More to discuss
Verilog Introduction Fall
KARTHIK.S Lecturer/ECE S.N.G.C.E
Verilog-HDL-3 by Dr. Amin Danial Asham.
Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-I]
Introduction to Verilog
Behavioral Modeling in Verilog
Week 5, Verilog & Full Adder
Introduction to Verilog
102-1 Under-Graduate Project Verilog
Hardware Descriptive Languages these notes are taken from Mano’s book
Introduction to Verilog
COE 202 Introduction to Verilog
Reconfigurable Computing (EN2911X, Fall07)
EEL4712 Digital Design (VHDL Tutorial).
Presentation transcript:

Lecture Note on Verilog, Course # , EE, NTU, C.H Tsai Basic Logic Design with Verilog TA: Chen-han Tsai

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Outline Introduction to HDL/ Verilog Gate Level Modeling Behavioral Level Modeling Test bench Summary and Notes Simulation using Silos

Lecture Note on Verilog, Course # , EE, NTU, C.H Tsai Introduction to HDL/ Verilog

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 What is HDL/Verilog Why use HDL (Hardware Description Language)? HDL ←→ layout by human Reduce cost and time Verilog is one of the most popular HDLs VHDL (another popular HDL) Key features of Verilog Supports Various levels Behavior level (Register Transfer Level, RTL) Gate level Switch level Simulate design functions

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Hardware Design Flow Verilog

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 An Example 1-bit Multiplexer

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Gate Level Description a1 a2 in1 in2 sel out o1o1 iv_sel a1_o a2_o n1 iv_sel Gate Level: you see only gates and wires in the code

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Behavioral Level Description RTL: you may see high level behavior in the code always block assign

Lecture Note on Verilog, Course # , EE, NTU, C.H Tsai Verilog HDL Syntax

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 A Simple Verilog Code declaration syntax module name in/out port port/wire declaration kernel hardware gate-connection/ behavior

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 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

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Module Instantiation instance example

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Port Connection Connect module port by order list FA1 fa1(c_o, sum, a, b, c_i); Not fully connected FA1 fa3(c_o,, a, b, c_i); Connect module port by name FA1 fa2(.A(a),.B(b),.CO(c_o),.CI(c_i),.S(sum)); Recommended

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Verilog Language Rule Case sensitive Identifiers: Digits 1 … 9 Underscore _ Upper and lower case letters from the alphabet Terminate line with semicolon “ ; ” Comments: Single line: // it ’ s a single line comment example Multiline: /* when the comment exceeds single line, multiline comment is necessary*/

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Register and Net Registers Keyword :reg, integer, time, real Storage element Assignment in “ always ” block 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

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Value and Number expressions Verilog value set consists of four basic values: 0 represent a logic zero or false condition 1 represent a logic one or true condition x represent an unknown logic value z represent a high-impedance stage

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Value and Number Expressions : Examples 659// unsized decimal ‘ h 837ff// unsized hexadecimal ‘ o7460// unsized octal 4af// illegal syntax 4 ’ b1001// 4-bit binary 5 ’ D 3// 5-bit decimal 3 ’ b01x// 3-bit number with unknown LSB 12 ’ hx// 12-bit unknown 8 ’ d -6// illegal syntax -8 ’ d 6// phrase as - (8 ’ d6) // underline usage 27_195_000 16’b0001_0101_0001_ ’h12ab_f001 // X and Z is sign-extended reg [11:0] a; initial begin a = ‘hx;// yields xxx a = ‘h3x;// yields 03x a = ‘h0x;// yields 00x end

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Net Concatenations : An Easy Way to Group Nets RepresentationsMeanings {b[3:0],c[2:0]} {b[3],b[2],b[1],b[0], c[2],c[1],c[0]} {a,b[3:0],w,3’b101} {a,b[3],b[2],b[1],b[0],w,1’b1,1’b0,1’b1} {4{w}} {w,w,w,w} {b,{3{a,b}}} {b,a,b,a,b,a,b} 3‘o7 Module A Module B Module C

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 (excerpts from CIC training course : Verilog_9807.pdf)

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 (excerpts from CIC training course : Verilog_9807.pdf)

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Compiler Directives `define `define RAM_SIZE 16 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. Only 1, 10, and 100 are legal values.

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 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 Terminate the simulation

Lecture Note on Verilog, Course # , EE, NTU, C.H Tsai Gate Level Modeling Primitives Case Study

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Gate Level Modeling Steps Design the smallest sub-modules Construct modules with built sub-modules Connections Use “ assign a = b; ” to connect a and b (a is driven by b) HDL: Hardware Description Language Architecture figure first, then start to write code!!

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Primitives Primitives are modules ready to be instanced Verilog build-in primitive gate not, buf and, or, not, buf, xor, nand, nor, xnor Design ware Vender-provided primitive gates User-built primitive gate Your building block modules (sub-modules)

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Case Study 1-bit Full Adder

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Case Study 1-bit Full Adder Co = (A ‧ B ‧ Ci ’ )+(A ‧ B ’ ‧ Ci)+(A ’ ‧ B ‧ Ci)+(A ‧ B ‧ Ci) = (A ‧ B ‧ Ci ’ )+(A ‧ B ’ ‧ Ci)+ (B ‧ Ci) = { A ‧ [ (B ‧ Ci ’ )+(B ’ ‧ Ci) ] } + (B ‧ Ci)

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Case Study 1-bit Full Adder S = (A ’ ‧ B ’ ‧ Ci)+(A ’ ‧ B ‧ Ci ’ )+(A ‧ B ’ ‧ Ci ’ )+(A ‧ B ‧ Ci) = { A ’ ‧ [ (B ’ ‧ Ci)+(B ‧ Ci ’ ) ] } + { A ‧ [ (B ’ ‧ Ci ’ )+(B ‧ Ci) ] }

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Case Study 1-bit Full Adder Design hierarchy

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Case Study 1-bit Full Adder Basic gate: 1-bit AND

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Case Study 1-bit Full Adder Basic gate: 1-bit OR

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Case Study 1-bit Full Adder Connect co Instance AND, OR gates

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Case Study 1-bit Full Adder Connect s Instance AND, OR gates

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Case Study 1-bit Full Adder Full Adder Connection Instance co, s

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Case Study 1-bit Full Adder Code

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 However … Further Reduction is Possible

Lecture Note on Verilog, Course # , EE, NTU, C.H Tsai Behavioral Level Modeling Case Study

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Behavioral Level Modeling High level description User friendly Concise code Widely used for some common operations +,-,* &,|,~ Two main formats always block assign

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Case Study 1-bit Full Adder

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Case Study 1-bit Full Adder

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Case Study 1-bit Full Adder LHS signals in always block should be declared as “reg”

Lecture Note on Verilog, Course # , EE, NTU, C.H Tsai Test bench

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Test bench Usage

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Summary Design module Gate level or behavior level Real hardware Modules exists 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++

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 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 (today ’ s topic) 畫圖 (architecture), then 連連看 (coding) Sequential circuits (next topic) register: element to store data

Lecture Note on Verilog, Course # , EE, NTU, C.H Tsai Simulation using Silos

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Create new project Write your verilog design code Create a new project: Project -> New -> (enter your project name) Include your verilog file(s) (choose your.v file) -> (click Add bottom) -> (click OK) Note that testbench should be included Then run and debug

Lecture Note on Vrilog, Course # , EE, NTU C.H Tsai, 10/29/2004 Run and Debug Run Press F5 or click the “ GO ” icon on tool bar An output window is generated to show whether there exists errors. Debug Press “ open analyzer ” on the toolbar Press “ open explorer ” on the toolbar Choose signals you want to watch Click right button and select “ Add signal to analyzer ” Then you can debug with waveform