uvm实战-学习笔记.doc

上传人:F****n 文档编号:98044372 上传时间:2019-09-07 格式:DOCX 页数:31 大小:792.12KB
返回 下载 相关 举报
uvm实战-学习笔记.doc_第1页
第1页 / 共31页
uvm实战-学习笔记.doc_第2页
第2页 / 共31页
uvm实战-学习笔记.doc_第3页
第3页 / 共31页
uvm实战-学习笔记.doc_第4页
第4页 / 共31页
uvm实战-学习笔记.doc_第5页
第5页 / 共31页
点击查看更多>>
资源描述

《uvm实战-学习笔记.doc》由会员分享,可在线阅读,更多相关《uvm实战-学习笔记.doc(31页珍藏版)》请在金锄头文库上搜索。

1、UVM实战(卷1) 学习笔记看了第1/2/3/4/5/6/8/9.1 这几个章节。 第一章是综述,第二章是一个具体的例子,学习笔记从第三章相关内容开始。我个人觉得UVM重要的部分(特点的部分):1) factory机制(override config_db)2) TLM传递3) phase机制4) sequence-sequencer 以及virtual seq/sqr内容中的截图基本来自于 UVM源代码、书自带的例子和uvm1.1应用指南及源代码分析这个PDF里的。 需要结合书(UVM实战(卷1)第1版)来看这个笔记。第3章 UVM基础3.1 uvm_component和uvm_object

2、常用的类名字:这个图是从作者张强的uvm1.1应用指南及源代码分析里截得,不如书上3.1.1里的图好。uvm_sequencer也是代码里必须有的,所以我加了uvm_sequenceruvm_void是一个空的虚类。在src/base/uvm_misc.svh中定义:红框的是我们搭testbench的时候用的比较多的基类。常用的uvm_object派生类:sequencer给driver的transaction要派生自uvm_sequence_item,不要派生自uvm_transaction所有的sequence要派生自uvm_sequence或者uvm_sequence的派生类,可以理解为

3、sequence是sequence_item的组合(集合)。 driver向sequencer索要item,sequencer检查是否有sequence要发送item,当发现有item待发送时,就把这个item发给driver.常用的uvm_component派生类:所有的driver要派生自uvm_driver. driver用来把sequence_item中的信息驱动到DUT端口上,从transaction-level向signal-level的转换。 uvm_driver需要参数(REQ RSP),比uvm_component增加了几个成员。重要的是seq_item_port和req/r

4、sp. (src/comps/uvm_driver.svh)monitor/scoreboard 派生自 uvm_monitor和uvm_scoreboard, 但是uvm_monitor和uvm_scoreboard并没有在uvm_component基础上做扩展。src/comps/uvm_monitor.svhsequencer要派生自uvm_sequencer. sequencer做了很多扩展,但是如果我们自己写的sequencer里没有增加成员的话,可以直接写如下代码:typedef uvm_sequencer #(传递的sequence_item类名) sequencer类名;因为s

5、equencer在agent中例化,所以一般写在agent类文件里。reference_model派生自uvm_component. agent要派生自uvm_agent. uvm_agent里多了一个is_active的成员。一般根据这个active来决定是否实例化driver和sequencer. is_active变量的数值需要在env的build_phase里设置完成(可以直接设置,也可以用uvm_config_db#(int):set)。env要派生自uvm_env. uvm_env没有对uvm_component扩展。src/comps/uvm_env.svh所有的test都要派生

6、自uvm_test或者它的派生类。uvm_test也没扩展src/comps/uvm_test.svhuvm_object和uvm_component的macromacro非常重要,事关把这些类的对象注册到factory机制中去。uvm_object macro1)对于uvm_sequence_item就统一用(假设不用parameter):uvm_object_utils_begin(item类名). field_automationuvm_object_utils_end2)对于uvm_sequence,要加上uvm_object_utils(sequence 类名)可能还需要uvm_de

7、clare_p_sequencer(sequencer类名)的声明uvm_component macro对于driver monitor reference_model scoreboard sequencer case agent env这些uvm_component派生类都要加上:uvm_component_utils(类名)uvm_component里的成员也可以像uvm_object里成员一样,用field_automation机制。field_automation机制:对于uvm_object派生类来说,field_automation机制让对象自动有的copy compare pr

8、int pack unpack等函数,简化了实现uvm_component派生类里一些function/task的工作量对于uvm_component派生类来说,field_automation机制最重要的是 可以在build_phase中自动获取uvm_config_db#():set()的数值(必须加super.build_phase(phase))- 也就是不用写 uvm_config_db#():get() 注意: field_automation的macro的类型要和uvm_config_db的参数类型一致:如下示例代码, field_int vs uvm_config_db#(bi

9、t47:0) 这个时候super.build_phase()是不起作用的。想要起作用的话,需要用clone = new + copy 源代码中可以看到clone函数一上来会做一次create,然后调copy函数src/base/uvm_object.svh3.2 UVM的树形结构uvm_component的new/create要注意第一个参数是名字,第二个参数是parent指针。UVM真正的树根是“uvm_top”. 根据上面这个树结构,可以看出一个个component的parent是什么。uvm_top的parent是null。 当一个component在实例化的时候,如果parent参数设

10、成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_f

11、irst_child(ref string name) get_next_child(ref string name) 获取child的名字(反映到string name上),返回值是0/1两种情况应用参考代码如下(改动的2.5.2例子中的my_agent.sv): 注意:上述代码是在connet_phase中实现的。上述代码的打印结果如下:my_agents name is uvm_test_top.env.i_agt, parents full path is uvm_test_top.env, children num is 3uvm_test_top.env.i_agt 0 child

12、: drv - full path:uvm_test_top.env.i_agt.drvuvm_test_top.env.i_agt 1 child: mon - full path:uvm_test_top.env.i_agt.monuvm_test_top.env.i_agt 2 child: sqr - full path:uvm_test_top.env.i_agt.sqrThis should be i_agt. my_agents name is uvm_test_top.env.i_agtuvm_test_top.env.i_agt first child name is drv

13、uvm_test_top.env.i_agt next child name is monuvm_test_top.env.i_agt next child name is sqrmy_agents name is uvm_test_top.env.o_agt, parents full path is uvm_test_top.env, children num is 1uvm_test_top.env.o_agt 0 child: mon - full path:uvm_test_top.env.o_agt.monUVM_WARNING /tools/synopsys/vcs/G-2012

14、.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_agtThis should be o_agt. my_agents name is uvm_test_top.env.o_agtuvm_test_top.env.o_agt first child name is mon3.3 field automation 机制注意数组类型的field mac

15、ro比一般的要少real和event的macro. 一般的对于enum类型有3个参数,而数组的只有2个参数。 联合数组的macro比较多常用函数需要注意 pack unpack pack_bytes unpack_bytes pack_ints unpack_ints 返回值都是bit个数。field-automation标记位17bit中 bit0copy bit1no_copy bit2compare bit3no_compare bit4print bit5no_print bit6record bit7no_record bit8pack bit9no_packUVM_ALL_ON是 b0101UVM_ALL_ON|UVM_NO_PACK 这样就会忽略掉pack bitfield-automation的macro可以和if结合起来,参考3.3.4的代码 uvm_object_utils_begin(my_tr

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 教学/培训

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号