1)基础用法:
uvm_object macro:
a. 在transaction使用
uvm_object_utils_begin:它用于把一个直接或间接派生自uvm_object的类注册到factory。
uvm_object_param_utils_begin:它用于把一个直接或间接派生自uvm_object的参数化类注册到factory。
b. 在uvm_sequence使用:
uvm_object_utils(sequence 类名)
可能还需要`uvm_declare_p_sequencer(sequencer类名)的声明
uvm_component macro
在uvm_component中使用
uvm_component_utils(类名)
transaction要派生自uvm_sequence_item,sequence要派生自uvm_sequence或者uvm_sequence的派生类。agent要派生自uvm_agent. uvm_agent里多了一个is_active的成员。一般根据这个active来决定是否实例化driver和sequencer. is_active变量的数值需要在env的build_phase里设置完成,可以直接设置,也可以用uvm_config_db#(int)::set。
UVM_PASSIVE:agent以这种形式运行时,只监测总线而不驱动总线;
UVM_ACTIVE:agent以这种形式运行时,既可以监测总线,也可以驱动总线;
pack的使用:
a. 定义一个简单的xaction,将类成员注册到uvm_field_int等宏定义中,在类中定义do_pack函数,继承原来的do_pack。
b.调用pack_bytes
c. 从log中可以看出,调用pack_bytes之后将类成员都打包成byte的形式,默认是按照大端的形式处理的
uvm_object中定义get_bits、get_bytes、get_ints函数用来获取对应位宽的数据。
2)项目升级用法:与上一致;
3)底层原理分析:
首先从type_id分析,它来源于uvm_sequence_item中uvm_object_utils_begin这个宏拓展的代码,那么在begin与end之间做了下图的事情:
第一句(注册):获取我们通过`uvm_object_utils_begin(jelly_bean_transaction)传进来的jelly_bean_transaction这个类,然后声明了一个该类型的uvm_object_registry类,同时把这个uvm_object_registry起个别名叫type_id。声明了两个函数,最终效果是调用了type_id,也就是uvm_object_registry这个类型中的get函数。
第二句:等效于new;
第三句:返回类型名。
uvm_field结构:
常用函数需要注意pack unpack pack_bytes unpack_bytes pack_ints unpack_ints 返回值都是bit个数。
UVM_ALL_ON:‘b000000101010101
UVM_ALL_ON|UVM_NO_PACK:这样就会忽略掉pack bit
对于uvm_component派生类来说,field_automation机制最重要的是可以在build_phase中自动获取uvm_config_db#()::set()的数值(必须加super.build_phase(phase))---- 也就是不用写 uvm_config_db#()::get()
然后分析uvm树:
uvm_void是一个空的虚类。在src/base/uvm_misc.svh中定义。
层次结构函数:
get_parent() get_child(string name) 这两个分别获取parent指针和指定名字的child指针。
get_children(ref uvm_component children[$]) 获取所有的child指针
get_num_children() 获取child个数
get_first_child(ref string name) get_next_child(ref string name) 获取child的名字(反映到string name上),返回值是0/1两种情况。
uvm打印信息控制:
get_report_verbosity_level()
set_report_verbosity_level(UVM_HIGH) 只对当前调用的component起作用
set_report_verbosity_level_hier(UVM_HIGH) 对当前及下面所有的component起作用(项目中使用);
simv +UVM_VERBOSITY=UVM_HIGH 命令行方式 ------ 我觉得用这个就可以了。