[dv] Coverage fixes

Makes coverage work for VCS and XLM.

Signed-off-by: Canberk Topal <ctopal@lowrisc.org>
This commit is contained in:
Canberk Topal 2022-04-26 16:42:50 +01:00 committed by Rupert Swarbrick
parent 4db6d15def
commit 3ad3bd0d71
5 changed files with 38 additions and 30 deletions

View file

@ -85,12 +85,6 @@ RUN-DIR := $(OUT-DIR)run
# get printed when VERBOSE.
verb = $(if $(filter-out 0,$(VERBOSE)),,@)
# Convert VERBOSE, COV, WAVE and COSIM to "store_true" arguments
verb-arg := $(if $(filter-out 0,$(VERBOSE)),--verbose,)
cov-arg := $(if $(call equal,$(COV),1),--en_cov,)
wave-arg := $(if $(call equal,$(WAVES),1),--en_wave,)
cosim-arg := $(if $(call equal,$(COSIM),1),--en_cosim,)
SHELL=/bin/bash
export PRJ_DIR := $(realpath ../../..)
@ -175,6 +169,12 @@ FORCE:
# Call it as $(call vars-prereq,X,TGT,VS)
vars-prereq = $(if $(call vars-differ,$(call strip,$(1)),$(2),$(3)),FORCE,)
# Convert VERBOSE, COV, WAVE and COSIM to "store_true" arguments
verb-arg := $(if $(filter-out 0,$(VERBOSE)),--verbose,)
cov-arg := $(if $(call equal,$(COV),1),--en_cov,)
wave-arg := $(if $(call equal,$(WAVES),1),--en_wave,)
cosim-arg := $(if $(call equal,$(COSIM),1),--en_cosim,)
###############################################################################
# Get a list of tests and seeds
#
@ -355,11 +355,12 @@ $(BUILD-DIR)/tb/.compile.stamp: \
$(tb-compile-vars-prereq) $(all-verilog) $(risc-dv-files) \
scripts/compile-tb.py yaml/rtl_simulation.yaml \
| $(BUILD-DIR)
$(verb)scripts/compile-tb.py \
$(verb-arg) \
--ibex-config $(IBEX_CONFIG) \
--output=$(BUILD-DIR)/tb \
--simulator=$(SIMULATOR) \
$(verb)scripts/compile-tb.py \
$(verb-arg) \
--ibex-config $(IBEX_CONFIG) \
--output=$(BUILD-DIR)/tb \
--shared-cov-dir=$(RUN-DIR)/shared_cov \
--simulator=$(SIMULATOR) \
$(cov-arg) $(wave-arg) $(cosim-arg)
$(call dump-vars,$(tb-compile-vars-path),comp,$(tb-compile-var-deps))
@touch $@
@ -376,14 +377,15 @@ $(rtl-sim-logs): \
$(RUN-DIR)/%/rtl.log: \
$(BUILD-DIR)/tb/.compile.stamp $(RUN-DIR)/%/test.bin scripts/run-rtl.py
@echo Running RTL simulation at $@
$(verb)scripts/run-rtl.py \
--ibex-config $(IBEX_CONFIG) \
--simulator $(SIMULATOR) \
$(cov-arg) $(wave-arg) \
--signature-addr $(SIGNATURE_ADDR) \
--test-dot-seed $* \
--binary $(RUN-DIR)/$*/test.bin \
--rtl-sim-dir $(BUILD-DIR)/tb \
$(verb)scripts/run-rtl.py \
--ibex-config $(IBEX_CONFIG) \
--simulator $(SIMULATOR) \
--shared-cov-dir=$(RUN-DIR)/shared_cov \
$(cov-arg) $(wave-arg) \
--signature-addr $(SIGNATURE_ADDR) \
--test-dot-seed $* \
--binary $(RUN-DIR)/$*/test.bin \
--rtl-sim-dir $(BUILD-DIR)/tb \
--out-dir $(@D)
.PHONY: rtl_sim_run

View file

@ -19,6 +19,7 @@ def main() -> int:
parser.add_argument('--ibex-config', required=True)
parser.add_argument('--output', required=True)
parser.add_argument('--shared-cov-dir', required=True)
parser.add_argument('--simulator', required=True)
parser.add_argument('--en_cov', action='store_true')
parser.add_argument('--en_wave', action='store_true')
@ -47,6 +48,7 @@ def main() -> int:
{
'core_ibex': core_ibex,
'out': args.output,
'shared_cov_dir': args.shared_cov_dir,
'cmp_opts': get_compile_opts(args.ibex_config,
args.simulator)
})

View file

@ -30,10 +30,10 @@ def find_cov_dirs(start_dir: str, simulator: str) -> Set[str]:
if file.endswith(".ucd") and simulator == 'xlm':
logging.info("Found coverage database (ucd) at %s" % path)
cov_dirs.add(path)
if vdb_dir_name in dirs and simulator == 'vcs':
vdb_path = os.path.join(path, vdb_dir_name)
logging.info("Found coverage database (vdb) at %s" % vdb_path)
cov_dirs.add(vdb_path)
if vdb_dir_name in dirs and simulator == 'vcs':
vdb_path = os.path.join(path, vdb_dir_name)
logging.info("Found coverage database (vdb) at %s" % vdb_path)
cov_dirs.add(vdb_path)
return cov_dirs
@ -74,10 +74,12 @@ def merge_cov_xlm(cov_dir: str, verbose: bool, cov_dirs: Set[str]) -> int:
# that handles them)
xlm_cov_dirs['cov_db_dirs'] = ' '.join(cov_dir_parents)
xlm_env = os.environ | xlm_cov_dirs
xlm_env = os.environ.copy()
xlm_env.update(xlm_cov_dirs)
# First do the merge
imc_cmd = ["imc", "-64bit", "-licqueue"]
os.makedirs(merge_dir, exist_ok=True)
cov_merge_tcl = os.path.join(xcelium_scripts, "cov_merge.tcl")
merge_ret = run_one(verbose,
imc_cmd + ["-exec", cov_merge_tcl,

View file

@ -55,6 +55,7 @@ def get_test_sim_cmd(base_cmd, test, binary, seed, sim_dir):
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument('--ibex-config', required=True)
parser.add_argument('--shared-cov-dir', required=True)
parser.add_argument('--simulator', required=True)
parser.add_argument("--en_cov", action='store_true')
parser.add_argument("--en_wave", action='store_true')
@ -85,6 +86,7 @@ def main() -> int:
sim_cmd = subst_vars(base_cmd,
{
'out': args.rtl_sim_dir,
'shared_cov_dir': args.shared_cov_dir,
'sim_opts': sim_opts,
'cwd': _CORE_IBEX,
})

View file

@ -39,7 +39,7 @@
-cm_tgl structarr
-cm_report noinitial
-cm_seqnoconst
-cm_dir <out>/test.vdb
-cm_dir <shared_cov_dir>/test.vdb
-cm_hier cover.cfg
wave_opts: >
-debug_access+all -ucli -do vcs.tcl
@ -61,10 +61,10 @@
+cosim_log_file=<sim_dir>/spike_cosim.log
cov_opts: >
-cm line+tgl+assert+fsm+branch
-cm_dir <out>/test.vdb
-cm_dir <shared_cov_dir>/test.vdb
-cm_log /dev/null
-assert nopostproc
-cm_name test_<test_name>_<iteration>
-cm_name test_<test_name>_<seed>
+enable_ibex_fcov=1
wave_opts: >
-ucli -do <cwd>/vcs.tcl
@ -186,9 +186,9 @@
<cov_opts>
<wave_opts>
cov_opts: >
-covmodeldir <out>/coverage/default/<test_name>.<seed>
-covworkdir <out>/coverage
-covscope default
-covmodeldir <sim_dir>/coverage
-covworkdir <sim_dir>
-covscope coverage
-covtest <test_name>.<seed>
+enable_ibex_fcov=1
wave_opts: >