VERILOG. Deepjyoti Borah, Diwahar Jawahar

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

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

ECE 4514 Digital Design II. Spring Lecture 2: Hierarchical Design

Verilog HDL. Lecture #6. Madhu Mutyam Dept. of Computer Science and Engineering Indian Institute of Technology, Madras

Course Topics - Outline

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

Lab 7 (All Sections) Prelab: Introduction to Verilog

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

Date Performed: Marks Obtained: /10. Group Members (ID):. Experiment # 11. Introduction to Verilog II Sequential Circuits

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

Verilog Fundamentals. Shubham Singh. Junior Undergrad. Electrical Engineering

Verilog Behavioral Modeling

Nikhil Gupta. FPGA Challenge Takneek 2012

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

Spring 2017 EE 3613: Computer Organization Chapter 5: Processor: Datapath & Control - 2 Verilog Tutorial

EN2911X: Reconfigurable Computing Topic 02: Hardware Definition Languages

Introduction to Verilog/System Verilog

Course Topics - Outline

Online Verilog Resources

Verilog. Verilog for Synthesis

Introduction. Why Use HDL? Simulation output. Explanation

The Verilog Hardware Description Language Testing the Design Overview

ECEN 468 Advanced Logic Design

Lecture #2: Verilog HDL

The Verilog Hardware Description Language

Week 4 Tutorial: Verilog Primer Part 2. By Steve Engels

Introduction. Purpose. Intended Audience. Conventions. Close

CSE140L: Components and Design Techniques for Digital Systems Lab

VLSI II E. Özgür ATES

Verilog Design Principles

Chap 6 Introduction to HDL (d)

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

Hardware Description Language (HDL)

FSM and Efficient Synthesizable FSM Design using Verilog

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

Contents. Appendix D Verilog Summary Page 1 of 16

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

Verilog Module 1 Introduction and Combinational Logic

CAD for VLSI Design - I. Lecture 21 V. Kamakoti and Shankar Balachandran

Register Transfer Level in Verilog: Part I

Verilog Design Principles

Introduction To Verilog Design. Chun-Hung Chou

Lecture 15: System Modeling and Verilog

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

CSE140L: Components and Design

Synthesis of Combinational and Sequential Circuits with Verilog

Synthesizable Verilog

UNIT V: SPECIFICATION USING VERILOG HDL

ECE 4514 Digital Design II. Spring Lecture 3: Verilog Bread and Butter

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

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

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

Hardware description language (HDL)

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

Verilog HDL [As per Choice Based Credit System (CBCS) scheme]

Brief Introduction to Verilog HDL (Part 1)

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

Verilog Coding Guideline

EEL 4783: HDL in Digital System Design

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

ECE 353 Lab 3 (Verilog Design Approach)

ES611 FPGA Based System Design. Behavioral Model

Verilog Nonblocking Assignments with Delays - Myths & Mysteries

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

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

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

Verilog 1 - Fundamentals

EECS150 - Digital Design Lecture 4 - Verilog Introduction. Outline

- 1 of 18 - The Verilog Hardware Description Language - A Behavioural View Overview. The Behavioural Model

Behavioral Modeling and Timing Constraints

Introduction to Verilog HDL. Verilog 1

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

Verilog HDL Introduction

SystemVerilog 3.1: It s What The DAVEs In Your Company Asked For

Verilog 1 - Fundamentals

Verilog Tutorial for ECE260B

EN2911X: Reconfigurable Computing Lecture 05: Verilog (2)

101-1 Under-Graduate Project Digital IC Design Flow

ENGN1640: Design of Computing Systems Topic 02: Lab Foundations

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

EECS150 - Digital Design Lecture 10 Logic Synthesis

EECS150 - Digital Design Lecture 10 Logic Synthesis

Verilog Tutorial (Structure, Test)

Modeling Sequential Circuits in Verilog

Verilog HDL. Gate-Level Modeling

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

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

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

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

VLSI Design 13. Introduction to Verilog

RTL Design (Using ASM/SM Chart)

Digital Design with FPGAs. By Neeraj Kulkarni

ECE 4514 Digital Design II. Spring Lecture 13: Logic Synthesis

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

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

EECS150 - Digital Design Lecture 8 - Hardware Description Languages

Department of Computer Science and Electrical Engineering. CMPE 415 Verilog Events Timing and Testbenches Prof. Ryan Robucci

Register Transfer Level Design. Topics. Register Transfer Level Notation. Chapter 8 Steve Oldridge Dr. Sidney Fels. A Circuit is described as:

EPC6055 Digital Integrated Circuits EXAM 1 Fall Semester 2013

Transcription:

VERILOG Deepjyoti Borah, Diwahar Jawahar

Outline 1. Motivation 2. Basic Syntax 3. Sequential and Parallel Blocks 4. Conditions and Loops in Verilog 5. Procedural Assignment 6. Timing controls 7. Combinatorial Logic in Verilog 8. Race conditions 9. Summary SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 2

What is Verilog? Verilog is a hardware description language(hdl) Verilog is used to model digital circuits Verilog is a data flow language The way it differs from the programming language is by describing propagation time and signal strength SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 3

Verilog Timeline 1983/84-Developed by Prabhu Goel and Phil Moorby as Automated Integrated Design System 1985-Renamed as Gateway Design Automation 1990-Cadence Design Systems purchase it 1995-Released in public domain: IEEE 1364-1995 or Verilog-95 2001-Verilog 2001 2005-Verilog 2005 SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 4

Why Verilog..? Easy verification of circuits : replacement of breadboard and hand layout Concurrency of processes in hardware elements Logic synthesis Abstract level description of design without choosing specific fabrication technology Functional verification is early in the design process to meet requirements SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 5

How Verilog works Specification Behavioural Description(Algorithm level) Register Transfer Level Logic synthesis/ Manual modeling Gate Level Modeling Approach: Top----- Down Bottom--------Up Mixed SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 6

Outline 1. Motivation 2. Basic Syntax 3. Sequential and Parallel Blocks 4. Conditions and Loops in Verilog 5. Procedural Assignment 6. Timing controls 7. Combinatorial Logic in Verilog 8. Race conditions 9. Summary SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 7

Modules module test; reg clk, reset; wire [3:0] q; ripple_carry_counter rcc(q, clk, reset); initial begin end endmodule module tff(q, clk, reset); output reg q; input clk, reset; always @( ) begin... end endmodule module ripple_carry_counter(q, clk, reset); output[3:0] q; input clk, reset; tff tff0(q[0], ~clk, reset);.... SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 8 endmodule

A Verilog Module Module Name Port list, port declaration Parameters Declaration of Variables, wires etc. Instantiation of lower end modules Tasks &functions Data flow statements: Always and initial blocks (All behavioural statements) End module SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 9

Ports Allow communication between a module and its environment. Three types of ports: Input Output Inout SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 10

Data Types Register Something that stores a value Nets- Connection between elements (commonly known as wire) Value set: 0, 1, x(unknown), z(high impedance) Reg unsigned variable Integer signed variable ( 32 bits ) Time unsigned integer ( 64 bits ) Real double precision floating point variable SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 11

Definition of Constants Little Endian convention is widely used. <width> `<base letter> <number> Constants can be specified in decimal, hexadecimal, octal or binary format E.g. x = 4'd1 SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 12

Outline 1. Motivation 2. Basic Syntax 3. Sequential and Parallel Blocks 4. Conditions and Loops in Verilog 5. Procedural Assignment 6. Timing controls 7. Combinatorial Logic in Verilog 8. Race conditions 9. Summary SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 13

Sequential Blocks reg a,b,c,d; initial begin a = 1`b0; b= 1`b1; c = a; All statements within the block runs sequentially a = 0 b = 1 c = 0 end d = b; d = 1 SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 14

Parallel Blocks All statements after fork runs in parallel Fork and Join initial fork a = 1`b0; #5 b = 1`b1; #10 c = a; #20 d = b; a = 0 After 5 cycle b = 1 After 10 cycle c = 0 After 20 cycle d = 1 join What happens without delay?? RACE!!! SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 15

Outline 1. Motivation 2. Basic Syntax 3. Sequential and Parallel Blocks 4. Conditions and Loops in Verilog 5. Procedural Assignment 6. Timing controls 7. Combinatorial Logic in Verilog 8. Race conditions 9. Summary SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 16

Conditional statement If condition Type1 if ( <expression>) true statement ; Type2 if (<expression>) true statement; else false statement; Type 3 if( <expression1>) true statement1; else if (expression2>) true statement2 ; else if (<expression3>) true statement3; else default_statement; SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 17

Multi way branching Keywords : case, endcase, default case (expression) alternative1: statement1; alternative2: statement2; alternative3: statement3; default: default statement; endcase SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 18

While loop initial begin count = 0; while ( count < 128) begin $display( Count = %d, count); count = count +1; end end SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 19

For loop initial for ( count= 0; count <128; count = count+ 1) $display ( count = %d, count); SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 20

repeat initial begin count = 0; repeat(128) begin $display( count = %d, count); count = count + 1; end end SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 21

forever initial begin clock = 1`b0; forever #10 clock = ~clock; end Use forever loop instead of always. (will be clarified in the next chapter) SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 22

Outline 1. Motivation 2. Basic Syntax 3. Sequential and Parallel Blocks 4. Conditions and Loops in Verilog 5. Procedural Assignment 6. Timing controls 7. Combinatorial Logic in Verilog 8. Race conditions 9. Summary SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 23

Structured procedures Initial Always Initial - process exactly once Always rescheduled many times initial begin a = 1; #1; b=a; end always @ (a or b ) begin if (a) c=b; else d= ~b; end SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 24

Structured procedures Initial forever initial forever begin end clk = 0; #1; clk = 1; #1; All behavioural statements can appear only within structured procedures Nesting between initial and always is not possible SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 25

Procedural Assignment Blocking Assignment ( = ) Used for purpose of logic Used for sequential execution of statements Non- Blocking Assignment ( <= ) The simulator can schedule any statement non deterministically within a block switch values without using temporary storage variables. SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 26

Blocking Assignment Example: initial begin x=0; y= 1; z=0; #15 count = count + 1; count = 1; end Values At time 0 : X=0, Y=1 and Z=0 At time 15 : initially count is assigned a junk value and then it changes to 1 in the next assignment SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 27

Non- Blocking Assignment Example initial begin x <= 0; y <= 1; z <= 0; #15 count <= count + 1; count <= 1; end Values At time 0 : x =0; y=1; z=0; count = 1 At time 15 : count <= 2 SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 28

Uses of Non Blocking Assignment Values for flop1 and flop2..? always @ (posedge clock) flop1 = flop2; always @ (posedge clock) flop2 = flop1; always @ (posedge clock) begin flop <= flop2; flop2 <= flop1; end SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 29

Outline 1. Motivation 2. Basic Syntax 3. Sequential and Parallel Blocks 4. Conditions and Loops in Verilog 5. Procedural Assignment 6. Timing controls 7. Combinatorial Logic in Verilog 8. Race conditions 9. Summary SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 30

Delay based timing control Specifies the time duration between when a statement is encountered and when it is executed. Delay can be specified by #Number #identifier #(expression) statement; statement; statement; Regular delay control Intra assignment delay control Zero delay control SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 31

Regular delay control parameter latency = 20; parameter delta = 2; reg a, b, c, d; initial begin a = 0; #10 b = 1; #latency c = 0; #( latency + delta ) d = 1; end SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 32

Intra assignment delay control Assign delay to the right of the assignment operator Alters the flow of activity in a different manner initial begin x = 0; z = 0; y = #5x + z; end SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 33

Zero delay control Statements are executed last within the same simulation time initial begin end x=0; y=0; initial begin #0 x=1; #0 y=1; end Used to eliminate race condition SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 34

Event based timing control Event can be change in value of a register or net The @ symbol is used to specify an event control Statements can be executed at a positive or negative transition of a signal value @ ( clock ) q = d; @ ( posedge clock ) q = d; @ ( negedge clock ) q = d; q = @ ( posedge clock ) d; SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 35

Level sensitive timing control The ability to wait for a certain condition to be true The keyword wait is used for level sensitive constructs. always wait (count_enable) #20 count = count + 1; SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 36

Outline 1. Motivation 2. Basic Syntax 3. Sequential and Parallel Blocks 4. Conditions and Loops in Verilog 5. Procedural Assignment 6. Timing controls 7. Combinatorial Logic in Verilog 8. Race conditions 9. Summary SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 37

Combinatorial logic in Verilog Combinatorial logic vs Sequential logic Blocking assignments which happen sequentially are used for combinational logic Non- Blocking assignments which happen in parallel are used for sequential logic Assign keyword for blocking statements SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 38

Outline 1. Motivation 2. Basic Syntax 3. Sequential and Parallel Blocks 4. Conditions and Loops in Verilog 5. Procedural Assignment 6. Timing controls 7. Combinatorial Logic in Verilog 8. Race conditions 9. Summary SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 39

Race Conditions Verilog does not guarantee order of execution initial a=0; initial b=a; initial begin end #1; $display( Value a=%a Value of b=%b,a,b); Possible values for a and b..? SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 40

Outline 1. Motivation 2. Basic Syntax 3. Sequential and Parallel Blocks 4. Conditions and Loops in Verilog 5. Procedural Assignment 6. Timing controls 7. Combinatorial Logic in Verilog 8. Race conditions 9. Summary SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 41

Summary Complex logic simulation Easier to develop and debug circuits Easy to code and learn ( constructs similar to programming languages ) SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 42

So its now time for demo! SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 43

Example x=ax+y module test(); initial begin $dumpfile("myfirsttask1.vcd"); $dumpvars(0,test); end reg [3:0] x; reg [3:0] a; reg [3:0] y; initial begin x = 4'd1; a = 4'd1; y = 4'd2; $display( "x= ax+y"); $monitor("%g x = %b a = %b y = %b", $time, x, a, y); #5 $finish; end always #1 x = x*a +y; endmodule SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 44

SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 45

Modules module test; reg clk, reset; wire [3:0] q; ripple_carry_counter rcc(q, clk, reset); initial begin $dumpfile("dump.vcd"); $dumpvars(0, test); clk = 1'b0; reset = 1'b1; #20 reset = 1'b0; #200 reset = 1'b1; #30 reset = 1'b0; #30; $finish; end always #5 clk = ~clk; endmodule module tff(q, clk, reset); output reg q; input clk, reset; always@ (posedge reset or posedge clk) begin if(reset)begin q<=1'b0; end else begin q<= ~q; end end endmodule module ripple_carry_counter(q, clk, reset); output[3:0] q; input clk, reset; tff tff0(q[0], ~clk, reset); tff tff1(q[1], ~q[0], reset); tff tff2(q[2], ~q[1], reset); tff tff3(q[3], ~q[2], reset); endmodule SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 46

SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 47

References Verilog Hardware Descriptive Language 5th edition, Donald Thomas, Philip Moorby, 2002,Kluwer Academic. Verilog HDL, A guide to digital design and synthesis, Samir Palnitkar, Sun Soft Press Verilog HDL Synthesis ( A practical primer ), J Bhasker, Star galaxy publishing Verilog Non Blocking assignment with Delays, Myths and Mysteries, Clifford E. Cummings, 2002, Sunburst Design Inc, 1-18, 44-47 Graphics source Wikipedia.org http://www.edaplayground.com/ SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 48

Credits Deepjyoti Borah Need for Verilog Sequential and Parallel blocks Conditions and Loops in Verilog DEMO Ripple carry counter 4 bit Diwahar Jawahar Behaviour modelling in Verilog Event and delay based timing controls Procedural assignment and Structured procedures Combinatorial Logic in Verilog & DEMO SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 49

Questions? SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 50

Thank you! SEMINAR HPC : Deepjyoti Borah, Diwahar Jawahar 51