EMT 351/4 DIGITAL IC DESIGN Verilog Behavioral Modeling  Constructs for Activity Flow Control  Task & Function  System Tasks for Timing Checks.

Slides:



Advertisements
Similar presentations
VERILOG: Synthesis - Combinational Logic Combination logic function can be expressed as: logic_output(t) = f(logic_inputs(t)) Rules Avoid technology dependent.
Advertisements

CS 3850 Lecture 6 Tasks and Functions. 6.1 Tasks and Functions Tasks are like procedures in other programming languages. e. g., tasks may have zero or.
Verilog Overview. University of Jordan Computer Engineering Department CPE 439: Computer Design Lab.
Synchronous Sequential Logic
Combinational Logic.
Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 07: Verilog (3/3) Prof. Sherief Reda Division of.
Table 7.1 Verilog Operators.
Hardware Description Language (HDL)
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
ELEN 468 Lecture 91 ELEN 468 Advanced Logic Design Lecture 9 Behavioral Descriptions III.
Verilog Sequential Circuits Ibrahim Korpeoglu. Verilog can be used to describe storage elements and sequential circuits as well. So far continuous assignment.
ELEN 468 Lecture 161 ELEN 468 Advanced Logic Design Lecture 16 Synthesis of Language Construct II.
Silicon Programming--Intro. to HDLs1 Hardware description languages: introduction intellectual property (IP) introduction to VHDL and Verilog entities.
ECEN ECEN475 Introduction to VLSI System Design Verilog HDL.
ELEN 468 Advanced Logic Design
Digital System Design Verilog ® HDL Tasks and Functions Maziar Goudarzi.
Advanced Verilog EECS 270 v10/23/06.
Digital System Design Verilog ® HDL Behavioral Modeling (1) Maziar Goudarzi.
Today’s Lecture Process model –initial & always statements Assignments –Continuous & procedural assignments Timing Control System tasks.
Timing control in verilog Module 3.1 Delays in Verilog.
Overview Logistics Last lecture Today HW5 due today
Tasks and Functions Programmable Logic Design (40-493) Fall 2001 Computer Engineering Department Sharif University of Technology Maziar Gudarzi.
Module : TASKS, Functions and UDPs in Verilog. Functions Functions are declared with the keywords function and endfunction. Functions are used if all.
Week Four Design & Simulation Example slides. Agenda Review the tiny example (Minako “logic”)from last week – look at the detailed static timing report.
Chapter 4: Behavioral Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 4-1 Ders – 4: Davranışsal Modelleme.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
Digital System Design Verilog ® HDL Behavioral Modeling Maziar Goudarzi.
3/4/20031 ECE 551: Digital System Design * & Synthesis Lecture Set 3 3.1: Verilog - User-Defined Primitives (UDPs) (In separate file) 3.2: Verilog – Operators,
1 Hardware description languages: introduction intellectual property (IP) introduction to VHDL and Verilog entities and architectural bodies behavioral,
Behavioral Modelling - 1. Verilog Behavioral Modelling Behavioral Models represent functionality of the digital hardware. It describes how the circuit.
ELEN 468 Lecture 131 ELEN 468 Advanced Logic Design Lecture 13 Synthesis of Combinational Logic II.
M.Mohajjel. Structured Procedures Two basic structured procedure statements always initial All behavioral statements appear only inside these blocks Each.
Verilog® HDL Behavioral Modeling (2)
OUTLINE Introduction Basics of the Verilog Language Gate-level modeling Data-flow modeling Behavioral modeling Task and function.
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
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.
Structural Description
Overview Logistics Last lecture Today HW5 due today
Verilog Tutorial Fall
Supplement on Verilog FF circuit examples
Supplement on Verilog for Algorithm State Machine Chart
Figure 8.1. The general form of a sequential circuit.
TODAY’S OUTLINE Verilog Codings Concurrent and Sequential If-else
ELEN 468 Advanced Logic Design
Verilog Introduction Fall
‘if-else’ & ‘case’ Statements
Behavioral Modeling Structural modeling Behavioral modeling
Timing Model Start Simulation Delay Update Signals Execute Processes
TODAY’S OUTLINE Testbench Circuit Verilog Operators
Verilog-HDL-3 by Dr. Amin Danial Asham.
Verilog HDL.
Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-I]
Behavioral Modeling in Verilog
Introduction To Verilog-HDL
Chapter 7: Advanced Modeling Techniques
RTL Style در RTL مدار ترتيبي به دو بخش (تركيبي و عناصر حافظه) تقسيم مي شود. مي توان براي هر بخش يك پروسس نوشت يا براي هر دو فقط يك پروسس نوشت. مرتضي صاحب.
Developing More Advanced Testbenches
FSM MODELING MOORE FSM MELAY FSM. Introduction to DIGITAL CIRCUITS MODELING & VERIFICATION using VERILOG [Part-2]
COE 202 Introduction to Verilog
101-1 Under-Graduate Project Logic Design with Behavioral Models
Chapter 4: Behavioral Modeling
Test Fixture (Testbench)
Dr. Tassadaq Hussain Introduction to Verilog – Part-3 Expressing Sequential Circuits and FSM.
The Verilog Hardware Description Language
ECE 551: Digital System Design & Synthesis
Introduction to Digital IC Design
Introduction to Verilog – Part-2 Procedural Statements
Reconfigurable Computing (EN2911X, Fall07)
Presentation transcript:

EMT 351/4 DIGITAL IC DESIGN Verilog Behavioral Modeling  Constructs for Activity Flow Control  Task & Function  System Tasks for Timing Checks

CONSTRUCTS FOR ACTIVITY FLOW CONTROL Procedural control statements modify the activity flow within a behavior by determining whether: Procedural control statements modify the activity flow within a behavior by determining whether: 1. To select or branch among alternative statements – (? … :, case, if) 2. Execute certain computations repeatedly – (repeat, for, while, forever) 3. Suspend activity flow for a specified time or until a condition has been met – (wait) 4. Branch into parallel activity flow – (fork … join) 5. Terminate execution of a task – (disable)

ACTVITY FLOW CONTROL 1. To select or branch among alternative statements – using conditional operator (? … :) module mux_behavior (y_out, clock, reset, sel, a, b); input clock, reset, sel; input [15:0] a, b; output [15:0] y_out; reg [15:0] y_out; (posedge clock or negedge reset) if (reset == 0) y_out = 0; else y_out = (sel) ? a+b : a-b; endmodule

ACTVITY FLOW CONTROL 1. To select or branch among alternative statements – using case statement (case) module mux4_case (a,b,c,d,select,y_out); input a,b,c,d; input [1:0] select; output y_out; reg y_out; (a or b or c or d or select) begin case (select) 0 : y_out = a; 1 : y_out = b; 2 : y_out = c; 3 : y_out = d; default y_out = 1’bx; endcase end endmodule

ACTVITY FLOW CONTROL 1. To select or branch among alternative statements – using conditional statement (if … else) module mux4_if (a,b,c,d,select,y_out); input a,b,c,d; input [1:0] select; output y_out; reg y_out; (a or b or c or d or select) begin if (select == 00) y_out = a; else if (select == 01) y_out = b; else if (select == 10) y_out = c; else y_out = d; end endmodule

ACTVITY FLOW CONTROL 2. Execute certain computations repeatedly – using repeat loop module repeater (clk,outA); input clk; output outA; reg inA; reg outA; initial begin inA = 1; #100 inA = 0; #50 inA = 1; #50 inA = 0; #200; end initial begin outA = repeat (posedge clk) inA; end endmodule

ACTVITY FLOW CONTROL 2. Execute certain computations repeatedly – using for loop module ANDgate_tb (); reg inputA, inputB; wire outputA; integer i; initial begin for (i=0; i<4; i=i+1) begin {inputA, inputB} = i; #10; end ANDgate ANDgate_inst (inputA, inputB, outputA); endmodule

ACTVITY FLOW CONTROL 2. Execute certain computations repeatedly – using forever loop ……. parameter half_cycle = 100; initial begin: clock_loop forever begin #half_cycle_clock = 0; #half_cycle_clock = 1; end; end endmodule

ACTVITY FLOW CONTROL 3. Suspend activity flow for a specified time or until a condition has been met – using wait statement module wait_sample (a,b,en,y1,y2); input a,b,en; output y1,y2; reg y1,y2; always begin wait (en) y1 = a; #100 y2 = b; #100; end endmodule

ACTVITY FLOW CONTROL 4. Branch into parallel activity flow – using fork … join statement Fork... Join syntax does not supported by synthesis tools Fork... Join syntax does not supported by synthesis tools Conveniently supports waveform generation for tb Conveniently supports waveform generation for tb Once the fork…join statement execute, all of the following activity cannot be executed until fork…join statement is complete Once the fork…join statement execute, all of the following activity cannot be executed until fork…join statement is complete … fork #50 sig_wave = ‘b1; #100 sig_wave = ‘b0; #150 sig_wave = ‘b1; #300 sig_wave = ‘b0; join ……

ACTVITY FLOW CONTROL 5. Terminate execution of a task – using disable statement module find_first_one (A_word,trigger,index_value); input [15:0] A_word; input trigger; output [3:0] index_value; reg [3:0] index_value; (trigger) begin index_value = 0; for (index_value=0; index_value<=15; index_value=index_value+1); if (A_word[index_value]==1) disable; end endmodule

TASKS AND FUNCTIONS Verilog has two types of sub-programs: Verilog has two types of sub-programs: Tasks Tasks - Create hierarchical organization of the procedural statements within a Verilog behavior Functions Functions - Only can be implemented using combinational behavior Tasks and functions let designers manage a smaller segment of code Tasks and functions let designers manage a smaller segment of code Able to improve the readability, portability and maintainability of code Able to improve the readability, portability and maintainability of code

TASKS Need to declared within a module and referenced only from within a behavior Need to declared within a module and referenced only from within a behavior Can have parameters passed to it, and the results can be passed back to the environment Can have parameters passed to it, and the results can be passed back to the environment All the inputs and outputs declared in a task will be associated with the inputs and outputs declared in a module according to the order All the inputs and outputs declared in a task will be associated with the inputs and outputs declared in a module according to the order A task must be named, and may include declarations of any number or combination of the following: A task must be named, and may include declarations of any number or combination of the following: - parameter, input, output, inout, reg, integer, real, time, realtime and event

Example 1 Multiple 4-bit bitwise operation module bitwise.. …. reg [3:0] AB_and, AB_or, AB_xor; reg [3:0] A, B; (A or B) begin bitwise_optn (AB_and, AB_or, AB_xor, A, B); end task bitwise_optn output [3:0] AB_and, AB_or, AB_xor; input A, B; begin # 5AB_and = A & B; AB_or = A |B; AB_xor = A ^ B; endendtask….endmodule

module bit_counter (dataword, bit_count); input [7:0] dataword; output [3:0] bit_count; reg [3:0] bit_count; (dataword) count_ones_in_word (dataword, bit_count); task count_ones_in_word; input [7:0] reg_a; output [3:0] count; reg [3:0] count; reg [7:0] temp_reg; begin count = 0; count = 0; temp_reg = reg_a; temp_reg = reg_a; while (temp_reg) while (temp_reg)begin count = count + temp_reg[0]; count = count + temp_reg[0]; temp_reg = temp_reg >> 1; temp_reg = temp_reg >> 1;endendendtaskendmodule Example 2 Number of 1’s counter

Simulation result for no. of 1’s counter Cont..

FUNCTIONS Compute only value on the basis of the present value of the parameters passed into the function Compute only value on the basis of the present value of the parameters passed into the function May not contain timing controls such as: May not contain timing controls such as: - delay control, event control, wait statement Also may not invoke a task within a function Also may not invoke a task within a function Must be declared within a module, and may contain declaration of inputs and local variables Must be declared within a module, and may contain declaration of inputs and local variables Implemented by expression and returns a value to the original location Implemented by expression and returns a value to the original location May not have any declaration of output or inout May not have any declaration of output or inout Must have at least one input argument Must have at least one input argument

Example 3 Left & Right bit shifter module shifter… … reg [7:0] addr, left_addr, right_addr; reg control; (addr) begin left_addr = shift (addr, 0); right_addr = shift (addr, 1); end function [7:0] shift; input [7:0] address; input control; begin shift = (control == 0) ? (address > 1); endendfunctionendmodule

module word_aligner (word_in,word_out); input [7:0] word_in; output [7:0] word_out; assign word_out = aligned_word (word_in); function [7:0] aligned_word; input [7:0] aligned_word; begin aligned_word = word_in; aligned_word = word_in; if (aligned_word != 0) if (aligned_word != 0) while (aligned_word[7] == 0) aligned_word = aligned_word << 1; while (aligned_word[7] == 0) aligned_word = aligned_word << 1;endendfunctionendmodule Example 4 Word Aligner

Cont.. Simulation result of word aligner

Task vs. Function Task Task A task can enable other task & function A task can enable other task & function Tasks may execute in non- zero simulation time Tasks may execute in non- zero simulation time Tasks may contain delay, event, or timing control statements Tasks may contain delay, event, or timing control statements Task may have zero or more arguments of type input, output or inout Task may have zero or more arguments of type input, output or inout Tasks do not return with a value, but can pass multiple values thru output & inout arguments Tasks do not return with a value, but can pass multiple values thru output & inout arguments Function Function A function can enable another function, but not task Function always execute at 0 simulation time Functions may not contain any delay, event, or timing control statements Functions must have at least 1 input argument – can have more than 1 input Functions always return a single value – cannot have output / inout arguments

SYSTEM TASKS FOR TIMING CHECKS There are 2 basic forms of timing analysis: There are 2 basic forms of timing analysis: Static analysis – considers the structural topology of a circuit, enumerates the paths along which signals can propagate, and determines whether certain timing constraints are met Static analysis – considers the structural topology of a circuit, enumerates the paths along which signals can propagate, and determines whether certain timing constraints are met Dynamic analysis – verifies the timing of a circuit through simulation Dynamic analysis – verifies the timing of a circuit through simulation

SYSTEM TASKS FOR TIMING CHECKS Static analysis Static analysis Advantages Advantages 1. Considers all possible paths thru the circuit 2. Does not miss reporting a timing violation Disadvantage Disadvantage 1. May generate timing reports on “false paths” in the circuit Dynamic analysis Dynamic analysis Advantage Advantage 1. Only good as the stimulus set used to simulate the circuit Disadvantages Disadvantages 1. Timing violation can be missed if the stimulus set fails to exercise all functional paths 2. Does not report false alarms 3. Become less practical and reliable for global verification when apply for huge circuits

SYSTEM TASKS FOR TIMING CHECKS Setup and hold conditions Setup and hold conditions $setup (data, posedge clk, 5)

SYSTEM TASKS FOR TIMING CHECKS Setup and hold conditions Setup and hold conditions $hold (data, posedge clk, 2)

SYSTEM TASKS FOR TIMING CHECKS Setup and hold conditions Setup and hold conditions $setuphold (data, posedge clk, 5, 2)

SYSTEM TASKS FOR TIMING CHECKS Signal period Signal period Used to check whether the period of a signal is sufficiently long Used to check whether the period of a signal is sufficiently long $period (posedge clock_a, t_limit)

SYSTEM TASKS FOR TIMING CHECKS Minimum pulse width Minimum pulse width To check the width of the active edge pulse of the clock signal must not be too small To check the width of the active edge pulse of the clock signal must not be too small $width (posedge clock_a, t_mpw)

SYSTEM TASKS FOR TIMING CHECKS Signal skew Signal skew Used to denote the time interval between reference features of two waveforms Used to denote the time interval between reference features of two waveforms $skew (negedge clk1, negedge clk2, t_skew)