Skip to content

Commit

Permalink
[dv/base_reg] use m_field instead of accessing field
Browse files Browse the repository at this point in the history
This PR does a quick updates to use m_fields in dv_base_reg instead of
acquiring uvm_base_reg_field using `get_fields()` method

Signed-off-by: Cindy Chen <[email protected]>
  • Loading branch information
cindychip authored and sriyerg committed Mar 4, 2021
1 parent 8a1726f commit 1e295f8
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions hw/dv/sv/dv_base_reg/dv_base_reg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,19 @@ class dv_base_reg extends uvm_reg;
endfunction : new

function void get_dv_base_reg_fields(ref dv_base_reg_field dv_fields[$]);
uvm_reg_field ral_fields[$];
get_fields(ral_fields);
foreach (ral_fields[i]) `downcast(dv_fields[i], ral_fields[i])
foreach (m_fields[i]) `downcast(dv_fields[i], m_fields[i])
endfunction

// get_n_bits will return number of all the bits in the csr
// while this function will return actual number of bits used in reg field
function uint get_n_used_bits();
uvm_reg_field fields[$];
get_fields(fields);
foreach (fields[i]) get_n_used_bits += fields[i].get_n_bits();
foreach (m_fields[i]) get_n_used_bits += m_fields[i].get_n_bits();
endfunction

// loop all the fields to find the msb position of this reg
function uint get_msb_pos();
uvm_reg_field fields[$];
get_fields(fields);
foreach (fields[i]) begin
uint field_msb_pos = fields[i].get_lsb_pos() + fields[i].get_n_bits() - 1;
foreach (m_fields[i]) begin
uint field_msb_pos = m_fields[i].get_lsb_pos() + m_fields[i].get_n_bits() - 1;
if (field_msb_pos > get_msb_pos) get_msb_pos = field_msb_pos;
end
endfunction
Expand Down

0 comments on commit 1e295f8

Please sign in to comment.