3.2 UVM的树形结构
uvm_component的new/create要注意第一个参数是名字,第二个参数是parent指针。 UVM真正的树根是“uvm_top”. 根据上面这个树结构,可以看出一个个component的parent是什么。uvm_top的parent是null。 当一个component在实例化的时候,如果parent参数设成null,那么parent参数会被仿真器自动设置成uvm_root的实例uvm_top. 在6.6.1章节里也提到了,sequence在uvm_config_db#()::get()的时候,第一个参数设成“null”,实际就是uvm_root::get() 3.5.1章节也提到了这个
层次结构函数:
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两种情况
应用参考代码如下(改动的2.5.2例子中的my_agent.sv):
注意:上述代码是在connet_phase中实现的。 上述代码的打印结果如下:
my_agent's name is uvm_test_top.env.i_agt, parent's full path is uvm_test_top.env, children num is 3
uvm_test_top.env.i_agt 0 child: drv --> full path:uvm_test_top.env.i_agt.drv uvm_test_top.env.i_agt 1 child: mon --> full path:uvm_test_top.env.i_agt.mon uvm_test_top.env.i_agt 2 child: sqr --> full path:uvm_test_top.env.i_agt.sqr This should be i_agt. my_agent's name is uvm_test_top.env.i_agt uvm_test_top.env.i_agt first child name is drv uvm_test_top.env.i_agt next child name is mon uvm_test_top.env.i_agt next child name is sqr
my_agent's name is uvm_test_top.env.o_agt, parent's full path is uvm_test_top.env, children num is 1
uvm_test_top.env.o_agt 0 child: mon --> full path:uvm_test_top.env.o_agt.mon UVM_WARNING /tools/synopsys/vcs/G-2012.09/etc/uvm/src/base/uvm_component.svh(1846) @ 0: uvm_test_top.env.o_agt [NOCHILD] Component with name 'drv' is not a child of component 'uvm_test_top.env.o_agt'
This should be o_agt. my_agent's name is uvm_test_top.env.o_agt uvm_test_top.env.o_agt first child name is mon
3.3 field automation 机制
注意数组类型的field macro比一般的要少real和event的macro. 一般的对于enum类型有3个参数,而数组的只有2个参数。 联合数组的macro比较多
常用函数需要注意 pack unpack pack_bytes unpack_bytes pack_ints unpack_ints 返回值都是bit个数。
field-automation标记位
17bit中 bit0?copy bit1?no_copy bit2?compare bit3?no_compare bit4?print bit5?no_print bit6?record bit7?no_record bit8?pack bit9?no_pack UVM_ALL_ON是 ‘b000000101010101
UVM_ALL_ON|UVM_NO_PACK 这样就会忽略掉pack bit
field-automation的macro可以和if结合起来,参考3.3.4的代码 `uvm_object_utils_begin(my_transaction) `uvm_field_int(dmac, UVM_ALL_ON) `uvm_field_int(smac, UVM_ALL_ON) if(is_vlan)begin `uvm_field_int(vlan_info1, UVM_ALL_ON) `uvm_field_int(vlan_info2, UVM_ALL_ON) `uvm_field_int(vlan_info3, UVM_ALL_ON) `uvm_field_int(vlan_info4, UVM_ALL_ON) end `uvm_field_int(ether_type, UVM_ALL_ON) `uvm_field_array_int(pload, UVM_ALL_ON) `uvm_field_int(crc, UVM_ALL_ON | UVM_NOPACK) `uvm_field_int(is_vlan, UVM_ALL_ON | UVM_NOPACK) `uvm_object_utils_end
这个is_vlan变量可以在sequence里约束成0或1,来实现vlan或非vlan
ps: 我觉得这个地方代码其实写成像3.3.3里的有一个crc_error的rand bit的更合理一些。然后crc_error是UVM_ALL_ON|UVM_NOPACK,而crc是UVM_ALL_ON
3.4 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 命令行方式 ------ 我觉得用这个就可以了 重载打印信息:
set_report_severity_override(UVM_WARNING,UVM_ERROR);
上述函数都是在connect_phase及后面的phase使用
设置UVM_ERROR到达一定数量结束仿真
set_report_max_quit_count(int) 设成0就是无论多少error都不退出
get_report_max_quit_count() 返回如果是0,说明无论多少error都不退出 设置在main_phase前调用。
simv +UVM_MAX_QUIT_COUNT=10
3.4.4 3.4.5 3.4.6 3.4.7 我觉得应该用不大到,就不做笔记了
3.5 config_db机制
uvm_config_db#(类型)::set/get(component指针,”…”,”变量名字”,para4) 都是4个参数:
第一个参数是一个component指针,如果是null的话,相当于uvm_root::get() 第二个参数是个路径字符串, 第一和第二两个参数组和成一个完整的路径 第三个参数对于set、get要完全一致,是变量名字 set的para4是数值,get的para4是变量
component中的成员变量如果:
1) component用uvm_component_utils宏注册 2) 变量用field-automation宏注册
3) component的build_phase函数里有super.build_phase(phase) 那么可以省略get语句
跨层次多重set的时候,看set的第一个参数,层级越高,优先级越高。 调用set的时候,第一个参数尽量使用this 同层次设置的时候是时间优先
非直线设置的时候注意 第一和第二参数的使用,如果需要parent指针,则要用this.m_parent
config_db机制支持通配符,但是作者不推荐使用通配符。 但是在对sequence的成员set的时候需要用通配符(6.6.1章节)。 使用如下函数调试 config_db
check_config_usage() print_config(1/0) 这两个函数在connect_phase函数中调 simv +UVM_CONFIG_DB_TRACE
注意:第二个参数设置错误不会报错!!------- config_db机制务必要注意参数的书写。
第4章 UVM中的TLM1.0通信
TLM 是Transaction Level Modeling缩写
这章要搞清楚 port export imp fifo以及几种操作function/task 和对应component中要实现的function/task
下面的箭头方向都是控制流的方向,不是数据流方向。
我觉得作为一个VMM用户会觉得TLM有点难理解,总想用VMM_CHANNEL去套,结果把自己搞晕。像port等其实是调imp所在component的task/function.
我看UVM源代码里有一个uvm_seq_item_pull_port的class,它的基类是uvm_port_base. 在uvm_driver的成员seq_item_port就是这个类型的。 与它对应的是uvm_seq_item_pull_imp,uvm_sequencer的成员seq_item_export就是这种类型。在my_agent.sv中会connect它们。
4.2端口互连
port是动作的发起者,export是动作接收者,但是需要以一个imp来结束。 可以port?export?imp port?port?imp 也可以port?imp export?imp
port?imp用的较多,port?port?imp可以用port指针赋值来实现port?port(4.3.2章节)
操作:
put get/peek transport, transport相当于一次put+一次get
peek和get的不同(4.3.4章节): 使用uvm_tlm_analysis_fifo的时候,get任务会使fifo中少一个transaction;而peek任务是fifo把transaction复制一份发出,内部缓存中的transaction不会减少。----- 一般情况下peek完以后,还得调get。
上述操作都有阻塞和非阻塞之分。 port export imp的类型也有blocking和nonblocking之分。 port/export/imp类型: put/get/peek/get_peek/transport blocking/nonblocking/不区分blocking-nonblocking之分
imp要多一个参数,除了声明transaction类型(或者REQ RSP类型)以外,还要声明实现这个接口的component
connect的一定是同类型的port/export/imp
TLM的关键在于“与imp对应的component中task/function的实现”。 假设A_port.connect(B_imp),那么需要实现的task/function为: