Illegal assignment in cast to class for uvm_componenets

Hi,
I am trying to assign one uvm_component to other uvm_component through casting got the below warning.

Warning: (vsim-12051) /rfs/proj/cs_csa_lcs2_private/projects/walleye/walleye1/trunk/dv/verif/common/uvc/architecture/RC_base_test.sv(414): Illegal assignment in cast to class

Source code:

virtual function void checkScoreboards();
    uvm_component           comparator_list[$];
    RC_base_comparator      my_comparator_ref;
    string                  my_name;

    find_all_by_type("*_data_comparator*", comparator_list, uvm_top);

    if (comparator_list.size() >= 1)
      begin
        foreach(comparator_list[i]) begin
        	my_comparator_ref = RC_base_comparator'(comparator_list[i]);  ///Warning
        	my_name = my_comparator_ref.get_name();

In the above code, RC_base_comparator is another uvm_component.

Would you please help me to fix this warning.

In reply to Sivajim:

You are doing a simple type cast, but you have to use the System function $cast which performs a cast of the object.

In reply to Sivajim:

You are trying to do a down-cast using as static bit-stream cast operator. Down-casting requires a dynamic $cast function to make sure the object handle you want to assign to the class variable is compatible.

if (!$cast(my_comparator_ref,comparator_list[i])
    `uvm_fatal("BADCAST", "object was not compatible with RC_base_comparator")

Hi,
Thank you All,
It’s working.