Jump to content

Bug in UVM code using byte_en?


Recommended Posts

I found an issue with byte_en signal. My RAL model is defined as following:

                   test_reg[31:0]: fld0[1:0], fld1[9:2]

”test_reg” is 32bits. The “fld0” at bit[1:0], “fld1” at bit[9:2], other bits are reserved.

I am using a AHB bus monitor connecting to my RAL model through uvm_reg_predictor. Using my AHB master driver (not using register model), I did following sequence:

1. Write all 1’s to the register. 

2. Write all 0’s to the register but with byte_en set to 4’b0001.

3. Then I read the register, expecting DUT and RAL to give 32’h30. But I get a compare error from RAL.  This is unexpected. 

In step 1, my register value is 32’h3f. Then, in step 2, because I am only updating a byte, I am expecting the register value to be 32’h30 in test_reg. In step 3, the compare_on_read show that the register value in RAL is actually 32’h0 instead of 32’h30. Obviously, byte_en is not honored in UVM prediction code. 

 

Upon further investigation, I found following code in uvm_reg_field that contributed to the error:

// do_predict

function void uvm_reg_field::do_precit(rvm_reg_item rw, …………….., uvm_reg_byte_en_t be = -1);

if(rw.path == UVM_FRONTDOOR || rw.path == UVM_PREDICT)

          field_val = XpredictX(m_mirrored, field_val, rw.map);

Here field_val is not considering “be”. For field_val to updated correctly, we need to take “be” into consideration. Otherwise for the case, current code will update the whole field and give an incorrect expect value of 32’h0. Here is the proposed fix for this issue.

// do_predict

function void uvm_reg_field::do_precit(rvm_reg_item rw, …………….., uvm_reg_byte_en_t be = -1);

// Add following lines to fix the problem.

for(int I=0; i<$size(m_mirrored); i++) begin

   Int orrigin_idx = i+get_lsb_pos(); // origin_idx is the location of the bit in the register, before shifting the field.

   If(!be[origin_idx/8])    // this will look at the corresponding byte enable bit.

         Field_val[i] = m_mirrored[i]; // if the bit is not enabled, we will not update it.

end

if(rw.path == UVM_FRONTDOOR || rw.path == UVM_PREDICT)

          field_val = XpredictX(m_mirrored, field_val, rw.map);

 

Similar issue also exists in uvm_reg_predictor. After applying the fix, we are getting correct value on partial field updates.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...