|
|
|
|
|
|
|
|
|
|
|
|
Adding Members
|
|
|
|
|
|
We add new variables to already defined class, or we can add new methods to already defined class |
|
|
|
|
|
|
|
|
|
|
|
Example : Adding Members
|
|
|
|
|
|
1 program new_memeber;
2 // Define the class
3 class aop;
4 integer i;
5 function void print ();
6 $display ("[1] Value of i %0d",i);
7 endfunction
8 endclass
9 // Add new variable j and method print2 to aop class
10 extends aop_extend (aop);
11 integer j;
12 function void print2 ();
13 $display ("[2] Value of i %0d",i);
14 $display ("[2] Value of j %0d",j);
15 endfunction
16 endextends
17 // Create instance of the aop class
18 aop a_;
19
20 initial begin
21 a_ = new ();
22 a_.i = 10;
23 a_.j = 11;
24 a_.print();
25 a_.print2();
26 end
27
28 endprogram
You could download file new_members.sv here
|
|
|
|
|
|
Simulation : Adding Members
|
|
|
|
|
|
[1] Value of i 10
[2] Value of i 10
[2] Value of j 11
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Copyright © 1998-2014 |
Deepak Kumar Tala - All rights reserved |
Do you have any Comment? mail me at:deepak@asic-world.com
|
|