Skip to content

Commit

Permalink
[dv] Add coverage for tl intg error with mem byte write
Browse files Browse the repository at this point in the history
Signed-off-by: Weicai Yang <[email protected]>
  • Loading branch information
weicaiyang committed Jul 21, 2021
1 parent c952dbc commit c5e5506
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 8 deletions.
49 changes: 41 additions & 8 deletions hw/dv/sv/cip_lib/cip_base_env_cov.sv
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ endgroup

class tl_errors_cg_wrap;
// This covergroup sampled all kinds of TL error cases.
covergroup tl_errors_cg (string ral_name)
covergroup tl_errors_cg (string name)
with function sample(bit unmapped_err,
bit csr_aligned_err,
bit csr_size_err,
Expand All @@ -91,7 +91,7 @@ class tl_errors_cg_wrap;
bit mem_ro_err,
bit tl_protocol_err);
option.per_instance = 1;
option.name = ral_name;
option.name = name;

// these cp should be disabled (set weight to 0), when they're not applicable for the block
cp_unmapped_err: coverpoint unmapped_err;
Expand All @@ -107,8 +107,8 @@ class tl_errors_cg_wrap;
endgroup

// Function: new
function new(string ral_name);
tl_errors_cg = new(ral_name);
function new(string name);
tl_errors_cg = new(name);
endfunction : new

// Function: sample
Expand All @@ -127,12 +127,12 @@ endclass

class tl_intg_err_cg_wrap;
// This covergroup sampled all kinds of TL integrity error and numbers of error bits.
covergroup tl_intg_err_cg (string ral_name) with function sample(tl_intg_err_e tl_intg_err_type,
covergroup tl_intg_err_cg (string name) with function sample(tl_intg_err_e tl_intg_err_type,
uint num_cmd_err_bits,
uint num_data_err_bits,
bit is_mem);
option.per_instance = 1;
option.name = ral_name;
option.name = name;

cp_tl_intg_err_type: coverpoint tl_intg_err_type;

Expand All @@ -146,8 +146,8 @@ class tl_intg_err_cg_wrap;
endgroup

// Function: new
function new(string ral_name);
tl_intg_err_cg = new(ral_name);
function new(string name);
tl_intg_err_cg = new(name);
endfunction : new

// Function: sample
Expand All @@ -159,6 +159,39 @@ class tl_intg_err_cg_wrap;
endfunction : sample
endclass

class tl_intg_err_mem_subword_cg_wrap;
// Design handles mem subword write specially. Add this CG to cover all types subword write
// with integrity errors
covergroup tl_intg_err_mem_subword_cg (string name) with function sample(
tl_intg_err_e tl_intg_err_type,
bit write,
int num_enable_bytes);
option.per_instance = 1;
option.name = name;

cp_tl_intg_err_type: coverpoint tl_intg_err_type;

cp_num_num_enable_bytes: coverpoint num_enable_bytes {
bins values[] = {[0:BUS_DW/8]};
}
cp_write: coverpoint write;

cr_all: cross cp_tl_intg_err_type, cp_num_num_enable_bytes, cp_write;
endgroup

// Function: new
function new(string name);
tl_intg_err_mem_subword_cg = new(name);
endfunction : new

// Function: sample
function void sample(tl_intg_err_e tl_intg_err_type,
uint write,
uint num_enable_bytes);
tl_intg_err_mem_subword_cg.sample(tl_intg_err_type, write, num_enable_bytes);
endfunction : sample
endclass

class cip_base_env_cov #(type CFG_T = cip_base_env_cfg) extends dv_base_env_cov #(CFG_T);
`uvm_component_param_utils(cip_base_env_cov #(CFG_T))

Expand Down
13 changes: 13 additions & 0 deletions hw/dv/sv/cip_lib/cip_base_scoreboard.sv
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class cip_base_scoreboard #(type RAL_T = dv_base_reg_block,
// covergroups
tl_errors_cg_wrap tl_errors_cgs_wrap[string];
tl_intg_err_cg_wrap tl_intg_err_cgs_wrap[string];
tl_intg_err_mem_subword_cg_wrap tl_intg_err_mem_subword_cgs_wrap[string];
`uvm_component_new

virtual function void build_phase(uvm_phase phase);
Expand Down Expand Up @@ -77,6 +78,11 @@ class cip_base_scoreboard #(type RAL_T = dv_base_reg_block,
tl_errors_cgs_wrap[ral_name].tl_errors_cg.cp_mem_ro_err.option.weight = 0;
end

if (has_mem) begin
tl_intg_err_mem_subword_cgs_wrap[ral_name] = new(
$sformatf("tl_intg_err_mem_subword_cgs_wrap[%0s]", ral_name));
end

if (cfg.en_tl_intg_gen) begin
tl_intg_err_cgs_wrap[ral_name] = new($sformatf("tl_intg_err_cgs_wrap[%0s]", ral_name));
if (!has_mem) tl_intg_err_cgs_wrap[ral_name].tl_intg_err_cg.cp_is_mem.option.weight = 0;
Expand Down Expand Up @@ -342,6 +348,13 @@ class cip_base_scoreboard #(type RAL_T = dv_base_reg_block,
cip_item.get_a_chan_err_info(tl_intg_err_type, num_cmd_err_bits, num_data_err_bits);
tl_intg_err_cgs_wrap[ral_name].sample(tl_intg_err_type, num_cmd_err_bits, num_data_err_bits,
is_mem_addr(item, ral_name));

if (tl_intg_err_mem_subword_cgs_wrap.exists(ral_name)) begin
tl_intg_err_mem_subword_cgs_wrap[ral_name].sample(
.tl_intg_err_type(tl_intg_err_type),
.write(item.a_opcode != tlul_pkg::Get),
.num_enable_bytes($countones(item.a_mask)));
end
end
end

Expand Down

0 comments on commit c5e5506

Please sign in to comment.