uvm_reg_adapter 功能就是在uvm_reg_bus_op和总线操作之间的转换。主要包含两个函数reg2bus 和bus2reg。

//------------------------------------------------------------------------------
// Title: Classes for Adapting Between Register and Bus Operations
//
// This section defines classes used to convert transaction streams between
// generic register address/data reads and writes and physical bus accesses.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
//
// Class: uvm_reg_adapter
//
// This class defines an interface for converting between <uvm_reg_bus_op>
// and a specific bus transaction.
//------------------------------------------------------------------------------ virtual class uvm_reg_adapter extends uvm_object; // Function: new
//
// Create a new instance of this type, giving it the optional ~name~. function new(string name="");
super.new(name);
endfunction // Variable: supports_byte_enable
//
// Set this bit in extensions of this class if the bus protocol supports
// byte enables. bit supports_byte_enable; // Variable: provides_responses
//
// Set this bit in extensions of this class if the bus driver provides
// separate response items. bit provides_responses; // Variable: parent_sequence
//
// Set this member in extensions of this class if the bus driver requires
// bus items be executed via a particular sequence base type. The sequence
// assigned to this member must implement do_clone(). uvm_sequence_base parent_sequence; // Function: reg2bus
//
// Extensions of this class ~must~ implement this method to convert the specified
// <uvm_reg_bus_op> to a corresponding <uvm_sequence_item> subtype that defines the bus
// transaction.
//
// The method must allocate a new bus-specific <uvm_sequence_item>,
// assign its members from
// the corresponding members from the given generic ~rw~ bus operation, then
// return it. pure virtual function uvm_sequence_item reg2bus(const ref uvm_reg_bus_op rw); // Function: bus2reg
//
// Extensions of this class ~must~ implement this method to copy members
// of the given bus-specific ~bus_item~ to corresponding members of the provided
// ~bus_rw~ instance. Unlike <reg2bus>, the resulting transaction
// is not allocated from scratch. This is to accommodate applications
// where the bus response must be returned in the original request. pure virtual function void bus2reg(uvm_sequence_item bus_item,
ref uvm_reg_bus_op rw); local uvm_reg_item m_item; // function: get_item
//
// Returns the bus-independent read/write information that corresponds to
// the generic bus transaction currently translated to a bus-specific
// transaction.
// This function returns a value reference only when called in the
// <uvm_reg_adapter::reg2bus()> method.
// It returns ~null~ at all other times.
// The content of the return <uvm_reg_item> instance must not be modified
// and used strictly to obtain additional information about the operation.
virtual function uvm_reg_item get_item();
return m_item;
endfunction virtual function void m_set_item(uvm_reg_item item);
m_item = item;
endfunction
endclass //------------------------------------------------------------------------------
// Group: Example
//
// The following example illustrates how to implement a RegModel-BUS adapter class
// for the APB bus protocol.
//
//|class rreg2apb_adapter extends uvm_reg_adapter;
//| `uvm_object_utils(reg2apb_adapter)
//|
//| function new(string name="reg2apb_adapter");
//| super.new(name);
//|
//| endfunction
//|
//| virtual function uvm_sequence_item reg2bus(uvm_reg_bus_op rw);
//| apb_item apb = apb_item::type_id::create("apb_item");
//| apb.op = (rw.kind == UVM_READ) ? apb::READ : apb::WRITE;
//| apb.addr = rw.addr;
//| apb.data = rw.data;
//| return apb;
//| endfunction
//|
//| virtual function void bus2reg(uvm_sequencer_item bus_item,
//| uvm_reg_bus_op rw);
//| apb_item apb;
//| if (!$cast(apb,bus_item)) begin
//| `uvm_fatal("CONVERT_APB2REG","Bus item is not of type apb_item")
//| end
//| rw.kind = apb.op==apb::READ ? UVM_READ : UVM_WRITE;
//| rw.addr = apb.addr;
//| rw.data = apb.data;
//| rw.status = UVM_IS_OK;
//| endfunction
//|
//|endclass
//
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
//
// Class: uvm_reg_tlm_adapter
//
// For converting between <uvm_reg_bus_op> and <uvm_tlm_gp> items.
//
//------------------------------------------------------------------------------ class uvm_reg_tlm_adapter extends uvm_reg_adapter; `uvm_object_utils(uvm_reg_tlm_adapter) function new(string name = "uvm_reg_tlm_adapter");
super.new(name);
endfunction // Function: reg2bus
//
// Converts a <uvm_reg_bus_op> struct to a <uvm_tlm_gp> item. virtual function uvm_sequence_item reg2bus(const ref uvm_reg_bus_op rw); uvm_tlm_gp gp = uvm_tlm_gp::type_id::create("tlm_gp",, this.get_full_name());
int nbytes = (rw.n_bits-)/+;
uvm_reg_addr_t addr=rw.addr; if (rw.kind == UVM_WRITE)
gp.set_command(UVM_TLM_WRITE_COMMAND);
else
gp.set_command(UVM_TLM_READ_COMMAND); gp.set_address(addr); gp.m_byte_enable = new [nbytes];
gp.m_byte_enable_length = nbytes; gp.set_streaming_width (nbytes); gp.m_data = new [gp.get_streaming_width()];
gp.m_length = nbytes; for (int i = ; i < nbytes; i++) begin
gp.m_data[i] = rw.data[i*+:];
gp.m_byte_enable[i] = (i > nbytes) ? 'h00 : (rw.byte_en[i] ? 8'hFF : 'h00);
end return gp; endfunction // Function: bus2reg
//
// Converts a <uvm_tlm_gp> item to a <uvm_reg_bus_op>.
// into the provided ~rw~ transaction.
//
virtual function void bus2reg(uvm_sequence_item bus_item,
ref uvm_reg_bus_op rw); uvm_tlm_gp gp;
int nbytes; if (bus_item == null)
`uvm_fatal("REG/NULL_ITEM","bus2reg: bus_item argument is null") if (!$cast(gp,bus_item)) begin
`uvm_error("WRONG_TYPE","Provided bus_item is not of type uvm_tlm_gp")
return;
end if (gp.get_command() == UVM_TLM_WRITE_COMMAND)
rw.kind = UVM_WRITE;
else
rw.kind = UVM_READ; rw.addr = gp.get_address(); rw.byte_en = ;
foreach (gp.m_byte_enable[i])
rw.byte_en[i] = gp.m_byte_enable[i]; rw.data = ;
foreach (gp.m_data[i])
rw.data[i*+:] = gp.m_data[i]; rw.status = (gp.is_response_ok()) ? UVM_IS_OK : UVM_NOT_OK; endfunction endclass

uvm_reg_adapter——寄存器模型(十八)的更多相关文章

  1. uvm_reg_map——寄存器模型(八)

    所有的寄存器都需要地址,都需要加入到地址列表中 //-------------------------------------------------------------------------- ...

  2. uvm_reg_cbs——寄存器模型(十六)

    当你完成寄存器模型的时候,你就会想到给后来的人一个接口,给他更多的扩展,让他做更多的事,一般而言,只有做VIP时,会想到做callbacks. typedef class uvm_reg; typed ...

  3. 最全的MySQL基础【燕十八传世】

    1.课前准备! 开启mysql服务:1).配置环境变量;2).net start mysql 将该sql文件导入到你的数据库中,以下所有操作都是基于该数据库表操作的!!! [此笔记是本人看着视频加上自 ...

  4. NeHe OpenGL教程 第四十八课:轨迹球

    转自[翻译]NeHe OpenGL 教程 前言 声明,此 NeHe OpenGL教程系列文章由51博客yarin翻译(2010-08-19),本博客为转载并稍加整理与修改.对NeHe的OpenGL管线 ...

  5. Python之路【第十八篇】:Web框架们

    Python之路[第十八篇]:Web框架们   Python的WEB框架 Bottle Bottle是一个快速.简洁.轻量级的基于WSIG的微型Web框架,此框架只由一个 .py 文件,除了Pytho ...

  6. COS访谈第十八期:陈天奇

    COS访谈第十八期:陈天奇 [COS编辑部按] 受访者:陈天奇      采访者:何通   编辑:王小宁 简介:陈天奇,华盛顿大学计算机系博士生,研究方向为大规模机器学习.他曾获得KDD CUP 20 ...

  7. 201771010126 王燕《面向对象程序设计(java)》第十八周学习总结

    实验十八  总复习 实验时间 2018-12-30 1.实验目的与要求 (1) 综合掌握java基本程序结构: (2) 综合掌握java面向对象程序设计特点: (3) 综合掌握java GUI 程序设 ...

  8. 马昕璐 201771010118《面向对象程序设计(java)》第十八周学习总结

    实验十八  总复习 实验时间 2018-12-30 1.实验目的与要求 (1) 综合掌握java基本程序结构: (2) 综合掌握java面向对象程序设计特点: (3) 综合掌握java GUI 程序设 ...

  9. Android为TV端助力 转载:Android绘图Canvas十八般武器之Shader详解及实战篇(上)

    前言 Android中绘图离不开的就是Canvas了,Canvas是一个庞大的知识体系,有Java层的,也有jni层深入到Framework.Canvas有许多的知识内容,构建了一个武器库一般,所谓十 ...

随机推荐

  1. CSS学习系列4 -- 再说CSS中的浮动运用及clear:left/right实际用法

    在 CSS学习系列2 -- CSS中的清除浮动 中,我们详细说了CSS中清除浮动的方法及使用 后来我自己在项目开发一个需要使用浮动的网页时,进行了实际运用,加上后来看到一篇好文章.所以就在这里再次写篇 ...

  2. Umbraco遇到的问题解决

    在本地VS2015运行公司的Corporate website时,有几个页面出现错误如下: 但事实是那个,这几个View都是存在的.弄了半天也没有能够解决.后来看到这个blog: https://ou ...

  3. 1.如何绕过WAF(Web应用防火墙)

    一:大小写转换法: 看字面就知道是什么意思了,就是把大写的小写,小写的大写.比如: SQL:sEleCt vERsIoN(); ‍‍XSS:)</script> 出现原因:在waf里,使用 ...

  4. PureUI(扩展版本)

    喜欢一个UI(pure,官网)不怎么更新(可能官方认为不需要更新).我自己做了扩展和修正,整个库下载地址:http://files.cnblogs.com/files/RainbowInTheSky/ ...

  5. Ocelot(二)- 请求聚合与负载均衡

    Ocelot(二)- 请求聚合与负载均衡 作者:markjiang7m2 原文地址:https://www.cnblogs.com/markjiang7m2/p/10865511.html 源码地址: ...

  6. Scrapy 框架进阶笔记

    上一篇简单了解了scrapy各个模块的功能:Scrapy框架初探 -- Dapianzi卡夫卡 在这篇通过一些实例来深入理解 scrapy 的各个对象以及它们是怎么相互协作的 settings.py ...

  7. 2017-10-18 NOIP模拟赛

    纸牌游戏 #include<iostream> #include<cstdio> #include<ctime> #include<cstdlib> # ...

  8. ios一个自定义的下拉多选菜单

    前段时间项目刚好要做到条件筛选菜单,正好找到一些别人写的,结合自己实际需求进行优化修改,一个实用的多条件筛选菜单,根据其他的下拉进行一些改进. 点击后返回点击文字显示 github地址:https:/ ...

  9. Linux调优(文件系统)

    查看单个文件是否发生碎片化(被存在磁盘非连续磁盘块上) # filefrag -v /var/log/messages 查看文件系统是否存在大量碎片(会显示空闲离散的块) # dumpe2fs /de ...

  10. [WebShow系列] Web浏览器最大化满屏及比例缩放方法

    如果要在大屏上展示,大屏所带电脑的浏览器应该处于满屏,此时就不会显示浏览器软件的边框了.个别浏览器在满屏状态下,某些边栏等还继续保留,此时应设置此浏览器的显示选项方可消除. 如果屏幕中的显示对象过小或 ...