Skip to content

Commit

Permalink
Add DSim coverage gather option to dsim_run rule
Browse files Browse the repository at this point in the history
Signed-off-by: Maciej Dudek <[email protected]>
  • Loading branch information
mtdudek committed Oct 28, 2024
1 parent 65524f9 commit 6e9ba43
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion dsim/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ def _dsim_run(ctx):

inputs = [ctx.file.dsim_env] + verilog_files + all_hdrs
outputs = [dsim_log] + ctx.outputs.outs
generated_files = [dsim_log]
# Coverage file
if ctx.attr.enable_code_coverage:
dsim_cov = ctx.actions.declare_file("{}.db".format(ctx.label.name))
command += " -cov-db " + dsim_cov.path
if ctx.attr.code_coverage_type in ["toggle", "all"]:
command += " +acc+b "
command += " -code-cov " + ctx.attr.code_coverage_type
outputs.append(dsim_cov)
generated_files.append(dsim_cov)


ctx.actions.run_shell(
outputs = outputs,
Expand All @@ -72,7 +83,7 @@ def _dsim_run(ctx):

return [
DefaultInfo(
files = depset([dsim_log]),
files = depset(generated_files),
runfiles = ctx.runfiles(files = runfiles),
),
]
Expand All @@ -95,6 +106,14 @@ dsim_run = rule(
mandatory = True,
allow_single_file = [".sh"],
),
"enable_code_coverage": attr.bool(
doc = "Gather simulation coverage",
default = False,
),
"code_coverage_type": attr.string(
doc = "Select coverage type: block, expression, toggle or all",
default = "all",
),
"outs": attr.output_list(
doc = "List of simulation products",
),
Expand Down

0 comments on commit 6e9ba43

Please sign in to comment.