Hardware Description Language (HDL)

Similar documents
Chap 6 Introduction to HDL (d)

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

Verilog HDL Introduction

Lab 7 (All Sections) Prelab: Introduction to Verilog

EECS150 - Digital Design Lecture 10 Logic Synthesis

Synthesizable Verilog

EEL 4783: HDL in Digital System Design

CSE140L: Components and Design Techniques for Digital Systems Lab

CSE140L: Components and Design

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

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

EECS150 - Digital Design Lecture 10 Logic Synthesis

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

Online Verilog Resources

Logic Synthesis. EECS150 - Digital Design Lecture 6 - Synthesis

ECEN 468 Advanced Logic Design

Introduction to Digital Design with Verilog HDL

Course Topics - Outline

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

Chapter 2 Using Hardware Description Language Verilog. Overview

Verilog Design Principles

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

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis

Lecture 15: System Modeling and Verilog

Verilog for Combinational Circuits

Digital Integrated Circuits

Verilog Tutorial (Structure, Test)

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

Synthesis of Combinational and Sequential Circuits with Verilog

Verilog introduction. Embedded and Ambient Systems Lab

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

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

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

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

Verilog Coding Guideline

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

Behavioral Modeling and Timing Constraints

A Brief Introduction to Verilog Hardware Definition Language (HDL)

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

Introduction to Verilog/System Verilog

Course Topics - Outline

Verilog Behavioral Modeling

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

14:332:231 DIGITAL LOGIC DESIGN. Verilog Functions and Tasks

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

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

Contents. Appendix D Verilog Summary Page 1 of 16

Verilog Fundamentals. Shubham Singh. Junior Undergrad. Electrical Engineering

Digital Design with FPGAs. By Neeraj Kulkarni

Midterm Exam Thursday, October 24, :00--2:15PM (75 minutes)

MODELING LANGUAGES AND ABSTRACT MODELS. Giovanni De Micheli Stanford University. Chapter 3 in book, please read it.

Course Topics - Outline

Chapter 10. case studies in sequential logic design

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

Digital System Design Verilog-Part III. Amir Masoud Gharehbaghi

Verilog for Synthesis Ing. Pullini Antonio

Introduction to Verilog HDL

Programmable Logic Devices Verilog VII CMPE 415

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

VERILOG. Deepjyoti Borah, Diwahar Jawahar

Verilog Tutorial. Verilog Fundamentals. Originally designers used manual translation + bread boards for verification

Verilog Tutorial 9/28/2015. Verilog Fundamentals. Originally designers used manual translation + bread boards for verification

Verilog Language Concepts

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

Introduction To Verilog Design. Chun-Hung Chou

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

Behavioral Modeling and Timing Constraints

Verilog HDL. Gate-Level Modeling

Hardware Description Languages (HDLs) Verilog

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

Verilog. Verilog for Synthesis

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

Design Using Verilog

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

Verilog Design Principles

Problem Set 3 Solutions

EN164: Design of Computing Systems Lecture 06: Lab Foundations / Verilog 2

DIGITAL SYSTEM DESIGN

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?

Digital Design with SystemVerilog

Introduction. Purpose. Intended Audience. Conventions. Close

Lab 7 (All Sections) Prelab: Verilog Review and ALU Datapath and Control

EITF35: Introduction to Structured VLSI Design

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

Introduction to Verilog

REF: Reuse Methodology Manual For System-ON-A-Chip Design, Third Edition 2002 CIC Training Manual Logic Synthesis with Design Compiler, July, 2007

Introduction to Verilog

תכן חומרה בשפת VERILOG הפקולטה להנדסה

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

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

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

Lecture 32: SystemVerilog

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

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

ECE 353 Lab 3 (Verilog Design Approach)

EE178 Lecture Verilog FSM Examples. Eric Crabill SJSU / Xilinx Fall 2007

ECE 574: Modeling and Synthesis of Digital Systems using Verilog and VHDL. Fall 2017 Final Exam (6.00 to 8.30pm) Verilog SOLUTIONS

Logic Circuits II ECE 2411 Thursday 4:45pm-7:20pm. Lecture 3

Transcription:

Hardware Description Language (HDL) What is the need for Hardware Description Language? Model, Represent, And Simulate Digital Hardware Hardware Concurrency Parallel Activity Flow Semantics for Signal Value And Time Special Constructs And Semantics Edge Transitions Propagation Delays Timing Checks 1

VERILOG HDL Basic Unit A module Module Describes the functionality of the design States the input and output ports Example: A Computer Functionality: Perform user defined computations I/O Ports: Keyboard, Mouse, Monitor, Printer 2

Module module module_name ( port_list ); port declarations; variable declaration; description of behavior endmodule Example module HalfAdder (A, B, Sum Carry); input A, B; output Sum, Carry; assign Sum = A ^ B; //^ denotes XOR assign Carry = A & B; // & denotes AND endmodule 3

Description Styles Structural: Logic is described in terms of Verilog gate primitives (same as describing the network) Example: not n1(sel_n, sel); and a1(sel_b, b, sel_b); and a2(sel_a, a, sel); or o1(out, sel_b, sel_a); sel n1 b sel_n a a1 sel_b o1 out a2 sel_a 4

Description Styles (cont.) Dataflow: Specify output signals in terms of input signals Example: assign out = (sel & a) (~sel & b); b sel sel_n sel_b out sel_a a 5

Description Styles (cont.) Behavioral: Algorithmically specify the behavior of the design Example: if (select == 0) begin out = b; end else if (select == 1) begin end out = a; a b Black Box 2x1 MUX out sel 6

Dataflow Modeling (cont.) Delay can be introduced Example: assign #2 sum = a ^ b; #2 indicates 2 time-units No delay specified : 0 (default) Associate time-unit with physical time `timescale time-unit/time-precision Example: `timescale 1ns/100 ps Timescale `timescale 1ns/100ps 1 Time unit = 1 ns Time precision is 100ps (0.1 ns) 10.512ns is interpreted as 10.5ns 7

Dataflow Modeling (cont.) Example: `timescale 1ns/100ps module HalfAdder (A, B, Sum, Carry); input A, B; output Sum, Carry; assign #3 Sum = A ^ B; assign #6 Carry = A & B; endmodule 8

Behavioral Modeling Example: module mux_2x1(a, b, sel, out); input a, a, sel; output out; always @(a or b or sel) begin if (sel == 1) out = a; else out = b; end endmodule Sensitivity List 9

FSM with Combinational Logic module FSM(o, a, b, reset); output o; reg o; input a, b, reset; reg [1:0] state, nextstate; always @(a or b or state) case (state) 2 b00: begin nextstate = a? 2 b00 : 2 b01; o = a & b; end 2 b01: begin nextstate = 2 b10; o = 0; end endcase Output o is declared a reg because it is assigned procedurally, not because it holds state Combinational block must be sensitive to any change on any of its inputs (Implies state-holding elements otherwise)

FSM with Combinational Logic module FSM(o, a, b, reset); always @(posedge clk or reset) if (reset) state <= 2 b00; else state <= nextstate; Latch implied by sensitivity to the clock or reset only

Behavioral Modeling (cont.) always statement : Sequential Block Sequential Block: All statements within the block are executed sequentially When is it executed? Occurrence of an event in the sensitivity list Event: Change in the logical value Statements with a Sequential Block: Procedural Assignments 12

Behavioral Modeling (cont.) Inter-Assignment Delay Example: Sum = A ^ B; #2 Carry = A & B; Delayed execution Intra-Assignment Delay Example: Sum = A ^ B; Carry = #2 A & B; Delayed assignment 13

Procedural Constructs Two Procedural Constructs initial Statement always Statement initial Statement : Executes only once always Statement : Executes in a loop Example: initial begin Sum = 0; Carry = 0; end always @(A or B) begin Sum = A ^ B; Carry = A & B; end 14

Event Control Event Control Edge Triggered Event Control Level Triggered Event Control Edge Triggered Event Control @ (posedge CLK) //Positive Edge of CLK Curr_State = Next_state; Level Triggered Event Control @ (A or B) //change in values of A or B Out = A & B; 15

Loop Statements Loop Statements Repeat While For Repeat Loop Example: repeat (Count) sum = sum + 5; If condition is a x or z it is treated as 0 16

Loop Statements (cont.) While Loop Example: while (Count < 10) begin sum = sum + 5; Count = Count +1; end If condition is a x or z it is treated as 0 For Loop Example: for (Count = 0; Count < 10; Count = Count + 1) begin sum = sum + 5; end 17

Conditional Statements if Statement Format: if (condition) procedural_statement else if (condition) procedural_statement else procedural_statement Example: if (Clk) Q = 0; else Q = D; 18

Conditional Statements (cont.) Case Statement Example: case (X) 2 b00: Y = A + B; 2 b01: Y = A B; 2 b10: Y = A / B; endcase 19

Data Types Net Types: Physical Connection between structural elements Register Type: Represents an abstract storage element. Default Values Net Types : z Register Type : x Net Types: wire, tri, wor, trior, wand, triand, supply0, supply1 Register Types : reg, integer, time, real, realtime 20

Data Types Net Type: Wire wire [ msb : lsb ] wire1, wire2, Example wire Reset; // A 1-bit wire wire [6:0] Clear; // A 7-bit wire Register Type: Reg reg [ msb : lsb ] reg1, reg2, Example reg [ 3: 0 ] cla; // A 4-bit register reg cla; // A 1-bit register 21

Restrictions on Data Types Data Flow and Structural Modeling Can use only wire data type Cannot use reg data type Behavioral Modeling Can use only reg data type (within initial and always constructs) Cannot use wire data type 22

Type of Port Connections by position Connection by Position parent_mod 23

Type of Port Connections (by direct connection Connection by Name parent_mod 24

Empty Port Connections If an input port of an instantiated module is empty, the port is set to a value of z (high impedance). module child_mod(in1, In2, Out1, Out2) input In1; input In2; output Out1; output Out2; module parent_mod(.) child_mod mod(a,,y1, Y2); //Empty Input endmodule //behavior relating In1 and In2 to Out1 endmodule If an output port of an instantiated module is left empty, the port is considered to be unused. module parent_mod(.) child_mod mod(a, B, Y1, ); //Empty Output endmodule 25

Test Bench `timescale 1ns/100ps module Top; reg PA, PB; wire PSum, PCarry; Test Bench Apply Inputs HalfAdder G1(PA, PB, PSum, PCarry); initial begin PA=0;PB=0; #10; PA=0;PB=1; #10; PA=1;PB=0; #10; PA=1;PB=1; #10; end endmodule Design Module Observe Outputs 26

Test Bench - Generating Stimulus Example: A sequence of values initial begin Clock = 0; #50 Clock = 1; #30 Clock = 0; #20 Clock = 1; end 27

Repetitive Test Bench Signals (clock) - Generating Clock Clock A Simple Solution: wire Clock; assign #10 Clock = ~ Clock Caution: Initial value of Clock (wire data type) = z ~z = x and ~x = x 28

Test Bench - Generating Clock (cont.) Initialize the Clock signal initial begin Clock = 0; end Caution: Clock is of data type wire, cannot be used in an initial statement Solution: reg Clock; initial begin Clock = 0; end always begin #10 Clock = ~ Clock; end forever loop can also be used to generate clock 29

Wire vs Reg wire Elements (Combinational logic) wire elements are simple wires (or busses of arbitrary width) in Verilog designs. The following are syntax rules when using wires: 1. wire elements are used to connect input and output ports of a module instantiation together with some other element in your design. 2. wire elements are used as inputs and outputs within an actual module declaration. 3. wire elements must be driven by something, and cannot store a value without being driven. 4. wire elements cannot be used as the left-hand side of an = or <= sign in an always@ block. 5. wire elements are the only legal type on the left-hand side of an assign statement. 6. wire elements are a stateless way of connecting two peices in a Verilog-based design. 7. wire elements can only be used to model combinational logic. 30

Wire vs Reg reg Elements (Combinational and Sequential logic) reg are similar to wires, but can be used to store information ( state ) like registers. The following are syntax rules when using reg elements. 1. reg elements can be connected to the input port of a module instantiation. 2. reg elements cannot be connected to the output port of a module instantiation. 3. reg elements can be used as outputs within an actual module declaration. 4. reg elements cannot be used as inputs within an actual module declaration. 5. reg is the only legal type on the left-hand side of an always@ block = or <= sign. 6. reg is the only legal type on the left-hand side of an initial block = sign (used in Test Benches). 7. reg cannot be used on the left-hand side of an assign statement. 8. reg can be used to create registers when used in conjunction with always@(posedge Clock) blocks. 9. reg can, therefore, be used to create both combinational and sequential logic. 31