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. Java基础之cmd入门操作笔记

    前提:jdk已安装且环境变量配置成功,参考上文jdk 安装及环境变量配置 入门操作步骤: 1.打开记事本或者notepad,编写Abc代码,具体如下: public class Abc{    pub ...

  2. storm启动supervisor源码分析-supervisor.clj

    supervisor是storm集群重要组成部分,supervisor主要负责管理各个"工作节点".supervisor与zookeeper进行通信,通过zookeeper的&qu ...

  3. 6.7 root和user之间的切换

  4. LeetCode第14题:最长公共前缀

    题目描述 编写一个函数来查找字符串数组中的最长公共前缀. 如果不存在公共前缀,返回空字符串 "". 示例 1: 输入: ["flower","flow ...

  5. 20169219 linux内核原理与分析第二周作业

    "linux内核分析"的第一讲主要讲了计算机的体系结构,和各寄存器之间对数据的处理过程. 通用寄存器 AX:累加器 BX:基地址寄存器 CX:计数寄存器 DX:数据寄存器 BP:堆 ...

  6. PS2018学习笔记(30-35节)

    30-35:万能的钢笔-制图抠图必学-part(1-6) # 本节知识点: 钢笔工具 贝塞尔曲线 绘图方式 光标状态认识 路径 形状 形状工具 矢量蒙版 # 本节段落表: 钢笔工具知识 直线绘制知识 ...

  7. 采用DCT进行图像压缩

    一.实验目的:熟悉变换编码的图像压缩方法 二.实验内容:以所给图像为例,采用dct进行图像压缩编码,通过改变模板矩阵中非零元素的个数,得到不同缩编码图像, 根据公式 ,编写程序计算原图像和dct变换后 ...

  8. 51nod1428(优先队列)

    题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1428 题意:中文题诶- 思路:贪心 问最少要多少教室就是求最多 ...

  9. Problem C: [noip2016十连测第五场]travel (构造+贪心)

    题面 https://www.lydsy.com/JudgeOnline/upload/201610/statements(1).pdf 题解 好神仙的贪心-- 首先无解的情况很容易判断,就是\(l= ...

  10. 洛谷 P2661 信息传递(并查集 & 最小环)

    嗯... 题目链接:https://www.luogu.org/problemnew/show/P2661 这道题和一些比较水的并查集不太一样,这道题的思路就是用并查集来求最小环... 首先,如果我们 ...