# Backdoor Access for a packed Structure of different register and an unpacked multi-dimension array of register

**URL:** <https://verificationacademy.com/forums/t/backdoor-access-for-a-packed-structure-of-different-register-and-an-unpacked-multi-dimension-array-of-register/37418>\
**Category:** UVM\
**Tags:** UVM, Backdoor\_access-HDL-access-methods\
**Created:** [April 9, 2020, 9:16am UTC](https://verificationacademy.com/forums/t/backdoor-access-for-a-packed-structure-of-different-register-and-an-unpacked-multi-dimension-array-of-register/37418 "2020-04-09T09:16:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhishek\_kumar\_Diwakar](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/abhishek_kumar_diwakar/32/2689_2.png) [@Abhishek\_kumar\_Diwakar](https://verificationacademy.com/forums/u/Abhishek_kumar_Diwakar)\
**Post date:** [April 9, 2020, 9:16am UTC](https://verificationacademy.com/forums/t/backdoor-access-for-a-packed-structure-of-different-register-and-an-unpacked-multi-dimension-array-of-register/37418/1 "2020-04-09T09:16:05Z")

</div>

Hi all,  
I am working on the validation of backdoor access method and for a design having **structure** of register. I need to use backdoor accessing support routines i.e. uvm\_hdl\_deposit and uvm\_hdl\_read. I am able to read and write the register on the RTL side. However, when I am reading their corresponding values from the register model of Testbench their values returned is 0 always what could be the reason for this. Also, If possible please help me in clarifying **how to access the multidimensional array of register through register backdoor access**.

Thanks in advance for the help.

The corresponding design code of seq is specified below:  
RTL code:

* * *

module slave(apb\_dut\_if apb,  
input bit rst);

reg [31:0] pr\_data;  
assign apb.prdata = (apb.psel && apb.penable && !apb.pwrite) ? pr\_data : 'z;

**typedef struct {  
reg [63:0] SRC;  
reg [63:0] DST;  
} socket\_t;**

* * *

Top level Module  
module tb\_top;  
…//other lines  
slave dut(dapb, rst);  
…//other lines  
endmodule: tb\_top

* * *

My used seq code (snippet)

* * *

```
// Implemanting uvm_hdl_deposit and uvm_hdl_read method on a packed struct.

```

#100;  
begin  
string path=“tb\_top.dut.SESSION[%0d].SRC”;  
burst\_data = 64’hABCD\_ABCD\_ABCD\_ABCD;  
begin  
uvm\_hdl\_deposit($sformatf(path,10),burst\_data);  
assert(status == UVM\_IS\_OK);  
end

```
       begin
         uvm_hdl_read($sformatf(path,10),read_data);
         assert(status == UVM_IS_OK);
       end
         assert(read_data == burst_data) $info("SRC variable data = %0h SRC variable expected = %0h", read_data,burst_data);
     else $warning("data = %0h expected = %0h", read_data,burst_data);
    end
   `uvm_info(get_type_name(), $sformatf("At READ desired=0x%0h mirrored=0x%0h", model.SESSION[10].SRC.get(), model.SESSION[10].SRC.get_mirrored_value()), UVM_MEDIUM)    

```

#100;  
begin  
string path=“tb\_top.dut.SESSION[%0d].DST”;  
burst\_data = 64’hFAFA\_FAFA\_FAFA\_FAFA;  
begin  
**uvm\_hdl\_deposit($sformatf(path,10),burst\_data);**  
assert(status == UVM\_IS\_OK);  
end  
begin  
**uvm\_hdl\_read($sformatf(path,10),read\_data);**  
assert(status == UVM\_IS\_OK);  
end  
assert(read\_data == burst\_data) $info(“DST variable data = %0h DST variable expected = %0h”, read\_data,burst\_data);  
else $warning(“data = %0h expected = %0h”, read\_data,burst\_data);  
end  
`uvm\_info(get\_type\_name(), $sformatf(“At READ desired=0x%0h mirrored=0x%0h”, model.SESSION[10].DST.get(), model.SESSION[10].DST.get\_mirrored\_value()), UVM\_MEDIUM) //getting value 0

* * *

**Snippet of RAL model related sub codes**

class ral\_reg\_SOCKET extends uvm\_reg;  
rand uvm\_reg\_field IP;  
rand uvm\_reg\_field PORT;

```
function new(string name = "SOCKET");
    super.new(name, 64,build_coverage(UVM_NO_COVERAGE));
endfunction: new

```

virtual function void build();  
this.IP = uvm\_reg\_field::type\_id::create(“IP”,get\_full\_name());  
this.IP.configure(this, 48, 0, “RW”, 0, 48’h0, 1, 0, 1);  
this.PORT = uvm\_reg\_field::type\_id::create(“PORT”,get\_full\_name());  
this.PORT.configure(this, 16, 48, “RW”, 0, 16’h0, 1, 0, 1);  
add\_hdl\_path\_slice(.name(“socket\_t.SRC”), .offset(0), .size(64),.first(1)); **//Is it correct to add hdl path like this for backdoor access?**  
add\_hdl\_path\_slice(.name(“socket\_t.DST”), .offset(8), .size(64),.first(1)); **//Is it correct to add hdl path like this for backdoor access?**  
endfunction: build

```
`uvm_object_utils(ral_reg_SOCKET)

```

endclass : ral\_reg\_SOCKET

class ral\_regfile\_SESSION extends uvm\_reg\_file;  
uvm\_reg regs[$];  
rand ral\_reg\_SOCKET SRC;  
rand ral\_reg\_SOCKET DST;  
rand uvm\_reg\_field SRC\_IP;  
rand uvm\_reg\_field SRC\_PORT;  
rand uvm\_reg\_field DST\_IP;  
rand uvm\_reg\_field DST\_PORT;

```
function new(string name = "SESSION");
    super.new(name);
endfunction : new

virtual function void build();
    this.SRC = ral_reg_SOCKET::type_id::create("SRC",,get_full_name());
    this.SRC.configure(get_block(), this, "");
    this.SRC.build();
    this.SRC.add_hdl_path_slice("SESSION.SRC",0,64); **//Is it correct to add hdl path like this for backdoor access?**
    this.SRC_IP = this.SRC.IP;
    this.SRC_PORT = this.SRC.PORT;
    this.regs.push_back(SRC);
    this.DST = ral_reg_SOCKET::type_id::create("DST",,get_full_name());
    this.DST.configure(get_block(), this, "");
    this.DST.build();
    this.DST.add_hdl_path_slice("SESSION.DST",0,64); **//Is it correct to add hdl path like this for backdoor access?**
    this.DST_IP = this.DST.IP;
    this.DST_PORT = this.DST.PORT;
    this.regs.push_back(DST);
endfunction : build

virtual function void map(uvm_reg_map mp,
                          uvm_reg_addr_t offset);
  mp.add_reg(SRC, offset+`UVM_REG_ADDR_WIDTH'h0);
  mp.add_reg(DST, offset+`UVM_REG_ADDR_WIDTH'h2);

endfunction

virtual function void set_offset(uvm_reg_map mp,
                                   uvm_reg_addr_t offset);
  SRC.set_offset(mp, offset+`UVM_REG_ADDR_WIDTH'h0);
  DST.set_offset(mp, offset+`UVM_REG_ADDR_WIDTH'h2);
endfunction

`uvm_object_utils(ral_regfile_SESSION)

```

endclass : ral\_regfile\_SESSION

```
foreach (this.SESSION[i]) begin
     int J = i;
     this.SESSION[J] = ral_regfile_SESSION::type_id::create($psprintf("SESSION[%0d]",J),,get_full_name());
    this.SESSION[J].configure(this, null, "");
    this.SESSION[J].build();
          this.SESSION[J].add_hdl_path("SESSION[J]");
  this.SESSION[J].map(default_map, `UVM_REG_ADDR_WIDTH'h1000+`UVM_REG_ADDR_WIDTH'h4 * J); **// AM I doing something wrong here ?**
  end

```

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [April 9, 2020, 2:18pm UTC](https://verificationacademy.com/forums/t/backdoor-access-for-a-packed-structure-of-different-register-and-an-unpacked-multi-dimension-array-of-register/37418/2 "2020-04-09T14:18:31Z")

</div>

_In reply to [Abhishek kumar Diwakar](https://verificationacademy.com/forums/t/backdoor-access-for-a-packed-structure-of-different-register-and-an-unpacked-multi-dimension-array-of-register/37418):_  
uvm\_hdl\_deposit and uvm\_hdl\_read are not specific register backdoor routines. They can be used in any place also without a register model.

The uvm\_hdl\_read/uvm\_hdl\_deposit are restricte to integral data types.  
See the definition of

```verilog
function int uvm_hdl_deposit(string path, uvm_hdl_data_t value);

```

```verilog
uvm_hdl_data_t

```

is the following

```verilog
typedef logic [UVM_HDL_MAX_WIDTH-1:0] uvm_hdl_data_t;

```

Did you check the HDL path? Does it exist?. If the return value is 0 this ccould be an inducation it is wrong/incomplete.  
You can use

```verilog
uvm_hdl_check_path

```

to check the path

---

<div class="post-metadata">

**Author:** ![Abhishek\_kumar\_Diwakar](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/abhishek_kumar_diwakar/32/2689_2.png) [@Abhishek\_kumar\_Diwakar](https://verificationacademy.com/forums/u/Abhishek_kumar_Diwakar)\
**Post date:** [April 10, 2020, 8:10am UTC](https://verificationacademy.com/forums/t/backdoor-access-for-a-packed-structure-of-different-register-and-an-unpacked-multi-dimension-array-of-register/37418/3 "2020-04-10T08:10:51Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/backdoor-access-for-a-packed-structure-of-different-register-and-an-unpacked-multi-dimension-array-of-register/37418/2):_

Thanks for your reply as you mentioned “The uvm\_hdl\_read/uvm\_hdl\_deposit is restricted to integral data types.” I must clarify that my value data(burst\_data and read\_data) are of uvm\_hdl\_data\_t. Also, as you told me to check the HDL path I have done that and that is also giving me the return value 1. So, I can say Path provided is correct. The used code to check this given below.  
The problem I am facing is with the testbench environment RAL model side at the DUT side these access methods are working fine but when I am trying to check the updated value through register I am not able to get the value.

**New seq code to check path provided is correct or not**  
#100;  
begin  
string path=“tb\_top.dut.SESSION[%0d].SRC”;  
burst\_data = 64’hABCD\_ABCD\_ABCD\_ABCD;  
begin  
uvm\_hdl\_deposit($sformatf(path,10),burst\_data);  
assert(status == UVM\_IS\_OK);  
end

```
       begin
         uvm_hdl_read($sformatf(path,10),read_data);
         assert(status == UVM_IS_OK);
       end
         assert(read_data == burst_data) $info("SRC variable data = %0h SRC variable expected = %0h", read_data,burst_data);
     else $warning("data = %0h expected = %0h", read_data,burst_data);
    end
   `uvm_info(get_type_name(), $sformatf("At READ desired=0x%0h mirrored=0x%0h", model.SESSION[10].SRC.get(), model.SESSION[10].SRC.get_mirrored_value()), UVM_MEDIUM)    

```

#100;  
begin  
string path=“tb\_top.dut.SESSION[%0d].DST”;  
burst\_data = 64’hFAFA\_FAFA\_FAFA\_FAFA;  
begin  
if(uvm\_hdl\_check\_path($sformatf(path,10)))begin  
**$display(“PATH checking successful”);**  
end  
else  
**$display(“PATH Provided Invalid”);**

```
         uvm_hdl_deposit($sformatf(path,10),burst_data);
         assert(status == UVM_IS_OK);
       end
       begin
         uvm_hdl_read($sformatf(path,10),read_data);
         assert(status == UVM_IS_OK);
       end
         assert(read_data == burst_data) $info("DST variable data = %0h DST variable expected = %0h", read_data,burst_data);
     else $warning("data = %0h expected = %0h", read_data,burst_data);
end
   `uvm_info(get_type_name(), $sformatf("At READ desired=0x%0h mirrored=0x%0h", model.SESSION[10].DST.get(), model.SESSION[10].DST.get_mirrored_value()), UVM_MEDIUM) 

```

Output:  
**PATH checking successful**
