一个简单的uvm_reg_model及其相关function介绍

    通常情况下,uvm_reg_model是uvm_reg集合,uvm_reg简单的示例如下所示:

     其中uvm_reg_field是寄存器内的域,在ral_reg_CFG_1内包含两个域,分别为CFG_1_0和CFG_1_1。其中,configure函数对域进行配置:

function void configure(
    uvm_reg        parent,    //指示field的parent uvm_reg
    int unsigned   size,      //指示field的bit size
    int unsigned   lsb_pos,   //指示该field的最低bit在uvm_reg的bit位置
    string         access,    //指示access策略,包括“RW”、“RO”等
    bit            volatile,  //
    uvm_reg_data_t reset,     //硬复位值
    bit            has_reset, //指示该字段是否确实会复位,如果为0则忽略复位值
    bit            is_rand,   //指示该字段是否可以随机化
    bit            individually_accessible  //指示该字段是否为唯一占用该字段
)

       一个简单的reg_model如下所示:

    create_map的函数原型如下所示,其功能是创建一个map。

virtual function uvm_reg_map create_map(
    string           name,                //map名
    uvm_reg_addr_t   base_addr,           //map基地址
    int unsigned     n_bytes,             //总线byte宽度
    uvm_endianness_e endian,              //指示字节排序格式
    bit              byte_addressing = 1  //地址递增方式是按照字节(1)还是按照n_bytes(0)
)

    uvm_reg的configure函数原型如下,设置了uvm_reg所属于的uvm_reg_block和uvm_reg_file;以及设置hdl路径;

function void configure (
    uvm_reg_block blk_parent,            //寄存器所属于的uvm_reg_block
    uvm_reg_file regfile_parent = null,  //寄存器所属于的uvm_reg_file
    string hdl_path = ""                 //指示DUT路径
)

    uvm_reg的add_hdl_path函数原型如下,设置uvm_reg_field的路径;

function void add_hdl_path (
    uvm_hdl_path_slice slices[],   //指示uvm_reg_field rtl路径
    string kind = "RTL"            
)

    uvm_reg_map的add_reg函数原型如下:

virtual function void add_reg (
    uvm_reg           rg,                //添加的寄存器
    uvm_reg_addr_t    offset,            //地址偏移
    string            rights = "RW",     //map指定该reg的访问权限
    bit               unmapped = 0,      //若为1则表示该寄存器不占用物理地址
    uvm_reg_frontdoor frontdoor = null
)

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
UVM (Universal Verification Methodology) provides a set of classes and macros to facilitate verification of hardware designs. One of the key components in UVM is the register model, which represents the registers and memories in the design. UVM provides a callback mechanism called UVM Callbacks (uvm_callbacks) to handle events and actions during the register access process. UVM register callbacks (uvm_reg_cbs) are a specific type of callback used for registering certain events related to register accesses. UVM register callbacks allow users to customize and extend the behavior of UVM register operations. These callbacks can be used to perform additional tasks before or after register read/write operations, such as logging, synchronization, or checking certain conditions. To use UVM register callbacks, you need to define a class derived from uvm_reg_callback and implement the desired callback methods. These methods will be called by UVM framework when corresponding events occur during register access. Here's an example of using UVM register callbacks: ```systemverilog class my_reg_callback extends uvm_reg_cbs; function new(string name = "my_reg_callback"); super.new(name); endfunction virtual function void pre_read(uvm_reg rg); // Perform pre-read tasks endfunction virtual function void post_read(uvm_reg rg); // Perform post-read tasks endfunction virtual function void pre_write(uvm_reg rg); // Perform pre-write tasks endfunction virtual function void post_write(uvm_reg rg); // Perform post-write tasks endfunction endclass // Register the callback with the desired register block my_reg_callback reg_cb = new(); my_register_block.my_register.add_callback(reg_cb); ``` In this example, `my_reg_callback` is a user-defined class derived from `uvm_reg_cbs`. It defines the callback methods `pre_read`, `post_read`, `pre_write`, and `post_write` which will be called by UVM framework at corresponding events. The callback object `reg_cb` is created and added to the desired register block using the `add_callback` method. This will enable the callback functionality for the specific register block. Please note that this is just a basic example, and there are more advanced features and options available for UVM register callbacks. The UVM User Guide provides detailed information on using and customizing register callbacks.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值