[UVM]不用寄存器模型(RAL Model)該怎麼讀寫寄存器呢?
标签: UVM [UVM]寄存器模型详解以及在SoC驗證中的应用
Register Access without RAL Model
In this section will see an example that shows one of the ways to access DUT registers without the UVM RAL Model.Let’s consider a DMA design which consists of registers in it and reg_interface is used to access the registers.
- 目录
一、Below is the block diagram of DMA.
二、Below are the DMA registers,
三、Below is the testbench block diagram,
3.1、The testbench component DMA agent is used to access the reg_interface.
7.4、Write and Read operation using defines
八、Accessing registers from TestCase
一、Below is the block diagram of DMA.

二、Below are the DMA registers,
- INTR
- CTRL
- IO ADDR
- MEM ADDR
Address of each register and register field description is given below,
三、Below is the testbench block diagram,

3.1、The testbench component DMA agent is used to access the reg_interface.
DMA Agent consists of,
- Driver
- Monitor
- Sequencer
- Sequences (Write sequence and Read Sequence)
3.2、In testbench,
- Write to the register is done by calling the write sequence
- Read of the register is done by calling the read sequence
This testbench is UVM based testbench. For ease understanding, only the sequence and test case is explained in this section. For detailed steps on writing UVM Testbench refer to UVM Testbench Architecture.
四、Base Sequence
class dma_sequence extends uvm_sequence#(dma_seq_item);
`uvm_object_utils(dma_sequence)
//---------------------------------------
//Constructor
//---------------------------------------
function new(string name = "dma_sequence");
super.new(name);
endfunction
`uvm_declare_p_sequencer(dma_sequencer)
//---------------------------------------
// create, randomize and send the item to driver
//---------------------------------------
virtual task body();
repeat(2) begin
req = dma_seq_item::type_id::create("req");
wait_for_grant();
req.randomize();
send_request(req);
wait_for_item_done();
end
endtask
endclass
五、Write Sequence
class write_sequence extends uvm_sequence#(dma_seq_item);
bit [31:0] t_addr,t_data;
`uvm_object_utils(write_sequence)
//---------------------------------------
//Constructor
//---------------------------------------
function new(string name = "write_sequence");
super.new(name);
endfunction
virtual task body();
`uvm_do_with(req,{req.wr_en==1;req.addr==t_addr;req.wdata==t_data;})
endtask
endclass
六、Read Sequence
class read_sequence extends uvm_sequence#(dma_seq_item);
bit [31:0] t_addr;
`uvm_object_utils(read_sequence)
//---------------------------------------
//Constructor
//---------------------------------------
function new(string name = "read_sequence");
super.new(name);
endfunction
virtual task body();
`uvm_do_with(req,{req.wr_en==0;req.addr==t_addr;})
endtask
endclass
七、Register Accessing
Write or Read operation to any SFR is done by calling the write or read sequence respectively.
7.1、Write Operation:
//Write to register INTR
wr_seq.t_addr = 32'h400;
wr_seq.t_data = 32'hFFFF_0F0F;
wr_seq.start(env.dma_agnt.sequencer);
//Write to register CTRL
wr_seq.t_addr = 32'h404;
wr_seq.t_data = 32'h1234_5678;
wr_seq.start(env.dma_agnt.sequencer);
//Write to register IO_ADDR
wr_seq.t_addr = 32'h408;
wr_seq.t_data = 32'hABCD_EF12;
wr_seq.start(env.dma_agnt.sequencer);
//Write to register MEM_ADDR
wr_seq.t_addr = 32'h40C;
wr_seq.t_data = 32'h9731_2345;
wr_seq.start(env.dma_agnt.sequencer);
7.2、Read Operation:
//Read from register INTR
rd_seq.t_addr = 32'h400;
rd_seq.start(env.dma_agnt.sequencer);
//Read from register CTRL
rd_seq.t_addr = 32'h404;
rd_seq.start(env.dma_agnt.sequencer);
//Read from register IO_ADDR
rd_seq.t_addr = 32'h408;
rd_seq.start(env.dma_agnt.sequencer);
//Read from register MEM_ADDR
rd_seq.t_addr = 32'h40C;
rd_seq.start(env.dma_agnt.sequencer);
In the above code, Register Address is assigned for register access. for the complex designs, the number of registers will be more. readability and debug will be difficult. to overcome this we can use define for register address.
7.3、Register address defines
`define INTR_SFR_ADDR 32'h400
`define CTRL_SFR_ADDR 32'h404
`define IO_ADDR_SFR_ADDR 32'h408
`define MEM_ADDR_SFR_ADDR 32'h40C
7.4、Write and Read operation using defines
- WRITE OPERATION
wr_seq.t_addr = `INTR_SFR_ADDR;
wr_seq.t_data = 32'hFFFF_0F0F;
wr_seq.start(env.dma_agnt.sequencer);
wr_seq.t_addr = `CTRL_SFR_ADDR;
wr_seq.t_data = 32'h1234_5678;
wr_seq.start(env.dma_agnt.sequencer);
wr_seq.t_addr = `IO_ADDR_SFR_ADDR;
wr_seq.t_data = 32'hABCD_EF12;
wr_seq.start(env.dma_agnt.sequencer);
wr_seq.t_addr = `MEM_ADDR_SFR_ADDR;
wr_seq.t_data = 32'h9731_2345;
wr_seq.start(env.dma_agnt.sequencer);
- READ OPERATION
rd_seq.t_addr = `INTR_SFR_ADDR;
rd_seq.start(env.dma_agnt.sequencer);
rd_seq.t_addr = `CTRL_SFR_ADDR;
rd_seq.start(env.dma_agnt.sequencer);
rd_seq.t_addr = `IO_ADDR_SFR_ADDR;
rd_seq.start(env.dma_agnt.sequencer);
rd_seq.t_addr = `MEM_ADDR_SFR_ADDR;
rd_seq.start(env.dma_agnt.sequencer);
八、Accessing registers from TestCase
class dma_reg_test extends uvm_test;
`uvm_component_utils(dma_reg_test)
//---------------------------------------
// env instance
//---------------------------------------
dma_model_env env;
//---------------------------------------
// sequence instance
//---------------------------------------
write_sequence wr_seq;
read_sequence rd_seq;
//---------------------------------------
// constructor
//---------------------------------------
function new(string name = "dma_reg_test",uvm_component parent=null);
super.new(name,parent);
endfunction : new
//---------------------------------------
// build_phase
//---------------------------------------
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
// Create the env
env = dma_model_env::type_id::create("env", this);
// Create the sequence
wr_seq = write_sequence::type_id::create("wr_seq");
rd_seq = read_sequence::type_id::create("rd_seq");
endfunction : build_phase
//---------------------------------------
// end_of_elobaration phase
//---------------------------------------
virtual function void end_of_elaboration();
//print's the topology
print();
endfunction
//---------------------------------------
// run_phase - starting the test
//---------------------------------------
task run_phase(uvm_phase phase);
phase.raise_objection(this);
wr_seq.t_addr = `INTR_SFR_ADDR;
wr_seq.t_data = 32'hFFFF_0F0F;
wr_seq.start(env.dma_agnt.sequencer);
wr_seq.t_addr = `CTRL_SFR_ADDR;
wr_seq.t_data = 32'h1234_5678;
wr_seq.start(env.dma_agnt.sequencer);
wr_seq.t_addr = `IO_ADDR_SFR_ADDR;
wr_seq.t_data = 32'hABCD_EF12;
wr_seq.start(env.dma_agnt.sequencer);
wr_seq.t_addr = `MEM_ADDR_SFR_ADDR;
wr_seq.t_data = 32'h9731_2345;
wr_seq.start(env.dma_agnt.sequencer);
rd_seq.t_addr = `INTR_SFR_ADDR;
rd_seq.start(env.dma_agnt.sequencer);
rd_seq.t_addr = `CTRL_SFR_ADDR;
rd_seq.start(env.dma_agnt.sequencer);
rd_seq.t_addr = `IO_ADDR_SFR_ADDR;
rd_seq.start(env.dma_agnt.sequencer);
rd_seq.t_addr = `MEM_ADDR_SFR_ADDR;
rd_seq.start(env.dma_agnt.sequencer);
phase.drop_objection(this);
endtask : run_phase
endclass : dma_reg_test
- Simulator output
UVM_INFO @ 0: reporter [RNTST] Running test dma_reg_test…
—————————————————————-
Name Type Size Value
—————————————————————-
uvm_test_top dma_reg_test – @1881
env dma_model_env – @1949
dma_agnt dma_agent – @2017
driver dma_driver – @2128
rsp_port uvm_analysis_port – @2200
seq_item_port uvm_seq_item_pull_port – @2163
monitor dma_monitor – @2048
item_collected_port uvm_analysis_port – @2095
sequencer dma_sequencer – @2231
rsp_export uvm_analysis_export – @2276
seq_item_export uvm_seq_item_pull_imp – @2686
arbitration_queue array 0 –
lock_queue array 0 –
num_last_reqs integral 32 ‘d1
num_last_rsps integral 32 ‘d1
—————————————————————-
UVM_INFO /playground_lib/uvm-1.2/src/base/uvm_objection.svh(1271) @ 195: reporter [TEST_DONE]
UVM_INFO /playground_lib/uvm-1.2/src/base/uvm_report_server.svh(847) @ 195: reporter
— UVM Report Summary —
** Report counts by severity
UVM_INFO : 3
UVM_WARNING : 0
UVM_ERROR : 0
UVM_FATAL : 0
** Report counts by id
[RNTST] 1
[TEST_DONE] 1
[UVM/RELNOTES] 1
智能推荐
记一次C/S架构的渗透测试
概述 目标站点是http://www.example.com,官网提供了api使用文档,但是对其测试后没有发现漏洞,目录、端口扫描等都未发现可利用的点。后发现官网提供了客户端下载,遂对其进行一番测试。 信息收集 先抓了下客户端的包,使用Fiddler和BurpSuite都抓不到,怀疑走的不是HTTP协议,用WireShark查看其确实用的是HTTP协议,但是数据包不好重放,这里最后使用了WSExp...
Linux:结合Securecrt进行文件上传(lrzsz)P2
1、安装rzsz软件 2、点击Scurecrt的option——X/Y/Z配置上传和下载目录 3、首先在Linux里切换到一个目录,然后用rz命令,文件就会上传到钙Linux的目录下 只要敲rz即可,然后在弹出的对话框里选择需要上传的文件即可 4、下载文件用sz 下载单个文件:在当前目录下有该文件 sz filename 下载...
SQL 提示作为 布局 生存工具指南
下面是一些展示AdventureWorks中表现最好的销售人员并列出他们的经理的结构化查询语言代码。 它产生以下结果。 所以,代码是有效的,但它是丑陋的。 如果我需要理解和改进代码,我首先需要把它变成可读的形式。 我有结构化查询语言提示,所以我可以按下计算机的ctrl按键键 踢你自己),它会应用默认的内置代码样式,并对此进行修复。 不,不是,因为我相信你仍然不喜欢它的格式。 没有两个开发人员能够就...
Vue+Springboot解决数据传输时参数格式不匹配问题
前端:使用的是ant design vue ,端口号为8000 后端:使用的是springboot框架开发,端口号为8080 需求:已经解决跨域问题,前端发送登录的信息给后台,后台接收不到 样例: 前端: 后台: 请求的数据格式为json格式,后台参数类型不匹配 解决方案 第一种: 修改后端,参数类型: 第二种方式: 在前端vue框架中加入qs插件,qs 是一个增加了一些安全性的查询字符串解析和序...
Flex布局做出自适应页面--语法和案例
本文发布在: github项目地址:https://github.com/tenadolanter/flex-layout-demo SegmentFault地址:https://segmentfault.com/a/1190000012916949/ CSDN地址:http://blog.csdn.net/qq_34648000/article/details/79115294 博客园地址:ht...
猜你喜欢
Java - 基于 Apache POI 创建 Excel 文件
基于 Apache POI 创建 Excel 文件 准备 新建 Maven Project,引入依赖: 创建行和列 设置列宽 设置列宽(第 19 行): 注意:其他行的首列的宽度是受第一行、第一列的影响而变宽,并非我们设置的。 设置字体颜色 设置字体颜色(第 25 ~ 31 行): 设置网页超链接 设置网页超链接(第 18、27 ~ 29 行): 参考 java操作excel常用的两种方式...
python基础-质数判断及优化
文章目录 一、问题描述 二、代码 三、问题2优化 四、数学补充 一、问题描述 质数判断条件: 质数是只能被1和它自身整除的数,1不是质数也不是合数。 二、代码 问题1代码 问题2代码 三、问题2优化 优化方案: 模块,通过模块可以对Python进行扩展 引入一个time模块,来统计程序执行的时间 time()函数可以用来获取当前的时间,返回的单位是秒 获取程序开始的时间,以运行时间来衡量优化结果。...
部署jenkins+svn持续集成
部署环境:CentOS7+jdk8 svn版本是windows,jenkins是linux 然后下载jenkins的yum源文件,获取jenkins的下载** 输入本机ip+端口,然后在这个web界面显示的路径里把**复制出来,下一步后选择推荐插件安装,后面需要用的插件可以再安装,等待安装完成后,第一次登陆不需要密码,可以设置登陆用户。 然后配置全局设置 如果你是yum安装得git,按照我得写,如...
7 パズル 反向BFS
题目 题意:7数码问题。在2×4的棋盘上,摆有7个棋子,每个棋子上标有1至7的某一数字,不同棋子上标的数字不相同。棋盘还有一个空格(用0表示),与空格相邻(上下左右)的棋子可以移到空格中,该棋子原先位置成为空格。给出一个初始 (保证可以转移到最终状态),找出一种从初始状态转变成给定最终状态的移动棋子步数最少的移动步骤。 输入:多组输入,每组8个数,表示初始状态前四个数为第一行从左到右,...
代理模式真得这么简单
代理模式真得这么简单 代理模式的定义 为另一个对象提供一个替身或占位符以控制对这个对象的访问 代理模式类图 简单描述就是真实对象,RealSubject,和代理对象,Proxy实现同一个接口Subect,并且代理对象Proxy持有真实对象的引用 静态代理实例 GumballMachine,作为真实对象 GumballMonitor,作为代理对象,控制对真实对象的访问 Main函数 动态代理实例 j...
