Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
add support for evaluating the functions old and write inside the csr…
Browse files Browse the repository at this point in the history
…_comb coverpoints
  • Loading branch information
techiepriyansh committed Dec 10, 2022
1 parent 0530667 commit 080a6f9
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions riscv_isac/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ def compute_per_line(queue, event, cgf_queue, stats_queue, cgf, xlen, flen, addr
old_csr_regfile = {}
for i in csr_regfile.csr_regs:
old_csr_regfile[i] = int(csr_regfile[i],16)
def old(csr_reg):
def old_fn_csr_comb_covpt(csr_reg):
return old_csr_regfile[csr_reg]

instr.update_arch_state(arch_state, csr_regfile)
Expand All @@ -865,6 +865,18 @@ def old(csr_reg):
for i in csr_regfile.csr_regs:
instr_vars[i] = int(csr_regfile[i],16)

csr_write_vals = {}
if instr.csr_commit is not None:
for commit in instr.csr_commit:
if commit[0] == "CSR" and commit[3]:
csr_write_vals[commit[1]] = int(commit[3],16)
def write_fn_csr_comb_covpt(csr_reg):
if csr_reg in csr_write_vals:
return csr_write_vals[csr_reg]
else:
return int(csr_regfile[csr_reg],16)


if enable :
ucovpt = []
covpt = []
Expand Down Expand Up @@ -999,7 +1011,15 @@ def old(csr_reg):
break
if is_csr_commit:
for coverpoints in value['csr_comb']:
if eval(coverpoints, {"__builtins__":None}, instr_vars):
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:
Expand Down

0 comments on commit 080a6f9

Please sign in to comment.