Module : TASKS, Functions and UDPs in Verilog. Functions Functions are declared with the keywords function and endfunction. Functions are used if all.

Slides:



Advertisements
Similar presentations
HDL Programming Fundamentals
Advertisements

VERILOG: Synthesis - Combinational Logic Combination logic function can be expressed as: logic_output(t) = f(logic_inputs(t)) Rules Avoid technology dependent.
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.
CDA 3100 Recitation Week 11.
Simulation executable (simv)
The Verilog Hardware Description Language
Supplement on Verilog adder examples
Synchronous Sequential Logic
Combinational Logic.
ELEN 468 Lecture 21 ELEN 468 Advanced Logic Design Lecture 2 Hardware Modeling.
Chap. 6 Dataflow Modeling
Reconfigurable Computing S. Reda, Brown University Reconfigurable Computing (EN2911X, Fall07) Lecture 07: Verilog (3/3) Prof. Sherief Reda Division of.
Multiplication and Division
Chapter 11 Verilog HDL Application-Specific Integrated Circuits Michael John Sebastian Smith Addison Wesley, 1997.
Hardware Description Language (HDL)
1 Workshop Topics - Outline Workshop 1 - Introduction Workshop 2 - module instantiation Workshop 3 - Lexical conventions Workshop 4 - Value Logic System.
 HDLs – Verilog and Very High Speed Integrated Circuit (VHSIC) HDL  „ Widely used in logic design  „ Describe hardware  „ Document logic functions.
Introduction to Verilog
The Control Logic Andreas Klappenecker CPSC321 Computer Architecture.
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.
Using Templates Object-Oriented Programming Using C++ Second Edition 11.
Silicon Programming--Intro. to HDLs1 Hardware description languages: introduction intellectual property (IP) introduction to VHDL and Verilog entities.
ENEE 408C Lab Capstone Project: Digital System Design Spring 2005 Class Web Site: e408c.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE VLSI System Design Lecture 4 - Advanced Verilog.
Digital System Design Verilog ® HDL Tasks and Functions Maziar Goudarzi.
Advanced Verilog EECS 270 v10/23/06.
2/3/03ΗΥ220 - Μαυροειδής Ιάκωβος1 Delays in Behavioral Verilog - Interassignment Delay  Key idea: unlike blocking delay, RHS is evaluated before delay.
B. RAMAMURTHY Hardware Description Language 8/2/
Today’s Lecture Process model –initial & always statements Assignments –Continuous & procedural assignments Timing Control System tasks.
Overview Logistics Last lecture Today HW5 due today
RTL Coding tips Lecture 7,8 Prepared by: Engr. Qazi Zia, Assistant Professor EED, COMSATS Attock.
each of these is an instantiation of “full_adder”
Tasks and Functions Programmable Logic Design (40-493) Fall 2001 Computer Engineering Department Sharif University of Technology Maziar Gudarzi.
ECE 2372 Modern Digital System Design
Verilog Language Concepts
CS 3850 Lecture 3 The Verilog Language. 3.1 Lexical Conventions The lexical conventions are close to the programming language C++. Comments are designated.
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.
Module 2.1 Gate-Level/Structural Modeling UNIT 2: Modeling in Verilog.
ECE/CS 352 Digital System Fundamentals© 2001 C. Kime 1 ECE/CS 352 Digital Systems Fundamentals Spring 2001 Chapters 3 and 4: Verilog – Part 2 Charles R.
1 CSE-308 Digital System Design (DSD) N-W.F.P. University of Engineering & Technology, Peshawar.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
Charles Kime & Thomas Kaminski © 2004 Pearson Education, Inc. Terms of Use (Hyperlinks are active in View Show mode) Terms of Use Verilog Part 3 – Chapter.
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 Verilog Digital System Design Z. Navabi, 2006 Verilog Language Concepts.
ELEN 468 Lecture 131 ELEN 468 Advanced Logic Design Lecture 13 Synthesis of Combinational Logic II.
Verilog A Hardware Description Language (HDL ) is a machine readable and human readable language for describing hardware. Verilog and VHDL are HDLs.
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
Spring 2009W. Rhett DavisNC State UniversityECE 406Slide 1 ECE 406 – Design of Complex Digital Systems Lecture 6: Procedural Modeling Spring 2009 W. Rhett.
Multiplexers Section Topics Multiplexers – Definition – Examples – Verilog Modeling.
COE 202 Introduction to Verilog Computer Engineering Department College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals.
Chapter 3: Dataflow Modeling Digital System Designs and Practices Using Verilog HDL and 2008~2010, John Wiley 3-1 Chapter 3: Dataflow Modeling.
SYEN 3330 Digital SystemsJung H. Kim Chapter SYEN 3330 Digital Systems Chapters 4 – Part4: Verilog – Part 2.
1 Verilog: Function, Task Verilog: Functions A function call is an operand in an expression. It is called from within the expression and returns a value.
TOPIC : SEQUENTIAL AND PARALLEL BLOCKS Module 2.3 : Behavioral modeling in verilog.
EMT 351/4 DIGITAL IC DESIGN Verilog Behavioral Modeling  Constructs for Activity Flow Control  Task & Function  System Tasks for Timing Checks.
Structural Description
Overview Logistics Last lecture Today HW5 due today
Reg and Wire:.
Verilog Introduction Fall
Behavioral Modeling Structural modeling Behavioral modeling
Introduction To Verilog-HDL
HDL Programming Fundamentals
Register-Transfer Level Components in Verilog
Supplement on Verilog combinational circuit examples
COE 202 Introduction to Verilog
Reconfigurable Computing (EN2911X, Fall07)
Presentation transcript:

Module : TASKS, Functions and UDPs in Verilog

Functions Functions are declared with the keywords function and endfunction. Functions are used if all of the following conditions are true for the procedure. There are no delay, timing, or event control constructs in the procedure. The procedure returns a single value. There is at least one input argument.

Function features When a function is declared, a register with name is declared implicitly inside Verilog. The output of a function is passed back by setting the value of the register appropriately. Notice that at least one input argument must be defined for a function. Functions cannot invoke other tasks. They can only invoke other functions.

Typical Structure of a Function

Example 1 The first example models a parity calculator that returns a 1-bit value. Let us discuss a function that calculates the parity of a 32-bit address and returns the value. We assume even parity. Example 1 shows the definition and invocation of the function calc-parity. The verilog code is shown in the next page.

Example 1 : Parity calculations module parity; reg [31:0] addr; reg parity; begin parity = calc_parity(addr); end function calc_parity input [31:0] address; begin calc_parity = ^address; end endfunction endmodule //Return the xor of all address bits. //invocation of calc_parity function

Example 2 : left-right shifter To illustrate how a range for the output value of a function can be specified, let us consider a function that shifts a 32-bit value to the left or right by one bit, based on a control signal. Example 2 shows the implementation of the left/right shifter. The verilog code has been shown in next page.

Example 2 : Left-Right Shifter module shifter: 'define LEFT-SHIFT l'bO 'define RIGHT-SHIFT l'bl reg [31:0] addr, left-addr, right-addr; reg control; (addr ) begin //call the function defined below to do left and right shift. left-addr = shift(addr, 'LEFT-SHIFT); right-addr = shift(addr, 'RIGHT-SHIFT); end function [31: 0] shift; //define shift function. The output is a 32-bit value. input [31:0] address; input control; begin shift = (control == 'LEFT-SHIFT) ?(address > 1); end endfunction endmodule //Compute the right- and left-shifted values whenever //a new address value appears