I’m trying to understand dynamic cast with a simple example.
Your text to link here…
As you can see that Pkt_h.Error = 0; // compiler error
So To prevent the compiler error, then I declared the “$cast” but I’ve got still have error.
class parent_class;
bit [31:0] addr;
function display();
$display("Addr = %0d",addr);
endfunction
endclass
class child_class extends parent_class;
bit [31:0] data;
function display();
super.display();
$display("Data = %0d",data);
endfunction
endclass
module inheritence;
initial begin
parent_class p;
child_class c;
c= new;
c.data = 1;
c.addr = 2;
c.display();
$cast(p,c);
p.data = 3;
p.addr = 4;
p.display();
end
endmodule
“data is not a class item”
Would you please let me know how to resolve this problem?