Skip to content

Add register callback support in UVM exporter #38

@antwon87

Description

@antwon87

It would be nice to be able to add a register callback class in the generated UVM RAL model, and associate it with a register. One use case that benefits from this is a counter register that is reset when a bit in another control register is written to. The callback gets associated with the control register so that when the reset bit is written, the RAL updates the desired and mirrored values of the counter register. This is possible to do outside of the RAL, but since the functionality is intrinsic to the register model, I think it's nice to include it right in the RAL.

Here's an abbreviated/pseudo-code example of how the callback class might look and where it gets instantiated in the register class.

class my_callback extends uvm_reg_cbs;

   {User-defined code for the class body.}
   {For the example use case, this would include a post-write method which calls
      predict() on the counter register to clear the mirrored and desired values.}

endclass: my_callback

class my_control_reg extends uvm_reg;

   {field declarations}

   function new(string name = "my_control_reg");
      super.new({args});
   endfunction: new

   virtual function void build();
      {field instantiations}

      // Instantiate the callback and associate it with this register
      my_callback reg_cb = new("my_callback");
      uvm_reg_cb::add(this, reg_cb);

   endfunction: build

endclass: my_control_reg

For the callback class, the user will probably want to define variables and implement one (or more?) of the methods from uvm_reg_cbs. The user could be given full control of the class and the ability to write out the full body, or they could be limited to adding those few things through separate commands while the tool still auto-generates common things like the new function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for Feature.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions