Dear All,
I’m trying to understand about factory with the below code.
// Code your design here
`include "interface.sv"
`include "sequence_item.sv"
`include "sequencer.sv"
`include "sequence.sv"
`include "driver.sv"
`include "monitor.sv"
`include "agent.sv"
`include "environment.sv"
`include "test.sv"
class state extends uvm_component;
`uvm_component_utils(state)
function new(string name, uvm_component parent);
super.new(name,parent);
endfunction
endclass
class florida extends state;
`uvm_component_utils(florida)
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
endclass
class new_york extends state;
`uvm_component_utils(new_york)
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
endclass
module top;
import uvm_pkg::*;
bit aclk;
bit areset_n;
//test_1 t1;
interface_1 intf_1(aclk ,areseet_n);
initial begin
//t1 = new("T1",null);
aclk = 0;
areset_n = 1;
run_test("test_1");
end
state my_state1, my_state2;
initial begin
uvm_config_db#(virtual interface_1)::set(uvm_root::get(),"uvm_test_top.env.a1","intf_1",intf_1);
end
always #1 aclk = ~aclk;
initial begin
factory.set_type_override_by_type(state::get_type(), florida::get_type());
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)
end
endmodule
In especially, I want to know how to setup and use the factory concept. So I make the below code.
initial begin
factory.set_type_override_by_type(state::get_type(), florida::get_type());
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)
end
Do I understand correctly the usage of factory ? Is it implementing correctly the usage of factory?
Basically, as i know, the factory is based on override and polymorphism.
function void set_type_override_by_type (uvm_object_wrapper original_type,
uvm_object_wrapper override_type,
bit replace = 1)
If I understand correctly the usage of factory, then why does “set_type_override_by_type” function need the parameter of original_type and override_type ? I mean that does original_type override to override_type or override_type override to original_type ?
and What does