From 6cc64ed1ecb773844c466650e3149a66b65fbeb2 Mon Sep 17 00:00:00 2001 From: Priyansh Rathi Date: Sun, 11 Dec 2022 16:28:03 +0530 Subject: [PATCH] upgrade to tracking registers for evaulating csr_comb coverage instead of just instruction tracking --- riscv_isac/coverage.py | 54 ++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/riscv_isac/coverage.py b/riscv_isac/coverage.py index abfa0db..30d0b3f 100644 --- a/riscv_isac/coverage.py +++ b/riscv_isac/coverage.py @@ -992,14 +992,30 @@ def write_fn_csr_comb_covpt(csr_reg): cgf[cov_labels]['abstract_comb'][coverpoints] += 1 if 'csr_comb' in value and len(value['csr_comb']) != 0: - for coverpoints in value['csr_comb']: - if eval(coverpoints, {"__builtins__":None}, instr_vars): - if cgf[cov_labels]['csr_comb'][coverpoints] == 0: - ucovpt.append(str(coverpoints)) - if no_count: - hit_covpts.append((cov_labels, 'csr_comb', coverpoints)) - covpt.append(str(coverpoints)) - cgf[cov_labels]['csr_comb'][coverpoints] += 1 + if instr.csr_commit: + is_csr_commit = False + for commit in instr.csr_commit: + if commit[0] == "CSR": + is_csr_commit = True + break + if is_csr_commit: + for coverpoints in value['csr_comb']: + if eval( + coverpoints, + { + "__builtins__":None, + "old": old_fn_csr_comb_covpt, + "write": write_fn_csr_comb_covpt + }, + instr_vars + ): + if cgf[cov_labels]['csr_comb'][coverpoints] == 0: + ucovpt.append(str(coverpoints)) + if no_count: + hit_covpts.append((cov_labels, 'csr_comb', coverpoints)) + covpt.append(str(coverpoints)) + csr_covpt.append(str(coverpoints)) + cgf[cov_labels]['csr_comb'][coverpoints] += 1 elif 'opcode' not in value: if 'csr_comb' in value and len(value['csr_comb']) != 0: @@ -1035,16 +1051,24 @@ def write_fn_csr_comb_covpt(csr_reg): if hit_csr_covpt: stats.cov_pt_sig += covpt - csr_regs_involved_in_covpts = set() + csr_regs_involved_in_covpt = set() for covpt in csr_covpt: - for csr_reg in csr_reg_num_to_str.values(): - if csr_reg in covpt: - csr_regs_involved_in_covpts.add(csr_reg) + for reg in csr_reg_num_to_str.values(): + if reg in covpt: + csr_regs_involved_in_covpt.add(reg) - num_exp = len(csr_regs_involved_in_covpts) + num_exp = 0 + for reg in csr_regs_involved_in_covpt: + if reg in tracked_regs_immutable or reg in tracked_regs_mutable: + stat_meta = instr_stat_meta_at_addr[instr_addr_of_tracked_reg[reg]] + stat_meta[3] -= 1 # decrease num remaining + tracked_regs_immutable.discard(reg) + tracked_regs_mutable.discard(reg) + del instr_addr_of_tracked_reg[reg] - for i in range(num_exp): - tracked_instrs.append((['sd'] if xlen == 64 else ['sw'], instr.instr_addr)) + num_exp += 1 + instr_addr_of_tracked_reg[reg] = instr.instr_addr + tracked_regs_immutable.add(reg) instr_stat_meta_at_addr[instr.instr_addr] = [hit_uniq_covpt, num_exp, 0, num_exp, csr_covpt, [], [], []] elif hit_any_covpt: