uvm(universal verification methodology)通用验证方法学
统一验证方法学的内容:
uvm的类库和核心机制
核心uvm组件和层次构建方式
uvm组件间的通信方式
深入uvm测试场景的构成
uvm的寄存器模型应用
验证环境的需求:
组件的创建和访问
环境的结构创建,组件之间的连接和运行
不同阶段的顺序安排
激励的生成,传递和控制
测试的报告机制
uvm类
1.uvm_void,uvm_object(核心基类)
2.工厂类factory注册创建覆盖 uvm_factory:uvm_object_wrapper,uvm_object_registry,uvm_component_registry(底层组件的创建)
3.事务(transaction)和序列(sequence)类继承自uvm_object
uvm_transaction-uvm_sequence_item:uvm_sequence,uvm_sequence_library,uvm_random_sequence,uvm_exhaustive_sequence,uvm_simple_sequence,uvm_reg_sequence
4.结构创建(structure creation)类
uvm_phase, uvm_report_object, uvm_component(组件类)
5.环境组件(environment component)类 继承自uvm_component
uvm_component:uvm_in_order_comparator,uvm_algorithm_comparator,uvm_driver,uvm_monitor,uvm_agent,uvm_env,uvm_test,uvm_reg_predictor, uvm_scoreboard,uvm_random_stimulus,uvm_sequencer_base,uvm_sequencer
6.通信管道(channel)类 fifo,channel
uvm_tlm_fifo_base-uvm_tlm_fifo,uvm_tlm_analysis_fifo,uvm_tlm_req_rsp_channel,uvm_tlm_rtransport_channel
7.信息报告(message report)类
uvm_object:uvm_report_server,uvm_report_handler,uvm_report_message
8.寄存器模型(register model)类reg
uvm_object:uvm_reg_filed,uvm_reg,uvm_mem,uvm_reg_block,uvm_reg_map,uvm_reg_file,uvm_reg_adapter
9.线程同步(thread synchronization)类event,barrier
uvm_object:uvm_event,uvm_event_callback,uvm_barrier,uvm_barrier_callback,uvm_pool,uvm_object_string_pool
10.事务接口(transaction interface)类port组件之间通过端口连接
uvm_void-uvm_port_base:uvm_UNDIR_port,uvm_UNDIR_export,uvm_UNDIR_imp,uvm_BIDIR_port,
uvm_BIDIR_export,uvm_BIDIR_imp
实例或类型替代,在UVM中承做覆盖(override),而被用来替换的对象或者类型,应该满足注册(registration)和多态(polymorphism)的要求
uvm的验证环境分为两部分,一部分构成了环境的层次,通过uvm_component,另一部分构成了环境的属性和数据传输,通过uvm_object完成
uvm_component继承自uvm_object
uvm_component的常见子类:
generator,stimulator,monitor,agent,checker/reference model, environment, test
sv中的非固定资产即那些TLM transaction , 从generator流向stimulator的数据包,这些类在uvm中统一由uvm_object表示
//注册(类似于初始化)和创建
class obj1 extends uvm_object;
`uvm_object_utils(obj1) //注册
function new(string name = "obj1");
super.new(name); //创建
$display($sformatf("%s is created", name));
endfunction:new
endclass
class comp1 extends uvm_component;
`uvm_component_utils(comp1) //注册
function new(string name="comp1". uvm_component parent=null); //构建
super.new(name, parent);
$display($sformatf("%s is created", name));
endfunction:new
function void build_phase(uvm_phase phase);
super.build_phase(phase);
endfunction:build_phase
endclass
comp1 c1,c2;
obj1 o1, o2;
initial begin
c1 = new("c1");
o1 = new("o1");//sv构建方法创建
c2 = comp1::type_id::create("c2", null);//uvm工厂方法创建
o2 = obj1::type_id::create("o2");
end
创建uvm_component对象时
comp_type::type_id::create(string name, uvm_component parent);//多数使用factory方法
创建uvm_object对象时
object_type::type_id::create(string name);
uvm_coreservice_t
该类内置了uvm世界核心的组件和方法,包括
唯一的uvm_factory,该组件用来注册,覆盖和例化
全局的report_server,该组件用来做消息统筹和报告
全局的tr_database,该组件用来记录transaction记录
get_root()方法用来返回当前uvm环境的结构顶层对象
该类独立于uvm环境
注册宏`uvm_{component,object}_utils
宏调用的过程中,实现类型定义
typedef uvm_component_registry #(T, "S") type_id
`uvm_component_utils用来注册组件类uvm_component
`uvm_object_utils用来实现注册核心基类uvm_object
uvm_component和uvm_object在创建时都需要调用create()函数,uvm_component会表示在uvm层次结构中,而uvm_object则不会显示在层次中
uvm_component::new(name, parent)保留两个参数,为了用过“钩子”的做法,一层层由底层勾住上一层,这样能够将整个uvm结构串接起来了
uvm创建对象的方法
create()
create_component()
get()
get_type_name()
set_inst_override()
set_type_override()
工厂机制提供的便利,将原来的类型替换成一个新的类型(不能轻易修改别人的代码)
env-agent(代理)-driver
vip别人提供的ip,不能获取到driver的代码
类型覆盖和实例覆盖
类型覆盖指,uvm层次结构下的所有原有类型都被覆盖类型所替换
set_type_override
orig_type::type_id::set_type_override(new type::get_type())
实例覆盖指,在某些位置中的原有类型都会被覆盖类型所替换
set_inst_override
orig_type::type_id::set_inst_override(new_type::get_type(),"orig_inst_path");
module factory_override;
import uvm_pkg::*
`include "uvm_macros.svh"
class comp1 extends uvm_component;
`uvm_component_utils(comp1)
function new(string name="comp1", uvm_component parent=null);
super.new(name, parent);
$display($sformatf("comp1::%s is created",name));//$sformatf将数据格式化为字符串
endfunction:new
virtual function void hello(string name);
$display($sformatf("comp1:: %s said hello!", name));
endfunction
endclass
class comp2 extends comp1;
`uvm_component_utils(comp2)
function new(string name="comp2", uvm_component parent=null)
super.new(name, parent);
$display($sformatf("comp2::%s is created",name));
endfunction:new
function void hello(string name);
$display($sformatf("comp1:: %s said hello!", name));
endfunction
endclass
comp1 c1, c2;
initial begin
comp1::type_id::set_type_override(comp2::get_type());
c1 = new("c1";)
c2 = comp1::type_id::create("c2", null);
c1.hello("c1");// c1 said hello!
c2.hello("c2"); //c2 said hello!
end
endmodule