1.注册uvm_component类
class comp1 extends uvm_component; //继承
`uvm_component_utils(comp1) //注册
function new(string name = "comp1", uvm_component parent = null) //创建new函数
super.new(name,parent); //继承父类new函数
$display($sformatf("%s is created",name));
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
endfunction
endclass
2.注册uvm_object类
class ob1 extends uvm_object;
`uvm_object_utils(ob1);
function new(string name = "ob1")
super.new(name);
$display($sformatf(%s is created,name));
endfunction
endclass
3.创建-create
comp1 c1 c2;
ob1 o1 o2;
initial begin
c1 = new("c1"); //sv创建
o1 = new("o1"); //sv创建
c2 = comp1::type_id::create("c2",null); //uvm工厂创建
o2 = ob1::type_id::create("o2"); //uvm工厂创建
end
本文档展示了如何在SystemVerilog中注册和使用UVM组件(comp1)和对象(ob1)。通过`uvm_component_utils`和`uvm_object_utils`宏进行注册,然后利用UVM工厂进行实例化,如`comp1::type_id::create`和`ob1::type_id::create`,这使得对象可以根据类型动态创建。
1702

被折叠的 条评论
为什么被折叠?



