EDA Playground lets you type in and run HDL code (using a selection of free and commercial simulators and synthesizers).
It's great for learning HDLs, it's great for testing out unfamiliar things and it's great for sharing code.
You can start typing straight away. But to run your code, you'll need to sign or log in. Logging in with a Google account gives you access to all non-commercial simulators and some commercial simulators:
To run commercial simulators, you need to register and log in with a username and password. Registration is free, and only pre-approved email's will have access to the commercial simulators.
206
//--------------------------------------------------------------------------
// Dynamic Casting
// www.24x7fpga.com
//--------------------------------------------------------------------------
// Parent class
class parent_class;
// class properties or variables
int a, b, s;
// task method
task func ( );
s = a + b;
disp();
endtask
function void disp( );
$display("Parent Class => a = %0d , b = %0d, sum s = %0d", a, b, s);
endfunction
endclass
// Child Class
class child_class extends parent_class;
// class properties or variables
int m;
// task method
task func ( );
m = a * b;
disp();
endtask
function void disp( );
$display("Child Class => a = %0d , b = %0d, mul m = %0d", a, b, m);
endfunction
endclass
module tb_dynamic_cast;
parent_class pr_obj; // declare a handle for parent class
child_class cl_obj; // declare a handle for child class
child_class cl_obj_2; // declare another handle for child class
initial begin
cl_obj = new( ); // construct an object
pr_obj = cl_obj;
$cast(cl_obj_2, pr_obj); // DYNAMIC CASTING
// parent class assigned to child class
pr_obj.a = 20;
cl_obj.b = 15;
$display("------------ Dynamic Casting ------------");
cl_obj_2.func(); // access a method
end
endmodule
xxxxxxxxxx
// Code your design here
Your account is not validated. If you wish to use commercial simulators, you need a validated account.
If you have already registered (or have recently changed your email address), but have not clicked on the link in the email we sent you, please do so. If you cannot find the email, please check your spam/junk folder. Or click here to resend the email.
If you have not already registered for a full account, you can do so by clicking below. You will then need to provide us with some identification information. You may wish to save your code first.
Creating, deleting, and renaming files is not supported during Collaboration. To encourage development of these features for Collaboration, tweet to @EDAPlayground
This playground may have been modified. Please save or copy before starting collaboration.
Your exercise has been submitted.