What is OOP
Terminology
An EXAMPLE Class
Default methods for Classes
Static attivity
Assigment and copying
Inheritance
Polymorphism
Why oop?
1. helps in creating and maintaining large test.pdf:
You can creat complex data types and tie them together
The routines that work with them
2. increases productivity:
You can creat testbenches and system-level models at a more
Abstract level by calling a routine to perform an action rather than toggling bits
You can work with transactions rather than signals transitions
3. allows the testtables to be reused
Oop decouples the testparts from design details make it more rebust and easier
To maintain and reuse
How shoshould the data and code be brought tegother?
Transactions
Oop basics: Terminology
Blueprint for a house ==> class
A compelet house ==> object
House address ===> handle
Turn on/off swithes ====> Methods
Light swithes ====> Properties
OpenGL vs OOP
Block definition module class
Block instance Instance Object
Block name Instance name handle
Data Type Reg & Wire Properties & Variables
Executable code behavioral Blocks Methods: Functions
(Always/initial) and tasks
Tasks/functions
Communication Ports or cross-module mailboxes/semaphores/CILS
Between Blocks task cballs ........
Oop: Your First Class
...
Bustran B; <-declare a handle that points to an object of the type bustran. When a handle is declared it is initialized to null
B = new (); <-call the new function to construct the bustran object.
When you call New You are allocating a new block
Memory to store variable for that object
1. New allocates space for buttran
2. initialize the variable to their default value (0 for 2 state
And X for 4-state variables)
3. Return the address where the object is stored
How gettint a handle on objects?
How deallocating a handle on objects?
Bustran B1, B2; <----- declare a handle
B1 = new (); <----- allocate bustran object
B2 = b1; <------
B1 = new (); <------ allocate another buttran object
B2 = NULL; <------- deallocate the second bustran object
How do I create a variable shared by all objects of a class, but not make it global?
Static variable
1. The static variable is associted with the class definition, not the instantiated object
2. It is often used to store meta-data, such as number of instances construncted
3. It is shared by all objects of that class
Using the ID field can help keep track of transactions as flow through test
Class routines: tasks and functions
Using one class inside another class
Mainly use a handle to an object
Using hierarchical syntax
Done for reuse and controll complexity
Copy: object copy
1. Shallow copy ==> b2 = new () B1 copy only handles, but B1 & B2 points to the same space
2. After deep copy ==== b2 = copy (B1) Copy, B1 & B2 has independent Space
Inheritance
1. Easy to debug
2. Perform code extension on the previous basis, instead of modifying the previous code.
Super. parent_method/Property
Inheritance chain
1. base class can hold extended class handle
2. Extended class cannot hold base handle, this fails because the base object is missing properties (variable)
That only exist in the extended class, such as bad_src in the following example
$ Cast (badtr, TR) ==> must be of the same type as badtr.
Abstract classes and Virtual Methods
1. Virtual class
2. Polymorphism
The OOP term for multiple routines sharing a common name is "polymorphism"
Polymorphism is realized by virtual Method
Always declare routines inside a class as virtual so that they can be redefine
In an extended class. This applies to all tasks and functions, doesn't the new
Function. Which is called when the object is constructed, and there is no way to extend it
Virtual fucntion is implemented during run, and compile is not concerned (meaning bound)
New Implementation in compile
Parameterized classes
It is often useful to define a generic class whose objects can be
Instantiated to have different array sizes or data types
1. The normal maid is used to parameterize the calss
Class Vector # (INT size = 1)
Bit [size-1: 0];
Endclass
2. instance of this class can then be instantiated like modules or interfaces
Vecor # (. SIZE (2) vtwo;
Initializing class properties (new)
How does systemopengl know which new function to call?
It does that by looking at the type of handle (some concepts refer to the object type pointed to by the handle, such as calling method through the handle)
OOP in systemopengl