网站建设基本流程ppt,网站建设网上学,2017网站备案,皋兰县城乡和住房建设局网站field_automation机制是域的自动化的机制#xff0c;这个机制的最大的优点是可以对一些变量进行批量的处理#xff0c;比如对象拷贝、克隆、打印之类的变量。
一、 成员变量的注册
使用field_automation机制首先要用uvm_field 系列宏完成变量的注册#xff0c;类中的成员变…field_automation机制是域的自动化的机制这个机制的最大的优点是可以对一些变量进行批量的处理比如对象拷贝、克隆、打印之类的变量。
一、 成员变量的注册
使用field_automation机制首先要用uvm_field 系列宏完成变量的注册类中的成员变量类型决定了要使用什么样的 uvm_field 宏如int型变量使用uvm_field_int(ARG,FLGA)宏其中ARG为定义的成员变量FLAG表示为当前成员变量的操作打开或关闭。
1标量类型
最简单的uvm_field系列宏有如下几种
define uvm_field_int(ARG,FLAG)
define uvm_field_real(ARG,FLAG)
define uvm_field_enum(T,ARG,FLAG)
define uvm_field_object(ARG,FLAG)
define uvm_field_event(ARG,FLAG)
define uvm_field_string(ARG,FLAG) 特别指出这里的define除了枚举类型外都是两个参数对于枚举类型来说define uvm_field_enum(T,ARG,FLAG) 需要有三个参数这里的T就是枚举的类型名称。
2静态数组类型
与静态数组相关的uvm_field系列宏有
define uvm_field_sarray_int(ARG,FLAG)
define uvm_field_sarray_enum(ARG,FLAG)
define uvm_field_sarray_object(ARG,FLAG)
define uvm_field_sarray_string(ARG,FLAG)
特别说明这里都是一维数组类型enum类型的数组里参数只有两个。
3动态数组类型
define uvm_field_array_enum(ARG,FLAG)
define uvm_field_array_int(ARG,FLAG)
define uvm_field_array_object(ARG,FLAG)
define uvm_field_array_string(ARG,FLAG
特别说明这里都是一维数组类型enum类型的数组里参数只有两个。
4, 队列类型
define uvm_field_queue_enum(ARG,FLAG)
define uvm_field_queue_int(ARG,FLAG)
define uvm_field_queue_object(ARG,FLAG)
define uvm_field_queue_string(ARG,FLAG)
特别说明enum类型的数组里参数只有两个。 5联合数组
define uvm_field_aa_int_string(ARG, FLAG)
define uvm_field_aa_string_string(ARG, FLAG)
define uvm_field_aa_object_string(ARG, FLAG)
define uvm_field_aa_int_int(ARG, FLAG)
define uvm_field_aa_int_int_unsigned(ARG, FLAG)
define uvm_field_aa_int_integer(ARG, FLAG)
define uvm_field_aa_int_integer_unsigned(ARG, FLAG)
define uvm_field_aa_int_byte(ARG, FLAG)
define uvm_field_aa_int_byte_unsigned(ARG, FLAG)
define uvm_field_aa_int_shortint(ARG, FLAG)
define uvm_field_aa_int_shortint_unsigned(ARG, FLAG)
define uvm_field_aa_int_longint(ARG, FLAG)
define uvm_field_aa_int_longint_unsigned(ARG, FLAG)
define uvm_field_aa_string_int(ARG, FLAG)
define uvm_field_aa_object_int(ARG, FLAG)
特别说明这里联合数组有两大识别标志一是索引的类型二是存储数据的类型。在这一系列uvm_field系列宏中出现的第一个类型是存储数据类型第二个类型是索引类型如uvm_field_aa_int_string用于声明那些存储的数据是int而其索引是string类型的联合数组。
二、 field automation机制函数
field automation功能非常强大它主要提供了如下函数。
1copy函数用于实例的复制其原型为
extern function void copy (uvm_object rhs);
如果要把某个A实例复制到B实例中那么应该使用B.copyA。在使用此函数前B实例必须已经使用new函数分配好了内存空间。
2compare函数用于比较两个实例是否一样其原型为
extern function bit compare (uvm_object rhs, uvm_comparer comparernull);
如果要比较A与B是否一样可以使用A.compareB也可以使用B.compareA。当两者一致时返回1否则为0。
3pack_bytes函数用于将所有的字段打包成byte流其原型为
extern function int pack_bytes (ref byte unsigned bytestream[],input uvm_packer packernull);
4unpack_bytes函数用于将一个byte流逐一恢复到某个类的实例中其原型为
extern function int unpack_bytes (ref byte unsigned bytestream[],input uvm_packer packernull);
5pack函数用于将所有的字段打包成bit流其原型为
extern function int pack (ref bit bitstream[],input uvm_packer packernull);
pack函数的使用与pack_bytes类似。
6unpack函数用于将一个bit流逐一恢复到某个类的实例中其原型为
extern function int unpack (ref bit bitstream[], input uvm_packer packernull);
7pack_ints函数用于将所有的字段打包成int4个byte或者dword流其原型为
extern function int pack_ints (ref int unsigned intstream[],input uvm_packer packernull);
8unpack_ints函数用于将一个int流逐一恢复到某个类的实例中其原型为
extern function int unpack_ints (ref int unsigned intstream[],input uvm_packer packernull);
9print函数用于打印所有的字段。
function void print (uvm_printer printer null)
10clone函数原型是
virtual function uvm_object clone ()
三、 field_automation使用方法
1 object类型域的自动化
part1/field_automation是UVM field_automation机制的实验首先注册在uvm_object_utils_begin(sequence_item) uvm_object_utils_end之间。 uvm_object_utils_begin(squence_item) uvm_field_int(data,UVM_ALL_ON) … uvm_object_utils_end 注册之后就可以在验证环境中使用field_automation函数。
在dadd_item对dataaddr进行了注册。 File:dadd_item.svClass:dadd_itemclass dadd_item extends uvm_sequence_item;uvm_object_utils_begin(dadd_item)uvm_field_int(data,UVM_ALL_ON)uvm_field_int(addr,UVM_ALL_ON)uvm_object_utils_endrand bit data_en;rand bit [31:0] data;rand bit [31:0] addr;extern function new(string name dadd_item);endclass: dadd_item
代码3.41 field_automation机制对item中参数注册代码 在dadd_scoreboard中对DUT的数据包和参考模型的数据包对比时用到了compare函数这样对比的就是data和addr变量。 File:dadd_scoreboard.svClass:dadd_scoreboardtask dadd_scoreboard :: main_phase(uvm_phase phase);dadd_item dadd_exp_item, dadd_act_item, tmp_dadd_exp_item;forkwhile(1)beginexp_port.get(dadd_exp_item);dadd_exp_queue.push_front(dadd_exp_item);endwhile(1)beginact_port.get(dadd_act_item);beginwait(dadd_exp_queue.size()0);tmp_dadd_exp_item dadd_exp_queue.pop_back();if(!tmp_dadd_exp_item.compare(dadd_act_item))beginuvm_error(dadd_scoreboard,$sformatf(Transaction miss match!\nExpect_addr:%h,Expect_data:%h\nActual_addr:%h,Expect_data:%h\n, tmp_dadd_exp_item.addr,tmp_dadd_exp_item.data,dadd_act_item.addr,dadd_act_item.data));endelsebeginuvm_info(dadd_scoreboard,DADD_PASS,UVM_LOW);endendendjoinendtask: main_phase
代码3.42 field_automation机制实验中的dadd_scoreboard的代码 2component类型域的自动化
首先注册在uvm_component_utils_begin(component) uvm_component_utils_end之间。 uvm_component_utils_begin(squence_item) uvm_field_int(data,UVM_ALL_ON) … uvm_component_utils_end 注册之后在也可在环境中使用一些相关的函数。
前面config_db机制讲过config_db::get时可以不用写也能得到相应的值这就用到了field_automation机制。
在component通过field_automation机制注册的变量可以省略config_db::get但是要注意config_db::get的第三个参数也就是标志位一定要和得到这个值的变量名一致。
在part1/field_automation实验中在dadd_environment中向dadd_driver发送一个字符串
File:dadd_environment.svClass:dadd_environmentfunction void dadd_environment :: build_phase(uvm_phase phase);iagt dadd_iagent :: type_id :: create(iagt,this);oagt dadd_oagent :: type_id :: create(oagt,this);refmdl dadd_refmodel :: type_id :: create(refmdl,this);scb dadd_scoreboard :: type_id :: create(scb,this);dadd_iagt_to_refmdl_fifo new(dadd_iagt_to_refmdl_fifo,this);dadd_oagt_to_scb_fifo new(dadd_oagt_to_scb_fifo,this);dadd_refmdl_to_scb_fifo new(dadd_refmdl_to_scb_fifo,this);if(!uvm_config_db #(virtual dadd_interface) :: get(this,,vif,vif))uvm_fatal(dadd_environment,The interface is not get !!!);iagt.vif vif;oagt.vif vif;uvm_config_db#(string) :: set(this,iagt.drv,field_automation_config_db,This is no need config_db::get by use field_automation in component.);endfunction : build_phase
代码3.43 field_automation机制component类型域的自动化实验中dadd_environment的代码 在dadd_driver中声明了一个变量
string field_automation_config_db;
在main_phase中直接打印出field_automation_config_db这个变量名字和dadd_environment中config_db::set的值是相同的。 File:dadd_driver.svClass:dadd_driverclass dadd_driver extends uvm_driver #(dadd_item);string field_automation_config_db;uvm_component_utils_begin(dadd_driver)uvm_field_string(field_automation_config_db,UVM_ALL_ON)uvm_component_utils_end
代码3.44 field_automation机制component类型域的自动化实验中dadd_driver的代码 执行Makefile脚本
make all
执行仿真打印的结果为 图3.24 component类型域的自动化实验的仿真log截图
本书《UVM实验教程-从平台、脚本到方法学全代码解析-王建利》及其实验代码已上传至GitHub 访问网址为 https://github.com/brentwang-lab/uvm_tb_gen 文章转载自: http://www.morning.sbkb.cn.gov.cn.sbkb.cn http://www.morning.qxrct.cn.gov.cn.qxrct.cn http://www.morning.qyxnf.cn.gov.cn.qyxnf.cn http://www.morning.youprogrammer.cn.gov.cn.youprogrammer.cn http://www.morning.tssmk.cn.gov.cn.tssmk.cn http://www.morning.hmxb.cn.gov.cn.hmxb.cn http://www.morning.pypqf.cn.gov.cn.pypqf.cn http://www.morning.gpfuxiu.cn.gov.cn.gpfuxiu.cn http://www.morning.wnxqf.cn.gov.cn.wnxqf.cn http://www.morning.hhrpy.cn.gov.cn.hhrpy.cn http://www.morning.qwdqq.cn.gov.cn.qwdqq.cn http://www.morning.mjats.com.gov.cn.mjats.com http://www.morning.ypklb.cn.gov.cn.ypklb.cn http://www.morning.bpmmq.cn.gov.cn.bpmmq.cn http://www.morning.irqlul.cn.gov.cn.irqlul.cn http://www.morning.twhgn.cn.gov.cn.twhgn.cn http://www.morning.kzxlc.cn.gov.cn.kzxlc.cn http://www.morning.lzqtn.cn.gov.cn.lzqtn.cn http://www.morning.qpzjh.cn.gov.cn.qpzjh.cn http://www.morning.kmqwp.cn.gov.cn.kmqwp.cn http://www.morning.dmthy.cn.gov.cn.dmthy.cn http://www.morning.yrgb.cn.gov.cn.yrgb.cn http://www.morning.ypfw.cn.gov.cn.ypfw.cn http://www.morning.bsqbg.cn.gov.cn.bsqbg.cn http://www.morning.tqpnf.cn.gov.cn.tqpnf.cn http://www.morning.ybyln.cn.gov.cn.ybyln.cn http://www.morning.trqhd.cn.gov.cn.trqhd.cn http://www.morning.cgmzt.cn.gov.cn.cgmzt.cn http://www.morning.zffps.cn.gov.cn.zffps.cn http://www.morning.zsrjn.cn.gov.cn.zsrjn.cn http://www.morning.ffhlh.cn.gov.cn.ffhlh.cn http://www.morning.msbct.cn.gov.cn.msbct.cn http://www.morning.jbxd.cn.gov.cn.jbxd.cn http://www.morning.nqypf.cn.gov.cn.nqypf.cn http://www.morning.dhyqg.cn.gov.cn.dhyqg.cn http://www.morning.qwmdx.cn.gov.cn.qwmdx.cn http://www.morning.qbtkg.cn.gov.cn.qbtkg.cn http://www.morning.kyzja.com.gov.cn.kyzja.com http://www.morning.qxdrw.cn.gov.cn.qxdrw.cn http://www.morning.bgzgq.cn.gov.cn.bgzgq.cn http://www.morning.mcjxq.cn.gov.cn.mcjxq.cn http://www.morning.mkpkz.cn.gov.cn.mkpkz.cn http://www.morning.sfrw.cn.gov.cn.sfrw.cn http://www.morning.fstdf.cn.gov.cn.fstdf.cn http://www.morning.nkcfh.cn.gov.cn.nkcfh.cn http://www.morning.lbggk.cn.gov.cn.lbggk.cn http://www.morning.znknj.cn.gov.cn.znknj.cn http://www.morning.gmgyt.cn.gov.cn.gmgyt.cn http://www.morning.nrpp.cn.gov.cn.nrpp.cn http://www.morning.tjndb.cn.gov.cn.tjndb.cn http://www.morning.wxlzr.cn.gov.cn.wxlzr.cn http://www.morning.kzbpx.cn.gov.cn.kzbpx.cn http://www.morning.wbllx.cn.gov.cn.wbllx.cn http://www.morning.spbp.cn.gov.cn.spbp.cn http://www.morning.pshtf.cn.gov.cn.pshtf.cn http://www.morning.rmyqj.cn.gov.cn.rmyqj.cn http://www.morning.nzzws.cn.gov.cn.nzzws.cn http://www.morning.vjdofuj.cn.gov.cn.vjdofuj.cn http://www.morning.ykkrg.cn.gov.cn.ykkrg.cn http://www.morning.ho-use.cn.gov.cn.ho-use.cn http://www.morning.cpctr.cn.gov.cn.cpctr.cn http://www.morning.gjlxn.cn.gov.cn.gjlxn.cn http://www.morning.rcwbc.cn.gov.cn.rcwbc.cn http://www.morning.clnmf.cn.gov.cn.clnmf.cn http://www.morning.hdtcj.cn.gov.cn.hdtcj.cn http://www.morning.cknws.cn.gov.cn.cknws.cn http://www.morning.xsetx.com.gov.cn.xsetx.com http://www.morning.qxxj.cn.gov.cn.qxxj.cn http://www.morning.wbnsf.cn.gov.cn.wbnsf.cn http://www.morning.pswqx.cn.gov.cn.pswqx.cn http://www.morning.gktds.cn.gov.cn.gktds.cn http://www.morning.fnxzk.cn.gov.cn.fnxzk.cn http://www.morning.shawls.com.cn.gov.cn.shawls.com.cn http://www.morning.rkdhh.cn.gov.cn.rkdhh.cn http://www.morning.cpnlq.cn.gov.cn.cpnlq.cn http://www.morning.rpzqk.cn.gov.cn.rpzqk.cn http://www.morning.qhvah.cn.gov.cn.qhvah.cn http://www.morning.wmdqc.com.gov.cn.wmdqc.com http://www.morning.bwzzt.cn.gov.cn.bwzzt.cn http://www.morning.xtlty.cn.gov.cn.xtlty.cn