SlideShare a Scribd company logo
1|Page

Notes: Verilog Part 5
8 CHAPTER 8:
8.1 DIFFERENCE BETWEEN FUNCTION AND TASKS
Functions
A function can enable another function but not
another task.
Function always executes in 0 simulation time.
Functions must not contain any delay, event or
timing control statements.
Functions must have at least one input
argument. They can have more than one
arguments.
Functions always return a single value. They
cannot have output or inout arguments.

Tasks
A task can enable another task as well as a
function.
Tasks may execute in non-zero simulation time.
Tasks may contain any delay, event or timing
control statements.
Tasks may have zero arguments of type input,
output or inout.
Tasks do not return with a value, but can pass
multiple values through output and inout
arguments.

 Both Tasks and functions must be defined in a module and are local to the module.
 Tasks are useful for common Verilog problems that contain any event, delay, timing or
multiple argument constructs.
 Functions are used in purely combinational circuits that are to be executed in zero
simulation time.
 Tasks or Functions cannot have wires. They contain behavioural statements only.
 They do not contain initial or always blocks but can be called from always, initial or other
tasks and functions.

8.2 TASKS
 They are used with the keywords task and endtask. They are used if any one of the following
condition is true for the procedure.
 There are delay, timing or event control constructs in the procedure.
 The procedure has zero or more than one output arguments.
 The procedure has no input arguments.
 Task declaration and task invocation syntax is given as Syntax.
 Examples
 TASK: Bitwise Oper Module Operator
 Assymetric Sequence Generator
 Automatic Tasks:
 Tasks are normally static in nature. Hence when task is called
concurrently at two places in a code, there are chances that the task
calls will operate on the same task variables.
 This results in incorrect results.
 Hence we use automatic task. Here both the task calls are given
dynamic variables upon invocation.

Notes: Verilog Part 5

Prepared By: Jay Baxi
2|Page



Thus because of these independent copies of variables correct
results are obtained.
For example: Automatic (Re-entrant) Tasks.

8.3 FUNCTIONS
 Functions are declared within keywords function and endfunction.
 They are used when all of the following condition are true for 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.
 There are no output or inout arguments.
 There are no nonblocking assignments.
8.3.1

Function Declaration and Invocation
 The syntax for the function declaration and invocation are as
Function Declaration and Invocation.
 When a function is declared a register name function_identifier is
implicitly formed.
 The output is passed by setting the value of register
function_identifier.
 The function is invoked by specifying the name and argument. The
return value is placed where the function was invoked.
 Range_or_type specifies the width of the internal register. If it is not
defined, the default bit width is 1.

8.3.2 Function Examples
 Parity Calculation
 Left/Right Shifter
8.3.3

Recursive Functions





8.3.4

If a function is concurrently called from two different locations, the
result is non deterministic, because both calls operate on same
variables.
Verilog provides automatic to declare a recursive function where all
function declarations are dynamically allocated for each call.
They cannot be accessed by hierarchical references, however, they
can be invoked.
An example of Recursive Function: Factorial

Constant and Signed Functions
 A constant function is a normal Verilog function with certain
restrictions.
 It can be used to reference complex values and can be used instead
of constants.
 Signed Functions allow signed operations to be performed on the
function return values. It uses the keyword signed.

Notes: Verilog Part 5

Prepared By: Jay Baxi

More Related Content

What's hot

user defined function
user defined functionuser defined function
user defined function
King Kavin Patel
 
Lecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.pptLecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.ppt
eShikshak
 
INLINE FUNCTION IN C++
INLINE FUNCTION IN C++INLINE FUNCTION IN C++
INLINE FUNCTION IN C++
Vraj Patel
 
Functions in C
Functions in CFunctions in C
Functions in C
Kamal Acharya
 
Chapter 11 Function
Chapter 11 FunctionChapter 11 Function
Chapter 11 FunctionDeepak Singh
 
Inline functions & macros
Inline functions & macrosInline functions & macros
Inline functions & macros
Anand Kumar
 
Function
FunctionFunction
Function
Saniati
 
Pure functions and usage in Angular
Pure functions and usage in AngularPure functions and usage in Angular
Pure functions and usage in Angular
MA Jiangfan
 
Functions in c language1
Functions in c language1Functions in c language1
Functions in c language1
sirikeshava
 
Inline function in C++
Inline function in C++Inline function in C++
Inline function in C++
Jenish Patel
 
Function C++
Function C++ Function C++
Function C++
Shahzad Afridi
 
Function in c++
Function in c++Function in c++
Function in c++Kumar
 
User defined functions
User defined functionsUser defined functions
User defined functions
Rokonuzzaman Rony
 
Ch10 Program Organization
Ch10 Program OrganizationCh10 Program Organization
Ch10 Program Organization
SzeChingChen
 
Storage classess of C progamming
Storage classess of C progamming Storage classess of C progamming
Storage classess of C progamming
Appili Vamsi Krishna
 
Functional Programming for OO Programmers (part 1)
Functional Programming for OO Programmers (part 1)Functional Programming for OO Programmers (part 1)
Functional Programming for OO Programmers (part 1)
Calvin Cheng
 
(3) cpp procedural programming
(3) cpp procedural programming(3) cpp procedural programming
(3) cpp procedural programming
Nico Ludwig
 

What's hot (20)

user defined function
user defined functionuser defined function
user defined function
 
Lecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.pptLecture20 user definedfunctions.ppt
Lecture20 user definedfunctions.ppt
 
INLINE FUNCTION IN C++
INLINE FUNCTION IN C++INLINE FUNCTION IN C++
INLINE FUNCTION IN C++
 
Functions in C
Functions in CFunctions in C
Functions in C
 
Chapter 11 Function
Chapter 11 FunctionChapter 11 Function
Chapter 11 Function
 
Inline functions & macros
Inline functions & macrosInline functions & macros
Inline functions & macros
 
Function
FunctionFunction
Function
 
Parameter passing to_functions_in_c
Parameter passing to_functions_in_cParameter passing to_functions_in_c
Parameter passing to_functions_in_c
 
Pure functions and usage in Angular
Pure functions and usage in AngularPure functions and usage in Angular
Pure functions and usage in Angular
 
Functions in c language1
Functions in c language1Functions in c language1
Functions in c language1
 
Scope of variables
Scope of variablesScope of variables
Scope of variables
 
Function in C program
Function in C programFunction in C program
Function in C program
 
Inline function in C++
Inline function in C++Inline function in C++
Inline function in C++
 
Function C++
Function C++ Function C++
Function C++
 
Function in c++
Function in c++Function in c++
Function in c++
 
User defined functions
User defined functionsUser defined functions
User defined functions
 
Ch10 Program Organization
Ch10 Program OrganizationCh10 Program Organization
Ch10 Program Organization
 
Storage classess of C progamming
Storage classess of C progamming Storage classess of C progamming
Storage classess of C progamming
 
Functional Programming for OO Programmers (part 1)
Functional Programming for OO Programmers (part 1)Functional Programming for OO Programmers (part 1)
Functional Programming for OO Programmers (part 1)
 
(3) cpp procedural programming
(3) cpp procedural programming(3) cpp procedural programming
(3) cpp procedural programming
 

Viewers also liked

Notes: Verilog Part 2 - Modules and Ports - Structural Modeling (Gate-Level M...
Notes: Verilog Part 2 - Modules and Ports - Structural Modeling (Gate-Level M...Notes: Verilog Part 2 - Modules and Ports - Structural Modeling (Gate-Level M...
Notes: Verilog Part 2 - Modules and Ports - Structural Modeling (Gate-Level M...
Jay Baxi
 
Assic 13th Lecture
Assic 13th LectureAssic 13th Lecture
Assic 13th Lecture
babak danyal
 
Fpga 06-data-types-system-tasks-compiler-directives
Fpga 06-data-types-system-tasks-compiler-directivesFpga 06-data-types-system-tasks-compiler-directives
Fpga 06-data-types-system-tasks-compiler-directivesMalik Tauqir Hasan
 
Radiation Hardening by Design
Radiation Hardening by DesignRadiation Hardening by Design
Radiation Hardening by Design
Jay Baxi
 
Verilog Lecture4 2014
Verilog Lecture4 2014Verilog Lecture4 2014
Verilog Lecture4 2014
Béo Tú
 
Verilog Lecture5 hust 2014
Verilog Lecture5 hust 2014Verilog Lecture5 hust 2014
Verilog Lecture5 hust 2014
Béo Tú
 
Easy Learn to Verilog HDL
Easy Learn to Verilog HDLEasy Learn to Verilog HDL
Easy Learn to Verilog HDL
kpyes34
 
Seminar: Fabrication and Characteristics of CMOS
Seminar: Fabrication and Characteristics of CMOSSeminar: Fabrication and Characteristics of CMOS
Seminar: Fabrication and Characteristics of CMOSJay Baxi
 
Designing of fifo and serial peripheral interface protocol using Verilog HDL
Designing of fifo and serial peripheral interface protocol using Verilog HDLDesigning of fifo and serial peripheral interface protocol using Verilog HDL
Designing of fifo and serial peripheral interface protocol using Verilog HDL
Jay Baxi
 
Day2 Verilog HDL Basic
Day2 Verilog HDL BasicDay2 Verilog HDL Basic
Day2 Verilog HDL BasicRon Liu
 
First Year Basic Electronics Notes VTU Syllabus 2014 Scheme
First Year Basic Electronics Notes VTU Syllabus 2014 SchemeFirst Year Basic Electronics Notes VTU Syllabus 2014 Scheme
First Year Basic Electronics Notes VTU Syllabus 2014 Scheme
BMS Institute of Technology and Management
 
Web design and development cs506 handouts
Web design and development   cs506 handoutsWeb design and development   cs506 handouts
Web design and development cs506 handouts
Sohaib Danish
 
4Sem VTU-HDL Programming Notes-Unit1-Introduction
4Sem VTU-HDL Programming Notes-Unit1-Introduction4Sem VTU-HDL Programming Notes-Unit1-Introduction
4Sem VTU-HDL Programming Notes-Unit1-Introduction
Dr. Shivananda Koteshwar
 
Fundamentals of HDL (first 4 chapters only) - Godse
Fundamentals of HDL (first 4 chapters only) - GodseFundamentals of HDL (first 4 chapters only) - Godse
Fundamentals of HDL (first 4 chapters only) - Godse
Hammam
 
MOSFETs (10EC63) Notes for Electronics & Communication Engineering Students o...
MOSFETs (10EC63) Notes for Electronics & Communication Engineering Students o...MOSFETs (10EC63) Notes for Electronics & Communication Engineering Students o...
MOSFETs (10EC63) Notes for Electronics & Communication Engineering Students o...
Hanumantha Raju
 
Microelectronic Circuits Notes (10EC63) by Dr. M. C. Hanumantharaju of BMS In...
Microelectronic Circuits Notes (10EC63) by Dr. M. C. Hanumantharaju of BMS In...Microelectronic Circuits Notes (10EC63) by Dr. M. C. Hanumantharaju of BMS In...
Microelectronic Circuits Notes (10EC63) by Dr. M. C. Hanumantharaju of BMS In...
BMS Institute of Technology and Management
 
Microelectronic Circuits (10EC63) Notes for Visvesvaraya Technological Univer...
Microelectronic Circuits (10EC63) Notes for Visvesvaraya Technological Univer...Microelectronic Circuits (10EC63) Notes for Visvesvaraya Technological Univer...
Microelectronic Circuits (10EC63) Notes for Visvesvaraya Technological Univer...
BMS Institute of Technology and Management
 
Verilog tutorial
Verilog tutorialVerilog tutorial
Verilog tutorial
Maryala Srinivas
 
Embedded System Design Notes written by Arun Kumar G, Associate Professor, De...
Embedded System Design Notes written by Arun Kumar G, Associate Professor, De...Embedded System Design Notes written by Arun Kumar G, Associate Professor, De...
Embedded System Design Notes written by Arun Kumar G, Associate Professor, De...
Arunkumar Gowdru
 

Viewers also liked (20)

Notes: Verilog Part 2 - Modules and Ports - Structural Modeling (Gate-Level M...
Notes: Verilog Part 2 - Modules and Ports - Structural Modeling (Gate-Level M...Notes: Verilog Part 2 - Modules and Ports - Structural Modeling (Gate-Level M...
Notes: Verilog Part 2 - Modules and Ports - Structural Modeling (Gate-Level M...
 
Assic 13th Lecture
Assic 13th LectureAssic 13th Lecture
Assic 13th Lecture
 
Fpga 06-data-types-system-tasks-compiler-directives
Fpga 06-data-types-system-tasks-compiler-directivesFpga 06-data-types-system-tasks-compiler-directives
Fpga 06-data-types-system-tasks-compiler-directives
 
Radiation Hardening by Design
Radiation Hardening by DesignRadiation Hardening by Design
Radiation Hardening by Design
 
Verilog Lecture4 2014
Verilog Lecture4 2014Verilog Lecture4 2014
Verilog Lecture4 2014
 
Verilog Lecture5 hust 2014
Verilog Lecture5 hust 2014Verilog Lecture5 hust 2014
Verilog Lecture5 hust 2014
 
Easy Learn to Verilog HDL
Easy Learn to Verilog HDLEasy Learn to Verilog HDL
Easy Learn to Verilog HDL
 
Seminar: Fabrication and Characteristics of CMOS
Seminar: Fabrication and Characteristics of CMOSSeminar: Fabrication and Characteristics of CMOS
Seminar: Fabrication and Characteristics of CMOS
 
Designing of fifo and serial peripheral interface protocol using Verilog HDL
Designing of fifo and serial peripheral interface protocol using Verilog HDLDesigning of fifo and serial peripheral interface protocol using Verilog HDL
Designing of fifo and serial peripheral interface protocol using Verilog HDL
 
Day2 Verilog HDL Basic
Day2 Verilog HDL BasicDay2 Verilog HDL Basic
Day2 Verilog HDL Basic
 
First Year Basic Electronics Notes VTU Syllabus 2014 Scheme
First Year Basic Electronics Notes VTU Syllabus 2014 SchemeFirst Year Basic Electronics Notes VTU Syllabus 2014 Scheme
First Year Basic Electronics Notes VTU Syllabus 2014 Scheme
 
Web design and development cs506 handouts
Web design and development   cs506 handoutsWeb design and development   cs506 handouts
Web design and development cs506 handouts
 
4Sem VTU-HDL Programming Notes-Unit1-Introduction
4Sem VTU-HDL Programming Notes-Unit1-Introduction4Sem VTU-HDL Programming Notes-Unit1-Introduction
4Sem VTU-HDL Programming Notes-Unit1-Introduction
 
Fundamentals of HDL (first 4 chapters only) - Godse
Fundamentals of HDL (first 4 chapters only) - GodseFundamentals of HDL (first 4 chapters only) - Godse
Fundamentals of HDL (first 4 chapters only) - Godse
 
Crash course in verilog
Crash course in verilogCrash course in verilog
Crash course in verilog
 
MOSFETs (10EC63) Notes for Electronics & Communication Engineering Students o...
MOSFETs (10EC63) Notes for Electronics & Communication Engineering Students o...MOSFETs (10EC63) Notes for Electronics & Communication Engineering Students o...
MOSFETs (10EC63) Notes for Electronics & Communication Engineering Students o...
 
Microelectronic Circuits Notes (10EC63) by Dr. M. C. Hanumantharaju of BMS In...
Microelectronic Circuits Notes (10EC63) by Dr. M. C. Hanumantharaju of BMS In...Microelectronic Circuits Notes (10EC63) by Dr. M. C. Hanumantharaju of BMS In...
Microelectronic Circuits Notes (10EC63) by Dr. M. C. Hanumantharaju of BMS In...
 
Microelectronic Circuits (10EC63) Notes for Visvesvaraya Technological Univer...
Microelectronic Circuits (10EC63) Notes for Visvesvaraya Technological Univer...Microelectronic Circuits (10EC63) Notes for Visvesvaraya Technological Univer...
Microelectronic Circuits (10EC63) Notes for Visvesvaraya Technological Univer...
 
Verilog tutorial
Verilog tutorialVerilog tutorial
Verilog tutorial
 
Embedded System Design Notes written by Arun Kumar G, Associate Professor, De...
Embedded System Design Notes written by Arun Kumar G, Associate Professor, De...Embedded System Design Notes written by Arun Kumar G, Associate Professor, De...
Embedded System Design Notes written by Arun Kumar G, Associate Professor, De...
 

Similar to Notes: Verilog Part 5 - Tasks and Functions

Unit 3 principles of programming language
Unit 3 principles of programming languageUnit 3 principles of programming language
Unit 3 principles of programming languageVasavi College of Engg
 
Function & procedure
Function & procedureFunction & procedure
Function & procedure
atishupadhyay
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
AMAN ANAND
 
FUNCTION CPU
FUNCTION CPUFUNCTION CPU
FUNCTION CPU
Krushal Kakadia
 
systemverilog-interview-questions.docx
systemverilog-interview-questions.docxsystemverilog-interview-questions.docx
systemverilog-interview-questions.docx
ssuser1c8ca21
 
04. WORKING WITH FUNCTIONS-2 (1).pptx
04. WORKING WITH FUNCTIONS-2 (1).pptx04. WORKING WITH FUNCTIONS-2 (1).pptx
04. WORKING WITH FUNCTIONS-2 (1).pptx
Manas40552
 
System verilog control flow
System verilog control flowSystem verilog control flow
System verilog control flow
Pushpa Yakkala
 
Software Engineering - Module 3: Lesson7
Software Engineering - Module 3: Lesson7Software Engineering - Module 3: Lesson7
Software Engineering - Module 3: Lesson7
ArraLafuente
 
Functions
FunctionsFunctions
Functions
Septi Ratnasari
 
Function in C++
Function in C++Function in C++
Function in C++
Prof Ansari
 
Java script function
Java script functionJava script function
Java script function
suresh raj sharma
 
Model Driven Testing: requirements, models & test
Model Driven Testing: requirements, models & test Model Driven Testing: requirements, models & test
Model Driven Testing: requirements, models & test
Gregory Solovey
 
Azure Function Workflow
Azure Function WorkflowAzure Function Workflow
Azure Function Workflow
Andrea Tosato
 
PSPC-UNIT-4.pdf
PSPC-UNIT-4.pdfPSPC-UNIT-4.pdf
PSPC-UNIT-4.pdf
ArshiniGubbala3
 
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
 FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM) FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
Mansi Tyagi
 
Python_UNIT-I.pptx
Python_UNIT-I.pptxPython_UNIT-I.pptx
Python_UNIT-I.pptx
mustafatahertotanawa1
 
358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2
sumitbardhan
 
C Programming - Refresher - Part II
C Programming - Refresher - Part II C Programming - Refresher - Part II
C Programming - Refresher - Part II
Emertxe Information Technologies Pvt Ltd
 
Function
FunctionFunction
Function
MuhammadBakri13
 

Similar to Notes: Verilog Part 5 - Tasks and Functions (20)

Fpga 13-task-and-functions
Fpga 13-task-and-functionsFpga 13-task-and-functions
Fpga 13-task-and-functions
 
Unit 3 principles of programming language
Unit 3 principles of programming languageUnit 3 principles of programming language
Unit 3 principles of programming language
 
Function & procedure
Function & procedureFunction & procedure
Function & procedure
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
FUNCTION CPU
FUNCTION CPUFUNCTION CPU
FUNCTION CPU
 
systemverilog-interview-questions.docx
systemverilog-interview-questions.docxsystemverilog-interview-questions.docx
systemverilog-interview-questions.docx
 
04. WORKING WITH FUNCTIONS-2 (1).pptx
04. WORKING WITH FUNCTIONS-2 (1).pptx04. WORKING WITH FUNCTIONS-2 (1).pptx
04. WORKING WITH FUNCTIONS-2 (1).pptx
 
System verilog control flow
System verilog control flowSystem verilog control flow
System verilog control flow
 
Software Engineering - Module 3: Lesson7
Software Engineering - Module 3: Lesson7Software Engineering - Module 3: Lesson7
Software Engineering - Module 3: Lesson7
 
Functions
FunctionsFunctions
Functions
 
Function in C++
Function in C++Function in C++
Function in C++
 
Java script function
Java script functionJava script function
Java script function
 
Model Driven Testing: requirements, models & test
Model Driven Testing: requirements, models & test Model Driven Testing: requirements, models & test
Model Driven Testing: requirements, models & test
 
Azure Function Workflow
Azure Function WorkflowAzure Function Workflow
Azure Function Workflow
 
PSPC-UNIT-4.pdf
PSPC-UNIT-4.pdfPSPC-UNIT-4.pdf
PSPC-UNIT-4.pdf
 
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
 FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM) FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
 
Python_UNIT-I.pptx
Python_UNIT-I.pptxPython_UNIT-I.pptx
Python_UNIT-I.pptx
 
358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2358 33 powerpoint-slides_2-functions_chapter-2
358 33 powerpoint-slides_2-functions_chapter-2
 
C Programming - Refresher - Part II
C Programming - Refresher - Part II C Programming - Refresher - Part II
C Programming - Refresher - Part II
 
Function
FunctionFunction
Function
 

Recently uploaded

Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 

Recently uploaded (20)

Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 

Notes: Verilog Part 5 - Tasks and Functions

  • 1. 1|Page Notes: Verilog Part 5 8 CHAPTER 8: 8.1 DIFFERENCE BETWEEN FUNCTION AND TASKS Functions A function can enable another function but not another task. Function always executes in 0 simulation time. Functions must not contain any delay, event or timing control statements. Functions must have at least one input argument. They can have more than one arguments. Functions always return a single value. They cannot have output or inout arguments. Tasks A task can enable another task as well as a function. Tasks may execute in non-zero simulation time. Tasks may contain any delay, event or timing control statements. Tasks may have zero arguments of type input, output or inout. Tasks do not return with a value, but can pass multiple values through output and inout arguments.  Both Tasks and functions must be defined in a module and are local to the module.  Tasks are useful for common Verilog problems that contain any event, delay, timing or multiple argument constructs.  Functions are used in purely combinational circuits that are to be executed in zero simulation time.  Tasks or Functions cannot have wires. They contain behavioural statements only.  They do not contain initial or always blocks but can be called from always, initial or other tasks and functions. 8.2 TASKS  They are used with the keywords task and endtask. They are used if any one of the following condition is true for the procedure.  There are delay, timing or event control constructs in the procedure.  The procedure has zero or more than one output arguments.  The procedure has no input arguments.  Task declaration and task invocation syntax is given as Syntax.  Examples  TASK: Bitwise Oper Module Operator  Assymetric Sequence Generator  Automatic Tasks:  Tasks are normally static in nature. Hence when task is called concurrently at two places in a code, there are chances that the task calls will operate on the same task variables.  This results in incorrect results.  Hence we use automatic task. Here both the task calls are given dynamic variables upon invocation. Notes: Verilog Part 5 Prepared By: Jay Baxi
  • 2. 2|Page   Thus because of these independent copies of variables correct results are obtained. For example: Automatic (Re-entrant) Tasks. 8.3 FUNCTIONS  Functions are declared within keywords function and endfunction.  They are used when all of the following condition are true for 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.  There are no output or inout arguments.  There are no nonblocking assignments. 8.3.1 Function Declaration and Invocation  The syntax for the function declaration and invocation are as Function Declaration and Invocation.  When a function is declared a register name function_identifier is implicitly formed.  The output is passed by setting the value of register function_identifier.  The function is invoked by specifying the name and argument. The return value is placed where the function was invoked.  Range_or_type specifies the width of the internal register. If it is not defined, the default bit width is 1. 8.3.2 Function Examples  Parity Calculation  Left/Right Shifter 8.3.3 Recursive Functions     8.3.4 If a function is concurrently called from two different locations, the result is non deterministic, because both calls operate on same variables. Verilog provides automatic to declare a recursive function where all function declarations are dynamically allocated for each call. They cannot be accessed by hierarchical references, however, they can be invoked. An example of Recursive Function: Factorial Constant and Signed Functions  A constant function is a normal Verilog function with certain restrictions.  It can be used to reference complex values and can be used instead of constants.  Signed Functions allow signed operations to be performed on the function return values. It uses the keyword signed. Notes: Verilog Part 5 Prepared By: Jay Baxi