VSDV
VSDV
integer count;
function new();
count=0;
endfunction
task counter();
$display("count value is %d",count);
endtask
endclass
class child1 extends Parent;
task counter();
count=count+1;
super.counter();
endtask
endclass
class child2 extends Parent;
task counter();
super.counter();
count=count-1;
endtask
endclass
class subchild1 extends child1;
integer offset,i;
function new();
offset=8;
endfunction
task counter();
for(i=0;i<offset;i++)
super.counter();
endtask
endclass
class subchild2 extends child2;
integer offset,i;
function new();
offset=8;
endfunction
task counter();
for(i=0;i<offset;i++)
super.counter();
endtask
endclass
program main;
Parent p;
child1 c1;
child2 c2;
subchild1 sc1;
subchild2 sc2;
initial
begin
p=new;
c1=new;
c2=new;
while(c1.count<15)
c1.counter();
$display("---------------------------");
c2.count=c1.count;
while(c2.count>0)
c2.counter();
$display("---------------------------");
sc1=new;
sc1.counter();
sc2=new;
sc2.count=sc1.count;
sc2.counter();
end
endprogram
endtask
endclass
program main;
Parent p;
child1 c1;
child2 c2;
subchild1 sc1;
subchild2 sc2;
initial
begin
p=new;
c1=new;
c2=new;
while(c1.count<15)
c1.counter();
$display("---------------------------");
while(c2.count1>0)
c2.counter1();
$display("---------------------------");
sc1=new;
sc1.counter();
sc2=new;
sc2.counter1();
end
endprogram