Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/dvsim/job/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ def __init__(self, sim_cfg: "SimCfg") -> None:
# Set class instance attributes.
self._set_attrs()

# Mutate the attributes based on any tool plugins.
if self.flow == "sim":
try:
plugin = get_sim_tool_plugin(self.sim_cfg.tool)
plugin.set_additional_attrs(self)
except NotImplementedError as e:
log.debug("Could not find sim tool for %s: %s", self.sim_cfg.tool, str(e))

# Check if all attributes that are needed are set.
self._check_attrs()

Expand Down Expand Up @@ -417,6 +425,7 @@ def _define_attrs(self) -> None:
"build_dir": False,
"build_opts": False,
"post_build_cmds": False,
"post_build_opts": False,
},
)

Expand Down Expand Up @@ -501,6 +510,7 @@ def _define_attrs(self) -> None:
"build_log": False,
"build_timeout_mins": False,
"post_build_cmds": False,
"post_build_opts": False,
"pre_build_cmds": False,
# Report processing
"report_cmd": False,
Expand Down
1 change: 1 addition & 0 deletions src/dvsim/modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ def __init__(self, bdict) -> None:
self.post_build_cmds = []
self.en_build_modes = []
self.build_opts = []
self.post_build_opts = []
self.build_timeout_mins = None
self.pre_run_cmds = []
self.post_run_cmds = []
Expand Down
3 changes: 3 additions & 0 deletions src/dvsim/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(self, regdict) -> None:
self.pre_run_cmds = []
self.post_run_cmds = []
self.build_opts = []
self.post_build_opts = []
self.run_opts = []
super().__init__("regression", regdict)

Expand Down Expand Up @@ -110,6 +111,7 @@ def create_regressions(regdicts, sim_cfg, tests):
# Merge the build and run cmds & opts from the sim modes
regression_obj.pre_build_cmds.extend(sim_mode_obj.pre_build_cmds)
regression_obj.post_build_cmds.extend(sim_mode_obj.post_build_cmds)
regression_obj.post_build_opts.extend(sim_mode_obj.post_build_opts)
regression_obj.build_opts.extend(sim_mode_obj.build_opts)
regression_obj.pre_run_cmds.extend(sim_mode_obj.pre_run_cmds)
regression_obj.post_run_cmds.extend(sim_mode_obj.post_run_cmds)
Expand Down Expand Up @@ -165,6 +167,7 @@ def merge_regression_opts(self) -> None:
if test.build_mode.name not in processed_build_modes:
test.build_mode.pre_build_cmds.extend(self.pre_build_cmds)
test.build_mode.post_build_cmds.extend(self.post_build_cmds)
test.build_mode.post_build_opts.extend(self.post_build_opts)
test.build_mode.build_opts.extend(self.build_opts)
processed_build_modes.append(test.build_mode.name)
test.pre_run_cmds.extend(self.pre_run_cmds)
Expand Down
3 changes: 3 additions & 0 deletions src/dvsim/sim/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def __init__(self, flow_cfg_file, hjson_data, args, mk_config) -> None:
self.flow_makefile = ""
self.pre_build_cmds = []
self.post_build_cmds = []
self.post_build_opts = []
self.build_dir = ""
self.pre_run_cmds = []
self.post_run_cmds = []
Expand Down Expand Up @@ -295,6 +296,7 @@ def _create_objects(self) -> None:
self.pre_build_cmds.extend(build_mode_obj.pre_build_cmds)
self.post_build_cmds.extend(build_mode_obj.post_build_cmds)
self.build_opts.extend(build_mode_obj.build_opts)
self.post_build_opts.extend(build_mode_obj.post_build_opts)
self.pre_run_cmds.extend(build_mode_obj.pre_run_cmds)
self.post_run_cmds.extend(build_mode_obj.post_run_cmds)
self.run_opts.extend(build_mode_obj.run_opts)
Expand Down Expand Up @@ -417,6 +419,7 @@ def _match_items(items: list, patterns: list):
self.pre_build_cmds,
self.post_build_cmds,
self.build_opts,
self.post_build_opts,
self.pre_run_cmds,
self.post_run_cmds,
self.run_opts,
Expand Down
15 changes: 14 additions & 1 deletion src/dvsim/sim/tool/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@

from collections.abc import Mapping, Sequence
from pathlib import Path
from typing import Protocol, runtime_checkable
from typing import TYPE_CHECKING, Protocol, runtime_checkable

from dvsim.sim.data import CoverageMetrics

if TYPE_CHECKING:
from dvsim.job.deploy import Deploy

__all__ = ("SimTool",)


Expand Down Expand Up @@ -82,3 +85,13 @@ def get_coverage_metrics(raw_metrics: Mapping[str, float | None] | None) -> Cove

"""
...

@staticmethod
def set_additional_attrs(deploy: "Deploy") -> None:
"""Define any additional tool-specific attrs on the deploy object.

Args:
deploy: the deploy object to mutate.

"""
...
13 changes: 13 additions & 0 deletions src/dvsim/sim/tool/vcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
import re
from collections.abc import Mapping, Sequence
from pathlib import Path
from typing import TYPE_CHECKING

from dvsim.sim.data import CodeCoverageMetrics, CoverageMetrics

if TYPE_CHECKING:
from dvsim.job.deploy import Deploy

__all__ = ("VCS",)


Expand Down Expand Up @@ -132,3 +136,12 @@ def get_coverage_metrics(raw_metrics: Mapping[str, float | None] | None) -> Cove
fsm=raw_metrics.get("fsm"),
),
)

@staticmethod
def set_additional_attrs(deploy: "Deploy") -> None:
"""Define any additional tool-specific attrs on the deploy object.

Args:
deploy: the deploy object to mutate.

"""
13 changes: 13 additions & 0 deletions src/dvsim/sim/tool/xcelium.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
from collections import OrderedDict
from collections.abc import Mapping, Sequence
from pathlib import Path
from typing import TYPE_CHECKING

from dvsim.sim.data import CodeCoverageMetrics, CoverageMetrics

if TYPE_CHECKING:
from dvsim.job.deploy import Deploy

__all__ = ("Xcelium",)


Expand Down Expand Up @@ -157,3 +161,12 @@ def get_coverage_metrics(raw_metrics: Mapping[str, float | None] | None) -> Cove
fsm=raw_metrics.get("fsm"),
),
)

@staticmethod
def set_additional_attrs(deploy: "Deploy") -> None:
"""Define any additional tool-specific attrs on the deploy object.

Args:
deploy: the deploy object to mutate.

"""
31 changes: 31 additions & 0 deletions src/dvsim/sim/tool/z01x.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright lowRISC contributors (OpenTitan project).
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

"""EDA tool plugin providing Z01X support to DVSim."""

from typing import TYPE_CHECKING

from dvsim.sim.tool.vcs import VCS

if TYPE_CHECKING:
from dvsim.job.deploy import Deploy

__all__ = ("Z01X",)


class Z01X(VCS):
"""Implement Z01X tool support."""

@staticmethod
def set_additional_attrs(deploy: "Deploy") -> None:
"""Define any additional tool-specific attrs on the deploy object.

Args:
deploy: the deploy object to mutate.

"""
if deploy.target == "run":
sim_run_opts = " ".join(opt.strip() for opt in deploy.run_opts)
deploy.exports.append({"sim_run_opts": sim_run_opts})
deploy.run_opts = list(deploy.sim_cfg.getattr("run_opts_fi_sim", ()))
2 changes: 2 additions & 0 deletions src/dvsim/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def merge_global_opts(
global_pre_build_cmds,
global_post_build_cmds,
global_build_opts,
global_post_build_opts,
global_pre_run_cmds,
global_post_run_cmds,
global_run_opts,
Expand All @@ -133,6 +134,7 @@ def merge_global_opts(
test.build_mode.pre_build_cmds.extend(global_pre_build_cmds)
test.build_mode.post_build_cmds.extend(global_post_build_cmds)
test.build_mode.build_opts.extend(global_build_opts)
test.build_mode.post_build_opts.extend(global_post_build_opts)
processed_build_modes.add(test.build_mode.name)
test.pre_run_cmds.extend(global_pre_run_cmds)
test.post_run_cmds.extend(global_post_run_cmds)
Expand Down
2 changes: 2 additions & 0 deletions src/dvsim/tool/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
from dvsim.sim.tool.base import SimTool
from dvsim.sim.tool.vcs import VCS
from dvsim.sim.tool.xcelium import Xcelium
from dvsim.sim.tool.z01x import Z01X

__all__ = ("get_sim_tool_plugin",)

_SUPPORTED_SIM_TOOLS = {
"vcs": VCS,
"xcelium": Xcelium,
"z01x": Z01X,
}


Expand Down
3 changes: 3 additions & 0 deletions tests/job/test_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def __init__(self) -> None:
self.build_timeout_mins = 500
self.build_mode = "build_mode"
self.build_opts = ["-b path/here", '-a "Quoted"']
self.post_build_opts = ["E"]


def _build_compile_sim(
Expand Down Expand Up @@ -120,6 +121,7 @@ class TestCompileSim:
"build_dir=build/dir "
"build_opts='-b path/here -a \"Quoted\"' "
"post_build_cmds='C && D' "
"post_build_opts=E "
"pre_build_cmds='A && B' "
"proj_root=/project "
"sv_flist_gen_cmd=gen_cmd "
Expand All @@ -134,6 +136,7 @@ class TestCompileSim:
"build_dir=build/dir "
"build_opts='-b path/here -a \"Quoted\"' "
"post_build_cmds='C && D' "
"post_build_opts=E "
"pre_build_cmds='A && B' "
"proj_root=/project "
"sv_flist_gen_cmd=gen_cmd "
Expand Down
Loading