SlideShare a Scribd company logo
1 of 20
Download to read offline
Object Oriented Programming
Procedural Approach
Focus is on procedures
All data is shared: no protection
More difficult to modify
Hard to manage complexity
Introduction to OOP
Object-oriented programming is a method of implementation
in which programs are organized as cooperative collections of
objects, each of which represents an instance of some class,
and whose classes are all members of one or more hierarchy
of classes united via inheritance relationships
Basic OOP
OOPs breaks a testbench into blocks that work together to
accomplish the verification goal
Why OOP?
• Highly abstract system level modelling
• Classes are intended for verification
• Classes are easily reused and extended
• Data security
• Classes are dynamic in nature
• Easy debugging, one class at a time
• Redundant code can be avoided by using inheritance
• Inheritance reduces time and cost
• Easy upgrading of system is possible using object oriented system
OOP cont..
 A class is a user-defined data type.
 Classes consist of data (called properties) and tasks and
functions to access the data (called methods).
 Classes are used in object-oriented programming.
 In SystemVerilog, classes support the following aspects of
object-orientation – encapsulation, data hiding, inheritance
and polymorphism
Class
Class Declaration
class register;
local bit[31:0] contents;
function void write(bit[31:0] d)
contents = d;
endfunction
function bit[31:0] read();
return contents;
endfunction
endclass
 Organized into groups with similar characteristics
• They are said to be related by a common characteristic
 Object-Oriented programming seeks to provide mechanisms
for modelling these relationships
Objects
 The world conceptually consists of objects
 Many objects can be said to be of the same type or class
•My bank account, your bank account, Bill Gates’ bank
account …
 We call the object type a class
 Instantiation
•An Object is instantiated from a Class
BankAccount myAccount; //creating a handle for
//the class BankAccount
myAccount = new ();//creating object
Objects as instances of Classes
 It is a pointer to an object.
 An oop handle is like the address of the object but is stored in a
pointer that only refer to one type.
Ex:
class Transaction;
logic addr,data;
endclass
initial begin
Transaction tr;
tr=new();
end
Variables..
Class Transaction
Variables
Memory
Handle
tr
What is Handle?
Class Example:
class register;
local bit[31:0] contents;
function void write(bit[31:0] d)
contents = d;
endfunction
function bit[31:0] read();
return contents;
endfunction
endclass
module top;
register r;
bit[31:0] d;
initial begin
r = new();
r.write(32’h00ff72a8);
d = r.read();
end
endmodule
 A class encapsulation is a process of hiding all internal details
of an object from out side world.
 Encapsulation is the ability to hide data and methods from out
side world and only expose data and methods that are required.
DATA
ENCAPSULATION
Class Encapsulation
 Advantage of encapsulation
• Protection
• Consistency
• Allows change
Encapsulation example:
class base;
local int i;
endclass
program main;
initial
begin
base b = new();
b.i = 123;
end
endprogram
Local variable error
Result:
 Polymorphism refers to the ability to assume different
forms. In OOP, it indicates a language’s ability to handle
objects differently based on their runtime type.
 When objects communicate with one another, we say that
they send and receive messages.
 The sending object only needs to be aware that the
receiving object can perform a particular behaviour.
Polymorphism
class A ;
virtual task disp ();
$display(" This is class A ");
endtask
endclass
class EA extends A ;
task disp ();
$display(" This is Extended class A ");
endtask
endclass
program main ;
EA my_ea;
A my_a;
initial
begin
my_a = new();
my_a.disp();
my_ea = new();
my_a = my_ea;
my_a.disp();
end
endprogram
RESULTS
This is class A
This is Extended class A
Example:
 Definition (Inheritance) Inheritance is the mechanism
which allows a class B to inherit properties of a class A.
 We say “ B inherits from A”.
 Objects of class B thus have access to attributes and
methods of class A without the need to redefine them.
 The following definition defines two terms with which we
are able to refer to participating classes when they use
inheritance.
INHERITANCE
 The idea of inheritance is simple but powerful:
 When you want to create a new class and there is already a class
that includes some of the code that you want, you can derive your
new class from the existing class.
 In doing this, you can reuse the fields and methods of the existing
class without having to write (and debug!) them yourself.
INHERITANCE (Cont...)
Example:
class parent;
task printf();
$display(" THIS IS PARENT CLASS ");
endtask
endclass
class subclass extends parent;
task printf();
$display(" THIS IS SUBCLASS ");
endtask
endclass
program main;
initial
begin
parent p;
subclass s;
p = new();
s = new();
p.printf();
s.printf();
end
endprogram
RESULTS
THIS IS PARENT CLASS A
THIS IS SUBCLASS
Why
SystemVerilog?
Why Not C++?
Why not C++?
C++ System Verilog
 Superset of Verilog
 RTL/Verification language
 Assertion language
 Constraint language
 Code coverage language
 No relation to
verilog
 Interface is required
to interact with Verilog
Comparison

More Related Content

Similar to System_Verilog_OOPS_Concepts.pdf

Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering CollegeObject Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering CollegeDhivyaa C.R
 
Abap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorialsAbap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorialscesarmendez78
 
JAVA-PPT'S.pptx
JAVA-PPT'S.pptxJAVA-PPT'S.pptx
JAVA-PPT'S.pptxRaazIndia
 
JAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptxJAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptxKunalYadav65140
 
Class 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented ProgrammingClass 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented ProgrammingAhmed Swilam
 
Application package
Application packageApplication package
Application packageJAYAARC
 
oop lecture 3
oop lecture 3oop lecture 3
oop lecture 3Atif Khan
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingMH Abid
 
C Sharp: Basic to Intermediate Part 01
C Sharp: Basic to Intermediate Part 01C Sharp: Basic to Intermediate Part 01
C Sharp: Basic to Intermediate Part 01Zafor Iqbal
 
Presentation 3rd
Presentation 3rdPresentation 3rd
Presentation 3rdConnex
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .NetGreg Sohl
 

Similar to System_Verilog_OOPS_Concepts.pdf (20)

Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering CollegeObject Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
Object Oriented PHP by Dr.C.R.Dhivyaa Kongu Engineering College
 
Abap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorialsAbap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorials
 
JAVA-PPT'S.pptx
JAVA-PPT'S.pptxJAVA-PPT'S.pptx
JAVA-PPT'S.pptx
 
JAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptxJAVA-PPT'S-complete-chrome.pptx
JAVA-PPT'S-complete-chrome.pptx
 
Class 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented ProgrammingClass 7 - PHP Object Oriented Programming
Class 7 - PHP Object Oriented Programming
 
java part 1 computer science.pptx
java part 1 computer science.pptxjava part 1 computer science.pptx
java part 1 computer science.pptx
 
Application package
Application packageApplication package
Application package
 
Oops
OopsOops
Oops
 
Ppt of c++ vs c#
Ppt of c++ vs c#Ppt of c++ vs c#
Ppt of c++ vs c#
 
oop lecture 3
oop lecture 3oop lecture 3
oop lecture 3
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
oopusingc.pptx
oopusingc.pptxoopusingc.pptx
oopusingc.pptx
 
C Sharp: Basic to Intermediate Part 01
C Sharp: Basic to Intermediate Part 01C Sharp: Basic to Intermediate Part 01
C Sharp: Basic to Intermediate Part 01
 
Oops ppt
Oops pptOops ppt
Oops ppt
 
PCSTt11 overview of java
PCSTt11 overview of javaPCSTt11 overview of java
PCSTt11 overview of java
 
python.pptx
python.pptxpython.pptx
python.pptx
 
My c++
My c++My c++
My c++
 
Presentation 3rd
Presentation 3rdPresentation 3rd
Presentation 3rd
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .Net
 
Php oop (1)
Php oop (1)Php oop (1)
Php oop (1)
 

Recently uploaded

Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfstareducators107
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningMarc Dusseiller Dusjagr
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Celine George
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111GangaMaiya1
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsNbelano25
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfNirmal Dwivedi
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 

Recently uploaded (20)

Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Our Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdfOur Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdf
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 

System_Verilog_OOPS_Concepts.pdf

  • 2. Procedural Approach Focus is on procedures All data is shared: no protection More difficult to modify Hard to manage complexity
  • 3. Introduction to OOP Object-oriented programming is a method of implementation in which programs are organized as cooperative collections of objects, each of which represents an instance of some class, and whose classes are all members of one or more hierarchy of classes united via inheritance relationships
  • 4. Basic OOP OOPs breaks a testbench into blocks that work together to accomplish the verification goal
  • 5. Why OOP? • Highly abstract system level modelling • Classes are intended for verification • Classes are easily reused and extended • Data security • Classes are dynamic in nature • Easy debugging, one class at a time • Redundant code can be avoided by using inheritance • Inheritance reduces time and cost • Easy upgrading of system is possible using object oriented system OOP cont..
  • 6.  A class is a user-defined data type.  Classes consist of data (called properties) and tasks and functions to access the data (called methods).  Classes are used in object-oriented programming.  In SystemVerilog, classes support the following aspects of object-orientation – encapsulation, data hiding, inheritance and polymorphism Class
  • 7. Class Declaration class register; local bit[31:0] contents; function void write(bit[31:0] d) contents = d; endfunction function bit[31:0] read(); return contents; endfunction endclass
  • 8.  Organized into groups with similar characteristics • They are said to be related by a common characteristic  Object-Oriented programming seeks to provide mechanisms for modelling these relationships Objects
  • 9.  The world conceptually consists of objects  Many objects can be said to be of the same type or class •My bank account, your bank account, Bill Gates’ bank account …  We call the object type a class  Instantiation •An Object is instantiated from a Class BankAccount myAccount; //creating a handle for //the class BankAccount myAccount = new ();//creating object Objects as instances of Classes
  • 10.  It is a pointer to an object.  An oop handle is like the address of the object but is stored in a pointer that only refer to one type. Ex: class Transaction; logic addr,data; endclass initial begin Transaction tr; tr=new(); end Variables.. Class Transaction Variables Memory Handle tr What is Handle?
  • 11. Class Example: class register; local bit[31:0] contents; function void write(bit[31:0] d) contents = d; endfunction function bit[31:0] read(); return contents; endfunction endclass module top; register r; bit[31:0] d; initial begin r = new(); r.write(32’h00ff72a8); d = r.read(); end endmodule
  • 12.  A class encapsulation is a process of hiding all internal details of an object from out side world.  Encapsulation is the ability to hide data and methods from out side world and only expose data and methods that are required. DATA ENCAPSULATION Class Encapsulation  Advantage of encapsulation • Protection • Consistency • Allows change
  • 13. Encapsulation example: class base; local int i; endclass program main; initial begin base b = new(); b.i = 123; end endprogram Local variable error Result:
  • 14.  Polymorphism refers to the ability to assume different forms. In OOP, it indicates a language’s ability to handle objects differently based on their runtime type.  When objects communicate with one another, we say that they send and receive messages.  The sending object only needs to be aware that the receiving object can perform a particular behaviour. Polymorphism
  • 15. class A ; virtual task disp (); $display(" This is class A "); endtask endclass class EA extends A ; task disp (); $display(" This is Extended class A "); endtask endclass program main ; EA my_ea; A my_a; initial begin my_a = new(); my_a.disp(); my_ea = new(); my_a = my_ea; my_a.disp(); end endprogram RESULTS This is class A This is Extended class A Example:
  • 16.  Definition (Inheritance) Inheritance is the mechanism which allows a class B to inherit properties of a class A.  We say “ B inherits from A”.  Objects of class B thus have access to attributes and methods of class A without the need to redefine them.  The following definition defines two terms with which we are able to refer to participating classes when they use inheritance. INHERITANCE
  • 17.  The idea of inheritance is simple but powerful:  When you want to create a new class and there is already a class that includes some of the code that you want, you can derive your new class from the existing class.  In doing this, you can reuse the fields and methods of the existing class without having to write (and debug!) them yourself. INHERITANCE (Cont...)
  • 18. Example: class parent; task printf(); $display(" THIS IS PARENT CLASS "); endtask endclass class subclass extends parent; task printf(); $display(" THIS IS SUBCLASS "); endtask endclass program main; initial begin parent p; subclass s; p = new(); s = new(); p.printf(); s.printf(); end endprogram RESULTS THIS IS PARENT CLASS A THIS IS SUBCLASS
  • 20. C++ System Verilog  Superset of Verilog  RTL/Verification language  Assertion language  Constraint language  Code coverage language  No relation to verilog  Interface is required to interact with Verilog Comparison