2011年6月4日 星期六

UVM Factory Usage in set_type_override_by_type

Cadence example

`include "uvm_pkg.sv"

module uvm_type_override;
// Import the UVM Package and include the UVM macros
import uvm_pkg::*;
`include "uvm_macros.svh"

class state extends uvm_component;
`uvm_component_utils(state)
function new(string name="state", uvm_component parent);
super.new(name, parent);
endfunction : new
function void end_of_elaboration();
this.print();
endfunction : end_of_elaboration
endclass : state

class florida extends state;
`uvm_component_utils(florida)
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction : new
endclass : florida

class new_york extends state;
`uvm_component_utils(new_york)
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction : new
endclass : new_york

state my_state1, my_state2;

initial begin
my_state1 = state::type_id::create("my_state1", null);
`uvm_info("INFO1", {"my_state1.type=", my_state1.get_type_name()}, UVM_LOW);
factory.set_type_override_by_type(state::get_type(), new_york::get_type());
my_state2 = state::type_id::create("my_state2", null);
`uvm_info("INFO2", {"my_state2.type=", my_state2.get_type_name()}, UVM_LOW);
#100 $finish;
end

endmodule : uvm_type_override


simulation result:

UVM_INFO ex4-16_uvm_factory2.sv(41) @ 0: reporter [INFO1] my_state1.type=state
UVM_INFO ex4-16_uvm_factory2.sv(44) @ 0: reporter [INFO2] my_state2.type=new_york

沒有留言: