class Parent ;
virtual task disp ();
$display(" This is class Parent ");
endtask
endclass
class Child extends Parent ;
task disp ();
$display(" This is class Child ");
endtask
endclass
program main ;
Parent P;
Child C;
initial
begin
C = new();
$display(" DEBUG: MASTER: step1: doing P = C ");
P=C;
$display(" DEBUG: MASTER: step2: calling P.disp() ");
P.disp();
$display(" DEBUG: MASTER: step3: calling C.disp() ");
C.disp();
$display(" DEBUG: MASTER: step4: doing C=null ");
C=null;
$display(" DEBUG: MASTER: step5: doing $cast(C,P) ");
$display(" $cast(C,P) = %b ",$cast(C,P));
//##C=P; //##static cast is not working !!!???
$cast(C,P); //##dynamic cast is working
//##C=P; //##static cast is not working !!!???
$display(" DEBUG: MASTER: step6: calling C.disp() ");
C.disp();
end
endprogram
//## DEBUG: MASTER: run results
/*
ncsim> run
DEBUG: MASTER: step1: doing P = C
DEBUG: MASTER: step2: calling P.disp()
This is class Child
DEBUG: MASTER: step3: calling C.disp()
This is class Child
DEBUG: MASTER: step4: doing C=null
DEBUG: MASTER: step5: doing $cast(C,P)
$cast(C,P) = 00000000000000000000000000000001
DEBUG: MASTER: step6: calling C.disp()
This is class Child
Simulation complete via implicit call to $finish(1) at time 0 FS + 1
./conc_cast_updown_null_static_dynamic.sv:13 program main ;
ncsim> exit
*/
virtual task disp ();
$display(" This is class Parent ");
endtask
endclass
class Child extends Parent ;
task disp ();
$display(" This is class Child ");
endtask
endclass
program main ;
Parent P;
Child C;
initial
begin
C = new();
$display(" DEBUG: MASTER: step1: doing P = C ");
P=C;
$display(" DEBUG: MASTER: step2: calling P.disp() ");
P.disp();
$display(" DEBUG: MASTER: step3: calling C.disp() ");
C.disp();
$display(" DEBUG: MASTER: step4: doing C=null ");
C=null;
$display(" DEBUG: MASTER: step5: doing $cast(C,P) ");
$display(" $cast(C,P) = %b ",$cast(C,P));
//##C=P; //##static cast is not working !!!???
$cast(C,P); //##dynamic cast is working
//##C=P; //##static cast is not working !!!???
$display(" DEBUG: MASTER: step6: calling C.disp() ");
C.disp();
end
endprogram
//## DEBUG: MASTER: run results
/*
ncsim> run
DEBUG: MASTER: step1: doing P = C
DEBUG: MASTER: step2: calling P.disp()
This is class Child
DEBUG: MASTER: step3: calling C.disp()
This is class Child
DEBUG: MASTER: step4: doing C=null
DEBUG: MASTER: step5: doing $cast(C,P)
$cast(C,P) = 00000000000000000000000000000001
DEBUG: MASTER: step6: calling C.disp()
This is class Child
Simulation complete via implicit call to $finish(1) at time 0 FS + 1
./conc_cast_updown_null_static_dynamic.sv:13 program main ;
ncsim> exit
*/
No comments:
Post a Comment