Sunday, September 18, 2016

INTRODUCTION TO OBJECT ORIENTED PROGRAMMING


Hi Friends,

Yet another post on oop's. Hope it helps you'll.

The OOP programming model programs are organised around "objects" and "data". Objects represent some things and like any other objects in the real Objects, in programming language have certain behaviour, properties, type, and identity. In OOP based language the principal aim is to find out the objects to manipulate and their relation between each other. OOP in systemverilog  offers greater flexibility and compatibility then procedural language like verilog. 

Understanding of "Objects" are key to object-oriented technology. Look around right now and you'll find many examples of real-world objects: your PC, your table, your chair.

Real-world objects share two characteristics: They all have state and behaviour. System have state (name, colour) and behaviour (playing music,switch on & off). Identifying the state and behaviour for real-world objects is a great way to begin thinking in terms of object-oriented programming. 

SystemVerilog is a object oriented programming  and to understand the functionality of OOP in SystemVerilog, we first need to understand several fundamentals related to objects. These include class, method, inheritance, encapsulation, abstraction, polymorphism etc.

Class 

 It is the building point of OOP and that contains data and codes with . In SystemVerilog OOPS , everything happens within class and it describes a set of objects with common behaviour. The class definition describes all the properties, behaviour, and identity of objects present within that class.    

Example:

Class example;
----------
----------
endclass

Object 

 Objects are the actual unit of object orientation concept with behaviour, identity. An object is expressed by the variable and methods within the objects. Again these variables and methods are distinguished from each other as instant variables, instant methods and class variable and class methods. 

Example:

Example ex_h;
ex_h = new();//Creates object of type Example and assigned object handle to variable "ex_h".


Methods 

 We know that a class can define both attributes "Variables" and behaviours "Methods". Again attributes are defined by variables and behaviours are represented by methods. In other words, methods define the abilities of an object. 


Inheritance 

 This is the mechanism of organising and structuring program. Though objects are distinguished from each other by some additional features but there are objects that share certain things common. In object oriented programming classes can inherit some common behaviour and state from others. Inheritance in OOP allows to define a general class and later to organise some other classes simply adding some details with the old class definition. This saves work as the special class inherits all the properties of the old general class and as a programmer you only require the new features. This helps in a better data analysis, accurate coding and reduces development time. In Verilog , to write a new definition using the existing definition is done inserting `ifdef compilation controls into the existing code.  


Abstraction 

 The process of abstraction in SystemVerilog is used to hide certain details and only show the essential features of the object. In other words, it deals with the outside view of an object. 


Encapsulation 

 This is an important programming concept that assists in separating an object's state from its behaviour. This helps in hiding an object's data describing its state from any further modification by external component. In SystemVerilog there are three different terms used for hiding data constructs and these are public, private and protected . As we know an object can associated with data with predefined classes and in any application an object can know about the data it needs to know about. So any unnecessary data are not required by an object can be hidden by this process. It can also be termed as information hiding that prohibits outsiders in seeing the inside of an object in which abstraction is implemented.  


Polymorphism 

 It describes the ability of the object in belonging to different types with specific behaviour of each type. So by using this, one object can be treated like another and in this way it can create and define multiple level of interface. Here the programmers need not have to know the exact type of object in advance and this is being implemented at run time. 

We will discuss above three concepts in details in up-coming posts.

Thank You,
Moderator

1 comment:

  1. Thanks a lot for sharing. Private Tutor in Parkland Will check back later for more of your articles.

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...