Uvm_reg_data_t and uvm_status_e compile error

Hi ,

I am going to use UVM register ,when I compile sequence ,a error comes :

** Warning: …/tb/seq_lib/register_seq_lib.sv(34): (vlog-2181) Use of a parameterized class uvm_reg_sequence as a type creates a default specialization.

** Error: …/tb/seq_lib/register_seq_lib.sv(51): near “reg_data”: syntax error, unexpected IDENTIFIER, expecting

the following is my source code :
##################################################
`include “uvm_macros.svh”
import uvm_pkg::*;

class user_test_seq extends uvm_reg_sequence;

`uvm_object_utils(user_test_seq)

reg_block_slave reg_model;

function new(string name=“user_test_seq”);
super.new(name);
endfunction : new

virtual task body();

$cast(reg_model, this.reg_model);
// Randomize the content of 10 random indexed registers
     
  uvm_reg_data_t reg_data;             //line 51
  uvm_status_e status;
  reg_model.SWRST.write(status, 'h33, .parent(this));

  reg_model.SWRST.read(status, reg_data);
  $display("read return reg_data is %h",reg_data);

endtask : body

endclass : user_test_seq
##################################################

The warning comes about because you are extending a parameterised sequence but not specifying the parameterisation - therefore it takes the default, which may or may not be OK depending on whether you meant to do that.

The error is due to a LRM issue. You need to declare the reg_data and status variables at the start of the body() method before you do anything:

virtual task body(); uvm_reg_data_t reg_data; uvm_status_e status;

$cast(reg_model, this.reg_model);
// Randomize the content of 10 random indexed registers
reg_model.SWRST.write(status, 'h33, .parent(this));

reg_model.SWRST.read(status, reg_data);
$display(“read return reg_data is %h”,reg_data);

endtask : body

In reply to mperyer:

Hi Mperyer

Thank you very much!

BR/Adams