使用burst_read/write和寄存器模型 [英] Using burst_read/write with register model

查看:77
本文介绍了使用burst_read/write和寄存器模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 16 个寄存器的寄存器空间.这些可通过串行总线(单次和突发)访问.我已经为这些寄存器定义了 UVM reg 模型.但是没有一个reg模型方法支持总线上的突发事务.

I've a register space of 16 registers. These are accessible through serial bus (single as well as burst). I've UVM reg model defined for these registers. However none of the reg model method supports burst transaction on bus.

作为一种解决方法

  1. 我可以为相同的空间声明内存模型,每当我需要突发访问时,我都会使用内存模型,但为同一事物声明 2 个单独的类似乎是多余的,而且这种方法不会正确反映寄存器值.
  2. 创建一个函数,该函数循环字节数迭代并逐个访问寄存器,但此方法不会在总线上创建突发事务.

所以我想知道是否有一种方法可以使用带有寄存器模型的burst_read和burst_write方法.如果burst_read 和burst_write 支持镜像就好了(当前的实现不支持这个),但如果不支持,我可以使用.predict 和.set 所以它不是大问题.

So I would like to know if there is a way to use burst_read and burst_write methods with register model. It would be nice if burst_read and burst_write support mirroring (current implementation doesn't support this) but if not I can use .predict and .set so its not big concern.

或者我可以轻松实现寄存器模型的方法来支持突发操作.

Or can I implement a method for register model easily to support burst operation.

推荐答案

在结合 Tudor 提供的意见和讨论中的链接后,这里是向 reg 模型添加突发操作的方法.

After combining opinions provided by Tudor and links in the discussion, here is what works for adding burst operation to reg model.

此实现并未显示所有代码,而仅显示添加突发操作所需的部分,我已使用串行协议 (SPI/I2C) 对其进行了读写操作测试.寄存器模型值正确更新以及 RTL 寄存器更新.

This implementation doesn't show all the code but only required part for adding burst operation, I've tested it for write and read operation with serial protocols (SPI / I2C). Register model values are updated correctly as well as RTL registers are updated.

创建一个类来保存数据和突发长度:

Create a class to hold data and burst length:

class burst_class extends uvm_object;
 `uvm_object_utils (....);

  int burst_length;
  byte data [$];

  function new (string name);
    super.new(name);
  endfunction

endclass

内部寄存器序列(用于读取不初始化数据)

Inside register sequence (for read don't initialize data)

burst_class obj;
obj = new ("burstInfo");

obj.burst_length = 4; // replace with actual length
obj.data.push_back (data1);
obj.data.push_back (data2);
obj.data.push_back (data3);
obj.data.push_back (data4);

start_reg.read (status,...., .extension(obj));
start_reg.write (status, ...., .extension (obj));

操作成功后数据值应该写入或收集到obj对象中在适配器类中(reg2bus 更新为写入,bus2reg 更新为读取)reg2bus 中除了读取的数据外,所有关于事务的信息都可用.

After successful operation data values should be written or collected in obj object In adapter class (reg2bus is updated for write and bus2reg is updated for read) All the information about transaction is available in reg2bus except data in case of read.

适配器类uvm_reg_item start_reg;int burst_length;burst_class adapter_obj;

adapter class uvm_reg_item start_reg; int burst_length; burst_class adapter_obj;

reg2bus 实现

  start_reg = this.get_item;
  adapter_obj = new ("adapter_obj");

  if($cast (adapter_obj, start_reg.extension)) begin
     if (adapter_obj != null) begin
        burst_length     = adapter_obj.burst_length;
     end
     else
        burst_length              = 1; /// so that current implementation of adapter still works
  end

这里根据burst_length更新事务大小并正确分配数据.至于读取bus2reg需要更新

Update the size of transaction over here according to burst_length and assign data correctly. As for read bus2reg needs to be updated

bus2reg 实现(已经拥有所有控制信息,因为 reg2bus 总是在 bus2reg 之前执行,使用在 reg2bus 中捕获的值)

bus2reg implementation (Already has all control information since reg2bus is always executed before bus2reg, use the values captured in reg2bus)

根据burst_length只将数据分配给通过扩展传递的对象,在这种情况下adapter_obj

According to burst_length only assign data to object passed though extension in this case adapter_obj

这篇关于使用burst_read/write和寄存器模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆