Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for pre_cmd parameter to match cocotb v1.9 #264

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ cocotb-clean -r
* `sim_args`: Any arguments or flags to pass to the execution of the compiled simulation.
* `extra_args`: Passed to both the compile and execute phases of simulators.
* `plus_args`: plusargs arguments passed to simulator.
* `pre_cmd`: Commands to run before simulation begins (currently only available for the Questa simulator).
* `force_compile`: Force compilation even if sources did not change. (default: `False`)
* `compile_only`: Only compile sources. Do not run simulation. (default: `False`)
* `testcase`: The name of the test function(s) to run (see [TESTCASE](https://docs.cocotb.org/en/stable/building.html?#envvar-TESTCASE) ).
Expand Down
21 changes: 21 additions & 0 deletions cocotb_test/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def __init__(
sim_args=None,
extra_args=None,
plus_args=None,
pre_cmd=None,
force_compile=False,
testcase=None,
sim_build="sim_build",
Expand Down Expand Up @@ -107,6 +108,7 @@ def __init__(
self.extra_args = some_or(extra_args, [])
self.simulation_args = some_or(sim_args, [])
self.plus_args = some_or(plus_args, [])
self.pre_cmd = some_or(pre_cmd, [])
self.force_compile = force_compile
self.compile_only = compile_only
self.waves = bool(some_or(waves, int(os.getenv("WAVES", 0))))
Expand Down Expand Up @@ -450,6 +452,9 @@ def run_command(self):
)

def build_command(self):
if self.pre_cmd:
print("WARNING: pre_cmd is not implemented for Icarus Verilog.")

verilog_sources = self.verilog_sources_flat.copy()
if self.waves:
dump_mod_name = "iverilog_dump"
Expand Down Expand Up @@ -502,6 +507,8 @@ def get_parameter_commands(self, parameters):

def do_script(self):
do_script = ""
if self.pre_cmd:
do_script += self.pre_cmd
if self.waves:
do_script += "log -recursive /*;"
if not self.gui:
Expand Down Expand Up @@ -621,6 +628,8 @@ def get_parameter_commands(self, parameters):
return parameters_cmd

def build_command(self):
if self.pre_cmd:
print("WARNING: pre_cmd is not implemented for Ius.")

assert (
not self.verilog_compile_args and not self.vhdl_compile_args
Expand Down Expand Up @@ -702,6 +711,8 @@ def get_parameter_commands(self, parameters):
return parameters_cmd

def build_command(self):
if self.pre_cmd:
print("WARNING: pre_cmd is not implemented for Xcelium.")

assert (
not self.verilog_compile_args and not self.vhdl_compile_args
Expand Down Expand Up @@ -766,6 +777,8 @@ def get_parameter_commands(self, parameters):
return [f"-pvalue+{self.toplevel_module}/{name}={str(value)}" for name, value in parameters.items()]

def build_command(self):
if self.pre_cmd:
print("WARNING: pre_cmd is not implemented for Vcs.")

pli_cmd = "acc+=rw,wn:*"

Expand Down Expand Up @@ -831,6 +844,8 @@ def get_parameter_commands(self, parameters):
return [f"-g{name}={str(value)}" for name, value in parameters.items()]

def build_command(self):
if self.pre_cmd:
print("WARNING: pre_cmd is not implemented for GHDL.")

ghdl_exec = shutil.which("ghdl")
if ghdl_exec is None:
Expand Down Expand Up @@ -924,6 +939,8 @@ def get_parameter_commands(self, parameters):
return ["-g" + name + "=" + str(value) for name, value in parameters.items()]

def build_command(self):
if self.pre_cmd:
print("WARNING: pre_cmd is not implemented for Riviera.")

self.rtl_library = self.toplevel_module

Expand Down Expand Up @@ -1076,6 +1093,8 @@ def build_script_run(self):
return "run -all \nexit"

def build_command(self):
if self.pre_cmd:
print("WARNING: pre_cmd is not implemented for Activehdl.")

self.rtl_library = self.toplevel_module

Expand Down Expand Up @@ -1115,6 +1134,8 @@ def get_parameter_commands(self, parameters):
return [f"-G{name}={str(value)}" for name, value in parameters.items()]

def build_command(self):
if self.pre_cmd:
print("WARNING: pre_cmd is not implemented for Verilator.")

cmd = []

Expand Down
Loading