ECE 171 Digital Circuits Chapter 8 Hardware Description Language

Slides:



Advertisements
Similar presentations
The Verilog Hardware Description Language
Advertisements

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.
CSE 201 Computer Logic Design * * * * * * * Verilog Modeling
CSE 341 Verilog HDL An Introduction. Hardware Specification Languages Verilog  Similar syntax to C  Commonly used in  Industry (USA & Japan) VHDL 
Introduction to VHDL (Lecture #5) ECE 331 – Digital System Design The slides included herein were taken from the materials accompanying Fundamentals of.
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.
CSE241 R1 Verilog.1Kahng & Cichy, UCSD ©2003 CSE241 VLSI Digital Circuits Winter 2003 Recitation 1: Verilog Introduction.
VHDL. What is VHDL? VHDL: VHSIC Hardware Description Language  VHSIC: Very High Speed Integrated Circuit 7/2/ R.H.Khade.
University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
B. RAMAMURTHY Hardware Description Language 8/2/
Lecture 7 Verilog Additional references Structural constructs
COMP541 Combinational Logic - I
ECE 332 Digital Electronics and Logic Design Lab Lab 5 VHDL Design Styles Testbenches.
ECE 2372 Modern Digital System Design
ECE/CS 352 Digital Systems Fundamentals
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.
Introduction to VHDL Spring EENG 2920 Digital Systems Design Introduction VHDL – VHSIC (Very high speed integrated circuit) Hardware Description.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
Fall 2004EE 3563 Digital Systems Design EE 3563 VHSIC Hardware Description Language  Required Reading: –These Slides –VHDL Tutorial  Very High Speed.
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
Chapter 5 Introduction to VHDL. 2 Hardware Description Language A computer language used to design circuits with text-based descriptions of the circuits.
CEC 220 Digital Circuit Design Introduction to VHDL Wed, February 25 CEC 220 Digital Circuit Design Slide 1 of 19.
ELEE 4303 Digital II Introduction to Verilog. ELEE 4303 Digital II Learning Objectives Get familiar with background of HDLs Basic concepts of Verilog.
Introduction to ASIC flow and Verilog HDL
ECE 171 Digital Circuits Chapter 8 Hardware Description Language Herbert G. Mayer, PSU Status 11/23/2015 Copied with Permission from prof. Mark
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,
CEC 220 Digital Circuit Design Introduction to VHDL Wed, Oct 14 CEC 220 Digital Circuit Design Slide 1 of 19.
1 University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
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.
Hardware Description Languages: Verilog
Hardware Description Language
Discussion 2: More to discuss
Verilog-HDL-1 by Dr. Amin Danial Asham.
KARTHIK.S Lecturer/ECE S.N.G.C.E
Verilog-HDL-3 by Dr. Amin Danial Asham.
Hardware Description Languages: Verilog
Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-I]
Chapter 4 Combinational Logic
Hardware Descriptive Languages these notes are taken from Mano’s book
Hardware Description Language
Behavioral Modeling in Verilog
Combinatorial Logic Design Practices
Hardware Description Language
Introduction to Verilog
Lecture 1.3 Hardware Description Languages (HDLs)
102-1 Under-Graduate Project Verilog
Hardware Descriptive Languages these notes are taken from Mano’s book
Introduction to Digital System and Microprocessor Design
Hardware Description Language
Digital Fundamentals Floyd Chapter 4 Tenth Edition
Hardware Description Language
Chapters 4 – Part3: Verilog – Part 1
Hardware Description Language
The Verilog Hardware Description Language
COE 202 Introduction to Verilog
EEL4712 Digital Design (VHDL Tutorial).
Presentation transcript:

ECE 171 Digital Circuits Chapter 8 Hardware Description Language Herbert G. Mayer, PSU Status 4/19/2016 Copied with Permission from prof. Mark Faust @ PSU ECE

Syllabus Definitions HDL Design Flow Modules Verilog Verilog Syntax Full Adder Test bench Timing Diagram

Definitions HDL: Hardware description language; specifies structure and behavior of electric circuits via program text IC: Integrated Circuit Module: Largest syntactic unit of HDL that specifies electric behavior; defines inputs, outputs, connections (wires), and actions = behavior; example: Verilog VHDL: VHSIC Hardware Description language; can be used as GP programming language VHSIC: Very High Speed Integrated Circuit

Hardware Description Languages (HDL) Benefits Complete, unambiguous specification of design Inputs, outputs, behavior, timing Simulation for design, test, debug Which speeds up design time And increases test coverage Synthesis for physical realization of design Several widely used ABEL – primarily for PLDs VHDL (VHSIC Hardware Description Language) Verilog (1995, 2001) Numerous tools and vendors Design, capture, edit, simulate, synthesize…

Design Flow

Modules Different types of module descriptions Structural – actual gates Behavioral – behavior, e.g. Verilog Dataflow – simple output  F(inputs) Combination of above

Verilog Syntax Case sensitive “module”, “Module”, “MODULE” not same Reserved keywords are lower case (e.g. “module”) User-defined identifiers (e.g. variables, modules, ports) no requirements Useful convention: use mixed case, leading capitals “BufferFull” not “bufferfull” or “BUFFERFULL” White space (e.g. spaces, line breaks ) generally ignored Separate lexical tokens Use it to make your modules readable Comments // single line comments /* multiple line comments */ Note that this is dataflow

Verilog Syntax Identifiers 4 Valued Logic Begin with letter or underscore _ Contain letters, digits, underscores, $ Max length 25; advice: keep shorter! 4 Valued Logic 0, 1, X, Z X for “unknown” Z for high-impedance, or not connected Literals (e.g. numbers, bit strings, characters) n’Bddd…d n and ‘ are optional n = (decimal) number of units B = radix; options for radix are: b = binary o = octal h = hexadecimal d = decimal ddd…d = digits in designated radix R = 4’b1010; R = 4’hA; R = 4’o12; R = 4’d10; R = 10;

Verilog Operators Bit-wise Boolean Arithmetic and shift Logical Misc: concatenation, replication

Verilog Vectors Signals or ports with width > 1 Single bit select Zbus[5] Range of bits word1[15:8]

Verilog Instantiating a module Two forms of parameter lists component name instance identifier Two forms of parameter lists By order of declaration By explicit port name: allows permutation, skip!

Verilog Dataflow Example: Full Adder

Verilog Dataflow Example: Full Adder Students: Define S in class, think of xor Students: Define CO in class

Verilog Dataflow Example: Full Adder

Verilog Structural Example: Full Adder

A TestBench Key tool for design verification Provides stimulus to module being tested Must obey interface and protocol Interface: signal direction and width (e.g. bus) Protocol: timing and edge relationships Facilitates response from module TestBench can be written to independently verify response Human can examine waveforms produced in simulation TestBench can be written to format response (e.g. table) for later examination or processing Is a Verilog module!

A TestBench Module TestBench 0 1 1 0 1 0 0 1 0 0 0 0 1 0 0 TestBench TestBench instantiates module and provides necessary inputs, called test vectors Declares registers (“reg”) which will be connected to the module input ports Declares wires which will be connected to the module output ports

Testbench Example

A Complete Example Using Dataflow Style Design a circuit that takes as input a binary representation of a month, and an additional Boolean input LeapYear (LY) which is 1 if the current year is a leap year, and determines the number of days in the month. The circuit should have four outputs: D28, D29, D30, D31 which are true when the given month has exactly the indicated number of days. For example, if the month inputs indicate March, the output D31 will be 1 while D30, D29 and D28 will be 0. Use the fewest number of bits to encode the month input. Methodology (will vary with target implementation!) Draw a “black box”, label inputs and outputs (I/Os) Confirm formats, representations, timing of I/Os Create a truth table Use K-maps to obtain minimized/reduced equations Translate equations to Verilog dataflow style syntax Create a testbench to appropriately test the module Appropriate may mean exhaustive testing Compile and test Debug : Exam your results; if not as expected, work backwards Bask in your success

Black Box and Truthtable DaysInMonth 4 M D31 LY D30 D29 D28 Perhaps ask question about encoding used… Use of X (don’t care) in inputs reduces rows in truth table and helps to clarify functionality Use of X in outputs may lead to simpler Boolean equations

K-Maps and Reduced Equations Students, draw Karnaugh maps, and exploit X, for: D30 D31

K-Maps and Reduced Equations

Verilog Dataflow Style Module module DaysInMonth(M3,M2,M1,M0,LY,D28,D29,D30,D31); input M3,M2,M1,M0; // encoded value of month // Jan = 0000, Feb = 0001, etc input LY; // 1 if leap year output D28; // 1 if month has 28 days output D29; // 1 if month has 29 days output D30; // 1 if month has 30 days output D31; // 1 if month has 31 days assign #6 D28 = ~M3 & ~M2 & ~M1 & M0 & ~LY; assign #6 D29 = ~M3 & ~M2 & ~M1 & M0 & LY; assign #6 D30 = M3 & ~M0 | M2 & ~M1 & M0 | ~M3 & ~M2 & M1 & M0; assign #6 D31 = M3 & M0 | ~M3 & ~M0 | M2 & M1; endmodule Usually a block comment here with description of module, author, date, other pertinent information DaysInMonth 4 M D31 LY D30 D29 D28 Delay

Verilog Testbench Use of don’t care inputs module TestDays(); reg M3,M2,M1,M0; reg LY; wire D28, D29, D30, D31; DaysInMonth D1 (M3,M2,M1,M0,LY,D28,D29,D30,D31); initial begin #10 LY = 1'bx; M3 = 1'b0; M2 = 1'b0; M1 = 1'b0; M0 = 1'b0; // Jan #10 M3 = 1'b0; M2 = 1'b0; M1 = 1'b0; M0 = 1'b1; // Feb LY = 1'b0; // Not Leap Year #10 LY = 1'b1; // Leap Year M3 = 1'b0; M2 = 1'b0; M1 = 1'b1; M0 = 1'b0; // Mar #10 M3 = 1'b0; M2 = 1'b0; M1 = 1'b1; M0 = 1'b1; // Apr #10 M3 = 1'b0; M2 = 1'b1; M1 = 1'b0; M0 = 1'b0; // May #10 M3 = 1'b0; M2 = 1'b1; M1 = 1'b0; M0 = 1'b1; // Jun #10 M3 = 1'b0; M2 = 1'b1; M1 = 1'b1; M0 = 1'b0; // Jul #10 M3 = 1'b0; M2 = 1'b1; M1 = 1'b1; M0 = 1'b1; // Aug #10 M3 = 1'b1; M2 = 1'b0; M1 = 1'b0; M0 = 1'b0; // Sep #10 M3 = 1'b1; M2 = 1'b0; M1 = 1'b0; M0 = 1'b1; // Oct #10 M3 = 1'b1; M2 = 1'b0; M1 = 1'b1; M0 = 1'b0; // Nov #10 M3 = 1'b1; M2 = 1'b0; M1 = 1'b1; M0 = 1'b1; // Dec #20 $finish(); end endmodule Use of don’t care inputs Ability to easily determine all input values for any test vector module DaysInMonth(M3,M2,M1,M0,LY,D28,D29,D30,D31); input M3,M2,M1,M0; // encoded value of month // Jan = 0000, Feb = 0001 … input LY; // 1 if leap year output D28; // 1 if month has 28 days output D29; // 1 if month has 29 days output D30; // 1 if month has 30 days output D31; // 1 if month has 31 days assign #6 D28 = ~M3 & ~M2 & ~M1 & M0 & ~LY; assign #6 D29 = ~M3 & ~M2 & ~M1 & M0 & LY; assign #6 D30 = M3 & ~M0 | M2 & ~M1 & M0 | ~M3 & ~M2 & M1 & M0; assign #6 D31 = M3 & M0 | ~M3 & ~M0 | M2 & M1; endmodule

The Timing Diagram Note how easy to read, determine if all input combinations used

A Better Solution: Buses (Vectors) module DaysInMonth(M,LY,D28,D29,D30,D31); input [3:0] M; // encoded value of month // Jan = 0000, Feb = 0001, etc input LY; // 1 if leap year output D28; // 1 if month has 28 days output D29; // 1 if month has 29 days output D30; // 1 if month has 30 days output D31; // 1 if month has 31 days assign #6 D28 = ~M[3] & ~M[2] & ~M[1] & M[0] & ~LY; assign #6 D29 = ~M[3] & ~M[2] & ~M[1] & M[0] & LY; assign #6 D30 = M[3] & ~M[0] | M[2] & ~M[1] & M[0] | ~M[3] & ~M[2] & M[1] & M[0]; assign #6 D31 = M[3] & M[0] | ~M[3] & ~M[0] | M[2] & M[1]; endmodule DaysInMonth M 4 D31 D30 LY D29 D28

A Better Solution: Buses (Vectors) Port types must match module TestDays();   reg [3:0] M; reg LY; wire D28,D29,D30,D31; DaysInMonth D1 (M,LY,D28,D29,D30,D31); initial begin #10 LY= 1'bx; M= 4’b0000; // Jan #10 M= 4’b0001; // Feb LY= 0; #10 LY= 1; M= 4’b0010; // Mar #10 M= 4’b0011; // Apr #10 M= 4’b0100; // May #10 M= 4’b0101; // Jun #10 M= 4’b0110; // Jul #10 M= 4’b0111; // Aug #10 M= 4’b1000; // Sep #10 M= 4’b1001; // Oct #10 M= 4’b1010; // Nov #10 M= 4’b1011; // Dec #20 $finish(); end endmodule module DaysInMonth(M,LY,D28,D29,D30,D31); input [3:0] M; // encoded value of month // Jan = 0000, Feb = 0001, etc input LY; // 1 if leap year output D28; // 1 if month has 28 days output D29; // 1 if month has 29 days output D30; // 1 if month has 30 days output D31; // 1 if month has 31 days assign #6 D28 = ~M[3] & ~M[2] & ~M[1] & M[0] & ~LY; assign #6 D29 = ~M[3] & ~M[2] & ~M[1] & M[0] & LY; assign #6 D30 = M[3] & ~M[0] | M[2] & ~M[1] & M[0] | ~M[3] & ~M[2] & M[1] & M[0]; assign #6 D31 = M[3] & M[0] | ~M[3] & ~M[0] | M[2] & M[1]; endmodule

TestBenches with Buses Buses “bundled” together in waveform display improve readability

Alternative TestBenches with Buses module TestDays();   reg [3:0] M; reg LY; wire D28, D29, D30, D31; DaysInMonth D1 (M,LY,D28,D29,D30,D31); initial begin #10 LY= 1'bx; M= 0; // Jan #10 M= 1; // Feb LY= 0;  #10 LY= 1; M= 2; // Mar #10 M= 3; // Apr #10 M= 4; // May #10 M= 5; // Jun #10 M= 6; // Jul #10 M= 7; // Aug #10 M= 8; // Sep #10 M= 9; // Oct #10 M= 10; // Nov #10 M= 11; // Dec #20 $finish(); end endmodule Most tools provide a means to change display radix

TestBenches with Behavioral Code module TestDays(); reg [3:0]M; reg LY; wire D28, D29, D30, D31; DaysInMonth D1 (M, LY, D28, D29, D30, D31); initial begin for (M = 0; M <= 11; M=M+1) LY = 0; #10; LY = 1; #10; end $finish(); endmodule Behavioral code to facilitate creation of test vectors Behavioral code for automating checking e.g. consider a method to verify a multiplier design

Verilog Structural Style Module module DaysInMonth(M,LY,D28,D29,D30,D31); input [3:0]M; // encoded value of month // Jan = 0000, Feb = 0001, etc input LY; // 1 if leap year output D28; // 1 if month has 28 days output D29; // 1 if month has 29 days output D30; // 1 if month has 30 days output D31; // 1 if month has 31 days wire T1,T2,T3,T4,T5,T6; wire M3bar,M2bar,M1bar,M0bar,Lybar; not #(3,3) U1a(M3bar,M[3]), U1b(M2bar,M[2]), U1c(M1bar,M[1]), U1d(M0bar,M[0]), U1e(LYbar,LY); and #(5,4) U2a(D28,M3bar,M2bar,M1bar,M[0],LYbar), U2b(D29,M3bar,M2bar,M1bar,M[0],LY); U3a(T1,M[3],M0bar), U4a(T2,M[2],M1bar,M[0]), U5a(T3,M3bar,M2bar,M[1],M[0]); or #(5,5) U6a(D30,T1,T2,T3); U3b(T4,M[3],M[0]), U3c(T5,M3bar,M0bar), U3d(T6,M[2],M[1]); U6b(D31,T4,T5,T6); endmodule Reflects actual implementation Primitives: or, and, nand, xor, xnor, nor, not Variable number of inputs Output is first port Wires used to connect gate outputs/inputs Comma separated list will share tpd Can have asymmetric delays (tPLH tPHL) Note: can use same testbench used with dataflow (maybe need to accommodate different Tpd)

Hierarchical Structural Description Note that this is structural and hierarchical

Timing Diagrams

Timing Diagrams