Hardware description languages

Similar documents
Lecture 8: Combinational Verilog. CSE 370, Autumn 2007 Benjamin Ylvisaker. Where We Are. Last lecture: Minimization with K!maps

Where We Are. Quick History Lesson. Lecture 8: Combinational Verilog. Specifying Circuits. Last lecture: Minimization with K!maps

Lecture 7. Summary of two-level combinational-logic. Ways of specifying circuits. Solving combinational design problems. Verilog versus VHDL

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

Hardware Description Languages: Verilog

! ISP (circa 1977) - research project at CMU " Simulation, but no synthesis

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

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

Outline. EECS150 - Digital Design Lecture 5 - Verilog 2. Structural Model: 2-to1 mux. Structural Model - XOR. Verilog Basics Lots of Examples

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

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

Introduction to Verilog. Garrison W. Greenwood, Ph.D, P.E.

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

Chapter 3 working with combinational logic

EECS150 - Digital Design Lecture 4 - Verilog Introduction. Outline

Synthesizable Verilog

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

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

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

Verilog Design Principles

Introduction to Verilog HDL

Verilog. Reminder: Lab #1 due tonight! Fall 2008 Lecture 3

Verilog Design Principles

C-Based Hardware Design

Design Using Verilog

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

Hardware Description Languages (HDLs) Verilog

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

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

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

A Brief Introduction to Verilog Hardware Definition Language (HDL)

Lecture 1: VHDL Quick Start. Digital Systems Design. Fall 10, Dec 17 Lecture 1 1

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

Chapter 2 Using Hardware Description Language Verilog. Overview

101-1 Under-Graduate Project Digital IC Design Flow

Combinational Logic II

Digital Design with FPGAs. By Neeraj Kulkarni

Advanced Digital Design Using FPGA. Dr. Shahrokh Abadi

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

EN2911X: Reconfigurable Computing Topic 02: Hardware Definition Languages

Introduction to Verilog/System Verilog

Contents. Appendix D Verilog Summary Page 1 of 16

Hardware Description Language VHDL (1) Introduction

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

EEL 4783: Hardware/Software Co-design with FPGAs

Physics 364, Fall 2012, reading due your answers to before the end of Wednesday s lab.

Hardware description language (HDL)

Synthesis of Combinational and Sequential Circuits with Verilog

CENG 241 Digital Design 1

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

EECS150 - Digital Design Lecture 8 - Hardware Description Languages

Verilog. Verilog for Synthesis

Physics 364, Fall 2014, reading due your answers to by 11pm on Sunday

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

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

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

Lecture 15: System Modeling and Verilog

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

Verilog for Combinational Circuits

Introduction. Why Use HDL? Simulation output. Explanation

NH 67, Karur Trichy Highways, Puliyur C.F, Karur District DEPARTMENT OF INFORMATION TECHNOLOGY CS 2202 DIGITAL PRINCIPLES AND SYSTEM DESIGN

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

Introduction to Verilog

Online Verilog Resources

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

EGC220 - Digital Logic Fundamentals

271/469 Verilog Tutorial

CSE370 TUTORIAL 3 - INTRODUCTION TO USING VERILOG IN ACTIVE-HDL

Two HDLs used today VHDL. Why VHDL? Introduction to Structured VLSI Design

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

Declarations of Components and Entities are similar Components are virtual design entities entity OR_3 is

Lecture 4. VHDL Fundamentals. Required reading. Example: NAND Gate. Design Entity. Example VHDL Code. Design Entity

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis

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

Combinational Logic Design with Verilog. ECE 152A Winter 2012

Verilog HDL Introduction

Lecture 4. VHDL Fundamentals. George Mason University

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

Lecture #2: Verilog HDL

Verilog Module 1 Introduction and Combinational Logic

EEL 4783: HDL in Digital System Design

IT T35 Digital system desigm y - ii /s - iii

ECE Digital System Design & Synthesis Exercise 1 - Logic Values, Data Types & Operators - With Answers

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

Introduction. Purpose. Intended Audience. Conventions. Close

271/471 Verilog Tutorial

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

ECE 353 Lab 3 (Verilog Design Approach)

Software Engineering 2DA4. Slides 2: Introduction to Logic Circuits

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

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

CDA 4253 FPGA System Design Introduction to VHDL. Hao Zheng Dept of Comp Sci & Eng USF

a, b sum module add32 sum vector bus sum[31:0] sum[0] sum[31]. sum[7:0] sum sum overflow module add32_carry assign

Lecture 3 Introduction to VHDL

VERILOG HDL. (and C) 1 ENGN3213: Digital Systems and Microprocessors L#5-6

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

VLSI Design 13. Introduction to Verilog

CSE140L: Components and Design Techniques for Digital Systems Lab

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

Transcription:

Specifying digital circuits Schematics (what we ve done so far) Structural description Describe circuit as interconnected elements Build complex circuits using hierarchy Large circuits are unreadable Hardware description languages (HDLs) Structural and behavioral descriptions Not programming languages They are parallel languages tailored to digital design Synthesize code to produce a circuit from descriptions Easier to modify designs Details of realization take care of by compiler 1 Hardware description languages Describe hardware at varying levels of abstraction Structural description textual replacement for schematic hierarchical composition of modules from primitives Behavioral/functional description describe what module does, not how synthesis generates circuit for module Simulation semantics 2

Hardware description languages (HDLs) Abel (~1983) Developed by Data-I/O Targeted to two-level logic (most popular at the time) Limited capabilities Verilog (~1985) IEEE standard Developed by Gateway (now part of Cadence) Syntax similar to C Supports both two-level and multi-level logic Moved to public domain in 1990 VHDL (~1987) IEEE standard DoD-sponsored Supports both two-level and multi-level logic Syntax similar to Ada SystemC (late 90s) developing into IEEE standard Support mixed hardware/software systems Not as widely accepted yet 3 Verilog Supports structural and behavioral descriptions Structural explicit structure of the circuit e.g., each logic gate instantiated and connected to others Behavioral program describes input/output behavior of circuit many structural implementations could have same behavior e.g., different implementation of one Boolean function We ll mostly be using behavioral Verilog in Aldec ActiveHDL rely on schematic when we want structural descriptions 4

Simulation and synthesis Simulation Execute a design to verify correctness Synthesis Generate a physical implementation from HDL code HDL Description Synthesis Gate or Transistor Description Simulation Simulation Physical Implementation Functional Validation Functional/ Timing Validation Real Chip! 5 Simulation and synthesis (con t) Simulation Models what a circuit does Ignore implementation options Can include static timing Allows you to test design options at an abstract level Synthesis Converts your code to a netlist (circuit) Can simulate synthesized design Tools map your netlist to the hardware you ll be using Simulation and synthesis in the CSE curriculum CSE370: Learn simulation CSE467: Learn synthesis 6

Simulation You provide an environment in which to test your circuit Using non-circuit constructs Active-HDL waveforms, read files, print Using Verilog simulation code A test fixture Simulation Test Fixture (Specification) Circuit Description (Synthesizable) 7 Structural model module xor_gate (out, a, b); input a, b; output out; wire abar, bbar, t1, t2; inverter inva (abar, a); inverter invb (bbar, b); and_gate and1 (t1, a, bbar); and_gate and2 (t2, b, abar); or_gate or1 (out, t1, t2); 8

Simple behavioral model Continuous assignment module xor_gate (out, a, b); input a, b; output out; reg out; assign #6 out = a ^ b; simulation register - keeps track of value of signal NOTE: anything on the left side of an assignment must have a reg declaration delay from input change to output change 9 Simple behavioral model always block module xor_gate (out, a, b); input a, b; output out; reg out; always @(a or b) begin #6 out = a ^ b; end specifies when block is executed ie. triggered by which signals NOTE: this or is not a Boolean OR, it just says: re-evaluate this expression whever a or b change 10

Driving a simulation through a testbench module testbench (x, y); output x, y; reg [1:0] cnt; 2-bit vector initial begin cnt = 0; repeat (4) begin #10 cnt = cnt + 1; $display ("@ time=%d, x=%b, y=%b, cnt=%b", $time, x, y, cnt); end #10 $finish; end initial block executed only once at start of simulation print to a console assign x = cnt[1]; assign y = cnt[0]; directive to stop simulation 11 Complete simulation Instantiate stimulus component and device to test in a schematic test-bench x y a b z 12

Specifying circuits in Verilog There are three major styles Instances n wires Continuous assignments always blocks A B C AND2 1 NOT 2 g1 g2 E OR2 3 g3 X Y Structural Behavioral wire E; and g1(e,a,b); not g2(y,c); or g3(x,e,y); wire E; assign E = A & B; assign Y = ~C; assign X = E Y; reg E, X, Y; always @ (A or B or C) begin E = A & B; Y = ~C; X = E Y; end 13 Data types Values on a wire 0, 1, x (unknown or conflict), z (tri-state or unconnected) Vectors A[3:0] vector of 4 bits: A[3], A[2], A[1], A[0] Unsigned integer value Indices must be constants Concatenating bits/vectors (curly brackets on left or right side) e.g. sign-extend B[7:0] = {A[3], A[3], A[3], A[3], A[3:0]}; {4{A[3]}, A[3:0]} = B[7:0]; Style: Use a[7:0] = b[7:0] + c; Not a = b + c; Bad style but legal syntax: C = &A[6:7]; // and of bits 6 and 7 of A 14

Data types that do not exist Structures Pointers Objects Recursive types (Remember, Verilog is not C or Java or Lisp or!) 15 Numbers Format: <sign><size><base format><number> 14 Decimal number 4 b11 4-bit 2 s complement binary of 0011 (is 1101) 12 b0000_0100_0110 12-bit binary number (_ is ignored, just used for readibility) 3 h046 3-digit (12-bit) hexadecimal number Verilog values are unsigned C[4:0] = A[3:0] + B[3:0]; if A = 0110 (6) and B = 1010( 6), then C = 10000 (not 00000) B is zero-padded, not sign-extended 16

Operators Similar to C operators 17 Two abstraction mechanisms Modules More structural Heavily used in 370 and real Verilog code Functions More behavioral Used often in real Verilog Just used in test fixtures in 370 18

Basic building blocks: Modules Instantiated into a design Not called like a procedure/method Illegal to nest module definitions Modules execute in parallel Names are case sensitive // for comments Name can t begin with a number Use wires for connections and, or, not are keywords All keywords are lower case Gate declarations (and, or, etc.) List outputs first (convention), then inputs A B C AND2 1 NOT 2 g1 g2 E OR2 g3 // first simple example module smpl (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); 3 X Y 19 Modules are circuit components Module has ports External connections A, B, C, X, Y in this example Port types input (A, B, C) output (X, Y) inout (tri-state) more later Use assign statements for Boolean expressions and & or not ~ A B C AND2 1 NOT 2 g1 g2 E OR2 g3 // previous example as a // Boolean expression module smpl2 (X,Y,A,B,C); input A,B,C; output X,Y; assign X = (A&B) ~C; assign Y = ~C; 3 X Y 20

Structural Verilog module xor_gate (out,a,b); input a,b; output out; wire abar, bbar, t1, t2; not inva (abar,a); not invb (bbar,b); and and1 (t1,abar,b); and and2 (t2,bbar,a); or or1 (out,t1,t2); 8 basic gates (keywords): and, or, nand, nor buf, not, xor, xnor a NOT 4 inva abar b AND2 and1 6 t1 OR2 b NOT 5 invb bbar a AND2 and2 7 t2 8 or1 out 21 Behavioral Verilog Describe circuit behavior Not implementation A B Cin Adder Sum Cout module full_addr (Sum,Cout,A,B,Cin); input A, B, Cin; output Sum, Cout; assign {Cout, Sum} = A + B + Cin; {Cout, Sum} is a concatenation of 2 1-bit signals 22

Behavioral 4-bit adder module add4 (SUM, OVER, A, B); input [3:0] A; input [3:0] B; output [3:0] SUM; output OVER; assign {OVER, SUM[3:0]} = A[3:0] + B[3:0]; [3:0] A is a 4-wire bus labeled A Bit 3 is the MSB Bit 0 is the LSB Can also write [0:3] A Bit 0 is the MSB Bit 3 is the LSB Buses are implicitly connected If you write BUS[3:2], BUS[1:0] They become part of BUS[3:0] 23 Continuous assignment Assignment is continuously evaluated Corresponds to a logic gate Assignments execute in parallel assign A = X (Y & ~Z); assign B[3:0] = 4'b01XX; assign C[15:0] = 4'h00ff; Boolean operators (~ for bit-wise negation) bits can assume four values (0, 1, X, Z) variables can be n-bits wide (MSB:LSB) assign #3 {Cout, Sum[3:0]} = A[3:0] + B[3:0] + Cin; arithmetic operator Gate delay (used by simulator) multiple assignment (concatenation) 24

Example: A comparator module Compare1 (Equal, Alarger, Blarger, A, B); input A, B; output Equal, Alarger, Blarger; assign #5 Equal = (A & B) (~A & ~B); assign #3 Alarger = (A & ~B); assign #3 Blarger = (~A & B); assign statement ordering doesn t matter because they execute in parallel 25 Comparator example (con t) // Make a 4-bit comparator from 4 1-bit comparators module Compare4(Equal, Alarger, Blarger, A4, B4); input [3:0] A4, B4; output Equal, Alarger, Blarger; wire E0, E1, E2, E3, AL0, AL1, AL2, AL3, BL0, BL1, BL2, BL3; Compare1 cp0(e0, AL0, BL0, A4[0], B4[0]); Compare1 cp1(e1, AL1, BL1, A4[1], B4[1]); Compare1 cp2(e2, AL2, BL2, A4[2], B4[2]); Compare1 cp3(e3, AL3, BL3, A4[3], B4[3]); assign #5 Equal = (E0 & E1 & E2 & E3); assign #10 Alarger = (AL3 (AL2 & e3) (AL1 & E3 & E2) (AL0 & E3 & E2 & E1)); assign #3 Blarger = (~Alarger & ~Equal); 26

Sequential assigns don t make any sense assign A = X (Y & ~Z); assign B = W A; assign A = Y & Z; Reusing a variable on the LHS in multiple assign statements is not allowed they execute in parallel indeterminate result 27 Always Blocks reg A, B, C; always @ (W or X or Y or Z) begin A = X (Y & ~Z); B = W A; A = Y & Z; if (A & B) begin B = Z; C = W Y; end end Variables that appear on the left hand side in an always block must be declared as reg s Statements in an always block are executed in sequence Sensitivity list All variables must be assigned on every possible path through the code!!! - otherwise, the simulator gets confused and decides it needs memory (the dreaded inferred latch ) so it can remember the old value it had 28

Functions Use functions for complex combinational logic module and_gate (out, in1, in2); input in1, in2; output out; assign out = myfunction(in1, in2); function myfunction; input in1, in2; begin myfunction = in1 & in2; end endfunction Benefit: Compiler will fail if function does not generate a result 29 Verilog tips Do not write C-code Think hardware, not algorithms Verilog is inherently parallel Compilers don t map algorithms to circuits well Do describe hardware circuits First draw a dataflow diagram Then start coding References Tutorial and reference manual are found in ActiveHDL help Wikipedia search for Verilog tutorials and external resources Sutherland quick reference guide Starter s Guide to Verilog 2001 by Michael Ciletti copies for borrowing in hardware lab 30

Hardware description languages vs. programming languages Program structure instantiation of multiple components of the same type specify interconnections between modules via schematic hierarchy of modules (only leaves can be HDL) Assignment continuous assignment (logic always computes) propagation delay (computation takes time) timing of signals is important (when does computation have its effect) Data structures size explicitly spelled out - no dynamic structures no pointers Parallelism hardware is naturally parallel (must support multiple threads) assignments can occur in parallel (not just sequentially) 31 Hardware description languages and combinational logic Modules - specification of inputs, outputs, bidirectional, and internal signals Continuous assignment - a gate s output is a function of its inputs at all times (doesn t need to wait to be "called") Propagation delay- concept of time and delay in input affecting gate output Composition - connecting modules together with wires Hierarchy - modules encapsulate functional blocks 32