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. Linux 静态库(.a)转换为动态库(.so)

    Linux 静态库转换为动态库 参考 http://blog.csdn.net/moxuansheng/article/details/5812410 首先将.a文件转为.so文件是可以实现的 原因是 ...

  2. 8、泛型程序设计与c++标准模板库2.4列表容器

    列表容器主要用于存放链表,其中的链表是双向链表,可以从任意一端开始遍历.列表容器是需要按顺序访问的容器.另外,列表容器不支持随机访问迭代器,因此某些算法不能适合于列表容器.列表容器还提供了另一种操作- ...

  3. js 使用中一些需要提醒的点

    1.js 中可以直接使用输出java 变量 <script> var path = '<%=basePath%>'; 2.js重新注册事件后,如何让事件不自动执行? mzTxt ...

  4. UCD9222 EN1/EN2

    如果要使用UCD9222 EN1/EN2来控制每路电源的输出,那么需要注意实际是由PMBUS_CNTRL和EN1/EN2的与来控制每路的输出.

  5. redis系列:通过共同好友案例学习set命令

    前言 这一篇文章将讲述Redis中的set类型命令,同样也是通过demo来讲述,其他部分这里就不在赘述了. 项目Github地址:https://github.com/rainbowda/learnW ...

  6. 【TMF eTOM】eTOM的概念和术语

    eTOM的概念 为了有效地理解和使用eTOM业务流程框架,我们首先要理解构成eTOM的关键概念.这些概念使eTOM成为集成业务流程设计/评估与传统过程的一个非常有效的工具.在这些概念中使用了在本文中详 ...

  7. C++的STL总结(1)

    没有很系统的学过算法,c++也只是学些基础,虽然经常会用一些STL里面的函数,但是并没有对STL模板库有一个清晰的了解,趁着寒假有时间就自己在网上百度浏览别人的总结的内容,自己汇集并总结了一下,希望对 ...

  8. ios各个型号设备屏幕分辨率总结

    https://blog.csdn.net/amyloverice/article/details/79389357     iPhone: iPhone 1G 320x480 iPhone 3G 3 ...

  9. MCP|LQD|Data-independent acquisition improves quantitative cross-linking mass spectrometry (DIA方法可提升交联质谱定量分析)

    文献名:Data-independent acquisition improves quantitative cross-linking mass spectrometry (DIA方法可提升定量交联 ...

  10. AIDE,sudo,TCP_Wrappers,PAM认证等系统安全访问机制

    AIDE 高级入侵检测环境:是一个入侵检测工具,主要用途是检查文件的完整性,审计计算机上的那些文件被更改过了. AIDE能够构造一个指定文件的数据库,它使用aide.conf作为其配置文件.AIDE数 ...