Jump to content

problem about using type_id::create()


Recommended Posts

Hi, experts,

I met one problem when i use type_id::create() to create one instance of a component object.

Here are my codes:

 

typedef class tmp_for_test;

 

class config_agent extends uvm_agent;
  typedef config_agent this_type;
 
    tmp_for_test #(int, byte) tmp_f_t;
 
  // Provide implmentations of virtual methods such as get_type_name and create
  `uvm_component_utils_begin(config_agent)
    `uvm_field_object(tmp_f_t, UVM_DEFAULT);
  `uvm_component_utils_end
 
  // new
  function new (string name, uvm_component parent);
    super.new(name, parent);
  endfunction : new
 
  // build_phase
  function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    ...
    tmp_f_t = tmp_for_test#(int, byte)::type_id::create("tmp_f_t", this);
    ...
  endfunction: build_phase
  ...
endclass: config_agent
 
class tmp_for_test #(type T1=int, type T2=T1) extends uvm_component;
  T1 width;
  T2 depth;
  // Provide implmentations of virtual methods such as get_type_name and create
  `uvm_component_utils(tmp_for_test)
    
  function new (string name, uvm_component parent);
    super.new(name, parent);
    ...
  endfunction
      
  function void build_phase(uvm_phase phase);
    super.build_phase(phase);
  endfunction: build_phase
  ...
endclass : tmp_for_test
 

The VCS reports such an error:

 

Error-[sV-ICA] Illegal class assignment
../sv_for_tmptest/02_master/config/config_agent.sv, 254
"this.tmp_f_t = uvm_pkg_uvm_component_registry_541795153::create("tmp_f_t", this, "\000");"
  Expression 'uvm_pkg_uvm_component_registry_541795153::create("tmp_f_t", 
  this, "\000")' on rhs is not a class or a compatible class and hence cannot  
  be assigned to a class handle on lhs. 
  Please make sure that the lhs and rhs expressions are compatible.
 
But it's okay when i use config_driver which extends uvm_driver replacing the class tmp_for test. Does anybody meet the same problem or know the reason?
 
Thanks in advance
Link to comment
Share on other sites

Hi, all

I have found the reason of this problem. It's that the type of the second paramter(byte type) of class tmp_for_test isn't identify with the defaut type, which is int type. If change the type of the second paramter from byte to int, the error disappears. But I have another question: If I want to use different type of the paramter of class tmp_for_test and instantiate it via the way of using type_id::create("tmp_f_t", this), how can i do?

 

regards

mrforever

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...