ECEN 468 Advanced Digital System Design

Similar documents
ECEN 468 Advanced Logic Design

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

Verilog Behavioral Modeling

EECS150 - Digital Design Lecture 10 Logic Synthesis

EECS150 - Digital Design Lecture 10 Logic Synthesis

Course Topics - Outline

RIZALAFANDE CHE ISMAIL TKT. 3, BLOK A, PPK MIKRO-e KOMPLEKS PENGAJIAN KUKUM. BEHAVIORAL DESCRIPTIONS IN VERILOG HDL (Chapter 7)

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

Lab 7 (All Sections) Prelab: Introduction to Verilog

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

Behavioral Modeling and Timing Constraints

Logic Synthesis. EECS150 - Digital Design Lecture 6 - Synthesis

14. Introducton to Verilog

Chapter 2 Using Hardware Description Language Verilog. Overview

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

Synthesizable Verilog

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

CSE140L: Components and Design Techniques for Digital Systems Lab

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

CSE140L: Components and Design

Online Verilog Resources

EEL 4783: HDL in Digital System Design

Chap 6 Introduction to HDL (d)

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

VLSI Design 13. Introduction to Verilog

14. Introducton to Verilog

Digital System Design Verilog-Part III. Amir Masoud Gharehbaghi

Programmable Logic Devices Verilog VII CMPE 415

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

CS6710 Tool Suite. Verilog is the Key Tool

Behavioral Modeling and Timing Constraints

In this lecture, we will go beyond the basic Verilog syntax and examine how flipflops and other clocked circuits are specified.

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

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

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

Course Topics - Outline

ECE 4514 Digital Design II. Spring Behavioral Modeling II: Conditionals and Loops

CS6710 Tool Suite. Verilog is the Key Tool. Verilog as HDL (AHT) Verilog has a Split Personality. Quick Review. Synthesis

Under-Graduate Project Logic Design with Behavioral Models

Introduction To Verilog Design. Chun-Hung Chou

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

Hanbat National University Prof. Lee Jaeheung

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

Nonblocking Assignments in Verilog Synthesis; Coding Styles That Kill!

Synthesis of Combinational and Sequential Circuits with Verilog

Veriolog Overview. CS/EE 3710 Fall 2010

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

Verilog for Synthesis Ing. Pullini Antonio

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

Amrita Vishwa Vidyapeetham. EC429 VLSI System Design Answer Key

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

ES611 FPGA Based System Design. Behavioral Model

Lecture 2: Data Types, Modeling Combinational Logic in Verilog HDL. Variables and Logic Value Set. Data Types. Why use an HDL?

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

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

Verilog HDL Introduction

Contents. Appendix D Verilog Summary Page 1 of 16

VERILOG. Deepjyoti Borah, Diwahar Jawahar

Register Transfer Level in Verilog: Part I

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

Lecture #2: Verilog HDL

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

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

Chapter 4 :: Topics. Introduction. SystemVerilog. Hardware description language (HDL): allows designer to specify logic function only.

Verilog Nonblocking Assignments with Delays - Myths & Mysteries

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis

Verilog Fundamentals. Shubham Singh. Junior Undergrad. Electrical Engineering

Last Lecture. Talked about combinational logic always statements. e.g., module ex2(input logic a, b, c, output logic f); logic t; // internal signal

A Tutorial Introduction 1

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

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

Modeling Sequential Circuits in Verilog

Module 4. Design of Embedded Processors. Version 2 EE IIT, Kharagpur 1

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

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

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

Quick Introduction to SystemVerilog: Sequental Logic

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

Lecture 3. Behavioral Modeling Sequential Circuits. Registers Counters Finite State Machines

Blocking(=) vs Nonblocking (<=) Assignment. Lecture 3: Modeling Sequential Logic in Verilog HDL. Procedural assignments

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

Hardware Description Languages. Veriolog Overview. CS/EE 3710 Fall Verilog. Verilog Origins. Quick Review (2001 syntax) Quick Review HDL

Digital Design using HDLs EE 4755 Midterm Examination

Lecture 15: System Modeling and Verilog

Introduction to Digital Design with Verilog HDL

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

EN2911X: Reconfigurable Computing Lecture 05: Verilog (2)

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

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

EN2911X: Reconfigurable Computing Topic 02: Hardware Definition Languages

EE 231 Fall EE 231 Homework 8 Due October 20, 2010

Chapter 4. Digital Design and Computer Architecture, 2 nd Edition. David Money Harris and Sarah L. Harris. Chapter 4 <1>

Hardware Description Language (HDL)

Chapter 4. Digital Design and Computer Architecture, 2 nd Edition. David Money Harris and Sarah L. Harris. Chapter 4 <1>

VERILOG 2: LANGUAGE BASICS

Verilog HDL. Testing & Verification Dept. of Computer Science & Engg,, IIT Kharagpur

Hardware Description Languages: Verilog

Lecture 32: SystemVerilog

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

Verilog For Synthesis

Transcription:

ECEN 468 Advanced Digital System Design Lecture 22: Verilog Behavioral Description

Structural vs. Behavioral Descriptions module my_module(); assign ; // continuous assignment and (); // instantiation of primitive adder_16 M(); // instantiation of module always @() initial module Structural, no order Behavior, in order in each procedure 2

Behavioral Descriptions In General v Co-exists with gate instantiations v Not all descriptions synthesize v Not all synthesized descriptions are desirable v Within a module o Multiple behaviors are allowed o Nested behaviors are not allowed 3

Behavioral Statements initial always single_statement; block_of_statements; v initial o Activated from t sim = 0 o Executed once o Initialize a simulation v always o Activated from t sim = 0 o Executed cyclically o Continue till simulation terminates 4

Example of Behavioral Statement module clock1 ( clk ); parameter half_cycle = 50; parameter max_time = 1000; output clk; reg clk; initial clk = 0; always #half_cycle clk = ~clk; initial #max_time $finish; module clk 50 100 150 200 t sim 5

Assignment v Continuous assignment o Values are assigned to net variables due to some input variable changes o assign = v Procedural assignment o Values are assigned to register variables when certain statement is executed in a behavior o Procedural assignment, = o Procedural continuous assignment, assign = [deassign] o Non-blocking assignment, <= 6

Blocking and Non-blocking Assignment initial a = 1; b = 0; a = b; // a = 0; b = a; // b = 0; initial a = 1; b = 0; a <= b; // a = 0; b <= a; // b = 1; v Blocking assignment = o Statement order matters o A statement has to be executed before next statement v Non-blocking assignment <= o Concurrent assignment o If there are multiple non-blocking assignments to same variable in same behavior, latter overwrites previous 7

Procedural Continuous Assignment v Continuous assignment establishes static binding for net variables v Procedural continuous assignment (PCA) establishes dynamic binding for variables o assign deassign for register variables only o force release for both register and net variables 8

assign deassign PCA v Binding takes effect when PCA statement is executed v Can be overridden by another PCA statement v deassign is optional v assign takes control, deassign release control module flop ( q, qbar, preset, clear, clock, data ); assign qbar = ~q; initial q = 0; always @ ( negedge clk ) q = data; always @ ( clear or preset ) if (!preset ) assign q = 1; else if (!clear ) assign q = 0; else deassign q; module 9

Example of assign module mux4_pca(a, b, c, d, select, y_out); input a, b, c, d; input [1:0] select; output y_out; reg y_out; always @(select) y_out changes with a; if (select == 0) assign y_out=a; else if (select == 1) assign y_out=b; else if (select == 2) assign y_out=c; else if (select == 3) assign y_out=d; else assign y_out=1 bx; module 10

Alternative module mux4_pca(a, b, c, d, select, y_out); input a, b, c, d; input [1:0] select; output y_out; reg y_out; always @(select or a or b or c or d) Value of a is assigned if (select == 0) y_out=a; to y_out at this time else if (select == 1) y_out=b; else if (select == 2) y_out=c; else if (select == 3) y_out=d; else y_out=1 bx; module 11

force release PCA force sig1 = 0; force sig2 = 1; moda Sig3 = 0; #9 sig3 = 1; sig2 sig1 modb release sig1; release sig2; sig3 v Similar to assigndeassign v Can be applied to net variables v Often applied in testing 12

Comparisons of Assignment Variable Output of primitive Net Seq-reg Continuous assignment mode Procedural assignment assign deassign PCA force release PCA Net Register Register Net and register description Structural Structural Behavioral Behavioral Behavioral binding Static Static Dynamic, one shot Dynamic, continuous Dynamic, continuous 13

Delay Control Operator (#) initial #0 in1 = 0; in2 = 1; #10 in3 = 1; #40 in4 = 0; in5 = 1; #60 in3 = 0; 14

Event Control Operator (@) @ ( eventa or eventb ) @ ( eventc ) v Event -> identifier or expression v When @ is reached o Activity flow is susped o The event is monitored o The other events are ignored o Other processes keep going v posedge: 0->1, 0->x, x->1 v negedge: 1->0, 1->x, x->0 v Cannot assign value to the event variable inside the synchronized behavior 15

Named Event module moda (); event sth_happens; // declaration always ->sth_happens; // trigger event module module modb(); always @ (top_mod.moda.sth_happens) module v Also called abstract event v Declared only in module with keyword event v Must be declared before it is used v Event is triggered by -> v Provide high level inter-module communication without physical details 16

Example of Named Event module flop_event ( clk, reset, data, q, q_bar ); input clk, reset, data; output q, q_bar; reg q; event up_edge; assign q_bar = ~q; always @ ( posedge clk ) -> up_edge; always @ ( up_edge or negedge reset ) if ( reset == 0 ) q = 0; else q = data; module 17

The wait Construct module moda (); always wait ( enable ) ra = rb; module v Activity flow is susped if expression is false v It resumes when the expression is true v Other processes keep going 18

Intra-assignment Delay: Blocking Assignment // B = 0 at time 0 // B = 1 at time 4 #5 A = B; // A = 1 C = D; A = #5 B; // A = 0 C = D; A = @(enable) B; C = D; A = @(named_event) B; C= D; v If timing control operator(#,@) on LHS o Blocking delay o RHS evaluated at (#,@) o Assignment at (#,@) v If timing control operator(#,@) on RHS o Intra-assignment delay o RHS evaluated immediately o Assignment at (#,@) 19

Intra-assignment Delay: Non-blocking Assignment always @ ( posedge clk ) G <= @ (bus) acc; C <= D; // not blocked " In 1 st cycle, acc is sampled " What if no bus change in the same cycle? " In next cycle, acc is sampled again " Value of acc from previous cycle is overwritten " Warning message v Sampling RHS immediately in the latest cycle v Wait for time control to execute assignment v Subsequent assignments are not blocked 20

Be Cautious module or8( y, a, b ); input [7:0] a, b; output [7:0] y; reg [7:0] y; initial assign y = a b; module v Model combinational logic by one-shot (initial) behavior v Valid v Not preferred v Not accepted by synthesis tool 21

Example initial a = #10 1; b = #2 0; c = #3 1; initial d <= #10 1; e <= #2 0; f <= #3 1; t a b c d e f 0 x x x x x x 2 x x x x 0 x 3 x x x x 0 1 10 1 x x 1 0 1 12 1 0 x 1 0 1 15 1 0 1 1 0 1 22

Tell the Differences always @ (a or b) y = a b; always @ (a or b) #5 y = a b; Which one describes or gate? Event control is blocked always @ (a or b) y = #5 a b; always @ (a or b) y <= #5 a b; 23

Simulation of Assignments v For each given time step o Evaluate all Right-Hand-Side o Execute blocking assignment, even if it is way after a nonblocking assignment o Execute non-blocking assignment that do not have intraassignment timing control o Execute past non-blocking assignment that is scheduled at this time o Execute $monitor. However, $display is executed whenever it is encountered. o Increment time step 24

Simulation of Non-blocking Assignment v Normally the last assignment at certain simulation time step v If it triggers other blocking assignments, it is executed before the blocking assignment it triggers always A <= B; always C = @(A) D; 25

Example initial a = 1; b = 0; a <= b; b <= a; $display( a=%b b=%b, a, b); initial a = 1; b = 0; a <= b; b <= a; $monitor( a=%b b=%b, a, b); a=1 b=0 a=0 b=1 26

Repeated Intra-assignment Delay rega = repeat (5) @ ( negedge clk ) regb; tmp = regb; @ ( negedge clk ); @ ( negedge clk ); @ ( negedge clk ); @ ( negedge clk ); @ ( negedge clk ); rega = tmp; 27

Indeterminate Assignment module multi_assign(); reg a, b, c, d; initial #5 a = 1; b = 0; always @ ( posedge a ) c = a; always @ ( posedge a ) c = b; always @ ( posedge a ) d = b; always @ ( posedge a ) d = a; module v Multiple assignments are made to same variable in different behavior v Value deps on code order or vor specifications v Similar to raceconditions in hardware 28

Activity Flow Control ( if else ) if ( A == B ) P = d; if ( B < C ); if ( a >= b ) v Syntax: if ( expression ) statement [ else statement ] v Value of expression o 0, x or z => false o Non-zero number => true if ( A < B ) P = d; else P = k; if ( A > B ) P = d; else if ( A < B ) P = k; else P = Q; 29

Conditional Operator (? : ) always @ ( posedge clock ) yout = ( sel )? a + b : a b; Conditional operator can be applied in either continuous assignments or behavioral descriptions 30

The case Statement module mux4 ( a, b, c, d, select, yout ); input a, b, c, d; input [1:0] select; output yout; reg yout; always @( a or b or c or d or select ) case ( select ) 0: yout = a; 1: yout = b; 2: yout = c; 3: yout = d; default yout = 1`bx; case module v Case items are examined in order v Exact match between case expression and case item v casex don t care bits with x or z v casez don t care bits with z 31

Expression Matching in case Construct Expression or case_item case casex casez 0 0 0 0 1 1 1 1 x x 0 1 x z x z z 0 1 x z 0 1 x z? (explicit don t care) N/A N/A 0 1 x z always @ ( pulse ) casez ( word ) 8`b0000???? : ; 32

The repeat Loop word_address = 0; repeat ( memory_size ) memory [word_address] = 0; word_address = word_address + 1; 33

The for Loop reg [15:0] rega; integer k; for ( k = 4; k; k = k 1 ) rega [ k+10 ] = 0; rega [ k+2 ] = 1; Loop variables have to be either integer or reg 34

The while Loop cnt1s reg [7:0] tmp; cnt = 0; tmp = rega; while ( tmp ) cnt = cnt + tmp[0]; tmp = tmp >> 1; Loop activities susp external activities module sth ( externalsig ); input externalsig; always while ( externalsig ); module Can be less forever 35

The disable Statement k = 0; for ( k = 0; k <= 15; k = k + 1 ) if ( word[ k ] == 1 ) disable ; Terminate prematurely in a block of procedural statements 36

The forever Loop parameter half_cycle = 50; initial : clock_loop clock = 0; forever #half_cycle clock = 1; #half_cycle clock = 0; initial #350 disable clock_loop; 37

always and forever always Declares a behavior Cannot be nested Executes when simulation s forever Computational activity flow within a behavior Can be nested Executes when statement is reached 38

Parallel Activity Flow fork // t_sim = 0 join #50 wave = 1; #100 wave = 0; #150 wave = 1; #300 wave = 0; // executes at t_sim = 300 Not supported by synthesis For simulation in testbench module race ( ); fork #150 a = b; #150 c = a; join module module fix_race ( ); fork a = #150 b; c = #150 a; join module 39