当前位置: 简表范文网 > 专题范文 > 公文范文 >

uvm实战-学习笔记

| 来源:网友投稿

下面是小编为大家整理的uvm实战-学习笔记,供大家参考。

uvm实战-学习笔记

 

 ? ?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 常用的类名字:

 这个图是从作者张强的?uvm1.1 应用指南及源代码分析?里截得,不如书上 3.1.1 里的图好. uvm_sequencer 也是代码里必须有的,所以我加了 uvm_sequencer

  在 src/base/uvm_misc.svh 中定义: virtual c 1 ass uvnri_\/oid endclass 红框的是我们搭 testbench 的时候用的比拟多的基类. 的 常用的 uvm_object 派生类: : sequencer 给 driver 的 transaction 要 派生 自 uvm_sequence_item, 不 要派生 自 uvm_transaction 所有的 sequence 要派生自 uvm_sequence 或者 uvm_sequence 的派生类,可以理解为 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/rsp. (src/comps/uvm_driver.svh) uvm_void 是一一个空的虚类.

 monitor/scoreboard 派生自 uvm_monitor 和 uvm_scoreboard, 但是 uvm_monitor 和 uvm_scoreboard 并没有在 uvm_component 根底上做扩展. src/comps/uvm_monitor.svh virtu.al class uvrn_mun L tor extends uyn_cornponent 〃

 Function* new Z/ Cr&atcs and 白门 instance G -F thio class using the normal 7/ conetructor arguments Por <uvjn_coinponent> :

 is the nainQ of the 7/ ins-tanc@, and ^parant^ is ths handle to the hierarchical parent, if any« Functian new .string name, uyn_camponent parent); eu.per . new (. name 3

 pa pent ।

 ; endPuinct L

 on izonut static string type_nani9 x/i 「二 UIN I -Puinction string get_type_name (J; ret j.rn t.yp&_name : endPuinct L

 on endclass sequencer 要派生自 uvm_sequencer. sequencer 做了很多扩展,但是如果我们自己写的 sequencer 里没有增加成员的话,可以直接写如下代码:

 typedef uvm_sequencer #〔传递的 sequence_item 类名 〕

 sequencer 类名 ; 由于 sequencer 在 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 vir tLial c la:=1:=1 u"i/rii_env extends uvm_Dorriponent; // Functi on :

 new 〃 // Creates and initializes an instance o-F this class using the rwrmal 7/ constructor arguments -Por <uviiii_coijipm«t.> :

 ^name~ Is the :

 name &F 工 he // instance f

 and ""p 白 rent" is the handle to the hiersrcfiical parent, i? any* T unct i □ n nci-.i 〔string na me- ,, u-"---"" 1

 u.vni_corii po ne nt parent-null ]; super.new name 3 parenti; endFLKCti on conEt static "= :

 t-ing type_name 1 「 tu.si 4"u.net L □ n stving get_ty pe_n.ariie 「 Et LT 广门 ty pe_nanie ; endFunction

 endclase 所有的 test 都要派生自 uvm_test 或者它的派生类.uvm_test 也没扩展 src/comps/uvm_test.svh ■/irtual clasc u.vrn_test extends ULVTII _ C □mponent // Function; new X/ // Creates and initializes an instance of this class using the normal // constructor argtiments For < uwiKii_compor>ent.> :

 is the name of the // instance, 白 rtd ""pareniU™ is the handle to th@ hi^rardnlcal parent, i-P any fu.net Lon new i "= :

 tring n.ame 】

 uvni_conponent parent〕; super .neujt name n

 parent j ; end-TunctiDri const static string type_name = 1

 virtual function string get_type_nsme 〔\ ; retLi.rn type_name ; end-Punct i on en du last :

 uvm_object 和

 uvm_component 的

 macro macro 非常重要,事关把这些类的对象注册到 factory 机制中去. uvm_object macro 1〕对于 uvm_sequence_item 就统一用〔假设不用 parameter〕:

 "uvm_object_utils_begin〔item 类名〕 ….field_automation... "uvm_object_utils_end 2〕对于 uvm_sequence,要加上 "uvm_object_utils〔sequence 类名 〕 可能还需要"uvm_declare_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 机制. "

 \ TVUL

 comp ,二七二二 m beci_r:,{my diivei} "JLvnL_f iel(pr r

 UVM_ALL_OM} " avnL_caiiLpoE.ent-_.;tiL3_end field_automation 机制:

 对于 uvm_object 派生类来说,field_automation 机制让对象自动有的 copy compare print 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#(bit[47:0])这个时候 super.build_phase()是不起 作用的. class my_sequencer extends uvm-sequencer my_transaction bit -47:0] dmac; bit ; 47:0] smac //int dmac; //int smac; " uvm_component._LJiti ls_begin (my_sequencer ) " u , v , m_-Field_int (dmac , 、 uvm_-Field_int (smac , " uvm_component._uit i ls_end Q-i L

 .Lun iu my_c3eeC build_phast uvffl_phase phase ■=ur 」 ir, juilcLphaet ahase uvn_config_dbt jj i :

 set Ji 二 ■= :

 ni L :

 口 j :

 :

 emt :■=:> 一二一\ , 43 卜自 1 二上三 1 ; 想要起作用的话,需要用 Furct 1 on nid my_caseO build_phase u.vm.phasE- phase); ou.pn-r- bnild_phase phase); //uv™_conFig.cJb#(bit[47 :

 0] 1 :

 isetCthiSi "env.i-agt*3qr M

 3

 "dmac" B , 48"WF9765); /H LIVUI

 .conf ig_<Jbt(bit[47 :

 0] ) :

 ai env.i-agt*3qr w

 3

 fi, smac ,b , 4sh89F23); uvm.config_db#C int ।

 :

 sett this 3

 匚:口 nfiE_db#i ;

 int ।

 :

 三 5=1 三 t "三 n 闩厂 ."j 43 8

 - r r3) ; clone = new + copy 源代码中可以看到 clone 函数一上来会做一次 create,然后调 copy 函数 src/base/uvm_object.svh

 function uun_abjcct uvin_otij tc t uJcirw uvm_nb.jrct trip: tmp this .crwrt!? i-f" tnp null uyn-repcrrt-Marnins elw tffi 口 copy this reiiirn tnp sfidfLinctlan 〃

 -capij //

 Function void u"H"m.object c:opy uvn.ahject rtia „Fo 「 cycle -chwklng Bt-wtic int depth i-T- rhe null ^ uyn_Elob(sl_DDpu_nan ETt If (Thia nu.ll) bsgLn uvm„rfflpDTrt_idaT i n Lng mtiirn; and uvm_gLabaL_cnpy_iiHp.set rhs . this : depth: __m_uvnuFiolcL/WJitonwtion 小事 dcuGDpj rhs : deptn. if :deptJi te^ln UyiTi_g] Qb=il_C^y _jViap _C ] AT 广 and d-TuHOtlan 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 指针. rho null be-sin

 get_children(ref uvm_component children[$])获取所有的 child 指针 get_num_children()获取 child 个数 get_first_child(ref string name) get_next_child(ref string name)获取 child 的名字(反映至 U string name 上),返回值是 0/1 两种情况 应用参考代码如下(改动的 2.5.2 例子中的 my_agent.sv):

 function void ny_aEont connnc:t_phjEci uvn_phjEBi phasiD ijivm-component children 3 uum-component child string child_narie supsr . cnnnoE t_pha=c-1 ph, if (is.active . beein dru 5eq_itpm_port connect sqr 5&q_itpri-i_e^pc!r-t ; end ap = fton.ap :

 .thi E

 g.Qt_-Ru.ll_namc- thi-= . 301 .parent. this .ffet_num_ch i Idren()); thig get-chi 1dren 1

 chiIdren :

 ■Poreach 1

 children i begin ..rhle .ger_Fu 1 L_n 加 E

 1,1,ct _ i11 di^en" 1 ] get_ranre 1

 chiIdren [1] .g et_ -Fu l l_n.3ne(1); ond child this eet-child if chi10null. begin .this g_9t_fUlL_H3me end else b>?gin 0nd if thia-set.First_chiId 1 child_namebeEin - - Sj

 this get-PulLnarie .chilcLrar"5, uhile 1 this.get_ne^t_child"chiLd_name "begin j.rhls . eet_ru :

 Ll_nam&!) .chi Id-nane und ond i?13F beein this get^-full-namE ))] end end-Function 注意:上述代码是在 connet_phase 中实现的. 上述代码的打印结果如下:

 my_agent"s name is uvm_test_top.env.i_agt, parent"s full path is uvm_test_top.env, children num is3 uvm_test_top.env.i_agt0 child: drv --> full path:uvm_test_top.env.i_agt.drv uvm_test_top.env.i_agt1 child: mon --> full path:uvm_test_top.env.i_agt.mon uvm_test_top.env.i_agt2 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 is1 uvm_test_top.env.o_agt0 child: mon --> full path:uvm_test_top.env.o_agt.mon UVM_WARNING /tools/synopsys/vcs/G-2021.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 3 copy bit1 3 no_copy bit2 3 compare bit3 3 no_compare bit4 — print bit5 3 no_print bit6 3 record bit7 3 no_record bit8 — pack bit9 3 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...

相关推荐

热门文章

防自然灾害安全教育心得7篇通用【完整版】

本页是最新发布的《防自然灾害安全教育心得7篇通用》的详细范文参考文章,觉得有用就收藏了,为了方便大家的阅读。教育能让更新了观念,改善了思想,了解了当前的社会形式。你在安全教育中一定有意想不到的收获,写一篇安全教育心得回顾一下吧。你是否在找正准备撰写“防自然灾害安全教育心得”,下面小编收集了

小学生寒假安全教育家长心得3篇通用

本页是最新发布的《小学生寒假安全教育家长心得3篇通用》的详细范文参考文章,好的范文应该跟大家分享,这里给大家转摘到。是生命之本,安全是头等财富!我们每个人都应该重视自己安全。写一篇安全心得能让自己在安全教育过后的总结中得到许多的收获。你是否在找正准备撰写“小寒假安全教育家长心得”

2022年70年周年校庆演讲稿最新范本(精选文档)

《70年周年校庆演讲稿最新范文》是一篇好的范文,觉得有用就收藏了,希望大家能有所收获。演讲稿的最终目的是用于讲话,所以,它是有声语言,是书面化的口语。它一方面是把口头语言变为书面语言,即化声音为文字,起到规范文字、有助演讲的作用。下面是小编为大家整理的70年演讲稿最新范文,希望能够帮助到大家!70年

2022年度清明节感怀演讲稿【完整版】

本页是最新发布的《2022清明节感怀演讲稿》的详细范文参考文章,好的范文应该跟大家分享,重新编辑了一下发到。4月4日,是我国的传统节日:清明节,让怀着无比沉重和景仰的心情来缅怀革命,继承革命传统。你知道么,今天小编整理了清明节感怀演讲稿供大家参考,一起来看看吧!清明节感怀演讲稿一

2022教学工作会议演讲稿(全文完整)

《教学工作会议演讲稿》是一篇好的范文,觉得应该跟大家分享,希望大家能有所收获。演讲稿是人们在工作和社会生活中经常使用的一种文体。它可以用来交流思想,感情,表达主张,见解。也可以用来介绍自己的学习,工作情况和经验等等。下面是小编为大家整理的工作会议演讲稿,希望能够帮助到大家!教学工作会议演讲稿1各位:

五四青年节青春演讲稿

《五四青年节青春演讲稿2022》是一篇好的范文,觉得有用就收藏了,重新编辑了一下发到。青年们还要集中进行各种社会志愿和社会实践活动,还有许多地方在青年节期间举行****仪式。五四的核心内容为,进步,民主,科学。以下是小编为大家准备了五四青年节演讲稿2022范本,欢迎参阅。五四青年节青春演讲

2022最新青年担当演讲稿(全文完整)

《最新青年担当演讲稿》是一篇好的范文,感觉很有用处,这里给大家转摘到。沧海,无人愿甘沦平庸,无人愿在茫茫粟漠中归依。青年们,当在光华中,勇披战衣,秉承之责任心,书写高昂之战歌。下面是小编为大家整理的最新青年担当演讲稿,希望能够帮助到大家!最新青年担当演讲稿1敬爱的老师,亲爱的同学:大家好!

2022年度清明节主题学生作文500字合集

《2022清明节主题学生作文500字》是一篇好的范文,觉得应该跟大家分享,这里给大家转摘到。这来之不易的幸福生活是革命用自己的鲜血换来的,作为一名青年志愿者,一定不辜负烈士们的遗愿,让我们踏着烈士们的足迹奋勇向前!下面是小编为大家带来的关于2022主题学生作文500字,希望能对大家

2022年高三毕业典礼演讲稿(精选文档)

最近发表了一篇名为《高三2022年毕业典礼演讲稿》的范文,觉得有用就收藏了,重新整理了一下发到这里。演讲是演讲者与听众、听众与听众的三角信息交流,演讲者不能以传达自己的思想和情感、情绪为满足,他必须能控制住自己与听众、听众与听众情绪的应和与交流。

五四精神演讲稿

本页是最新发布的《2022五四精神演讲稿》的详细范文参考文章,感觉很有用处,这里给大家转摘到。演讲稿也叫演讲词,它是在较为隆重的仪式上和某些公众场合发表的讲话文稿。演讲稿是进行演讲的依据,是对演讲内容和形式的规范和提示,它体现着演讲的目的和手段。以下是小编整理的2022五四演讲稿

学雷锋致英雄演讲稿怎么写(完整)

最近发表了一篇名为《学雷锋致英雄演讲稿怎么写》的范文,觉得应该跟大家分享,这里给大家转摘到。演讲稿特别注重结构清楚,层次简明。在日新月异的现代社会中,在很多情况下需要用到演讲稿,如何写一份恰当的演讲稿呢?下面是小编为大家整理的学致英雄演讲稿怎么写,希望能够帮助到大家!学雷锋致英雄

语文新课程纲要教材解读培训心得3篇通用

本页是最新发布的《语文新课程纲要教材解读培训心得3篇通用》的详细范文参考文章,觉得有用就收藏了,看完如果觉得有帮助请记得(CTRL+D)收藏本页。语文要让了解文章的含义,吸取其中的精华,感悟文章的写法。你知道语文心得的写法?不妨来学习一下如何写语文培训心得。你是否在找正准备撰写“语文新课程