|
CIRCT 23.0.0git
|


Public Member Functions | |
| __init__ (self, SourceFiles sources, Path run_dir, bool debug, bool save_waveform=False, Optional[Callable[[str], None]] run_stdout_callback=None, Optional[Callable[[str], None]] run_stderr_callback=None, Optional[Callable[[str], None]] compile_stdout_callback=None, Optional[Callable[[str], None]] compile_stderr_callback=None, bool make_default_logs=True, Optional[Dict[str, str]] macro_definitions=None) | |
| List[CompileStep] | compile_commands (self) |
| int | compile (self) |
| List[str] | run_command (self, bool gui) |
| str | waveform_extension (self) |
| SimProcess | run_proc (self, bool gui=False) |
| int | run (self, str inner_command, bool gui=False, bool server_only=False) |
Static Public Member Functions | |
| Dict[str, str] | get_env () |
Public Attributes | |
| sources | |
| run_dir | |
| debug | |
| save_waveform | |
| macro_definitions | |
Static Public Attributes | |
| CompileCommand = List[str] | |
| CompileFunction = Callable[[], Optional[int]] | |
| CompileStep = Union[CompileCommand, CompileFunction] | |
| bool | UsesStderr = True |
Protected Member Functions | |
| int | _run_compile_command (self, CompileCommand cmd) |
| int | _run_compile_step (self, CompileStep step) |
| int|tuple[subprocess.Popen, List[threading.Thread]] | _start_process_with_callbacks (self, List[str] cmd, Optional[Dict[str, str]] env, Optional[Path] cwd, Optional[Callable[[str], None]] stdout_cb, Optional[Callable[[str], None]] stderr_cb, bool wait) |
Protected Attributes | |
| _compile_stdout_cb | |
| _compile_stdout_log | |
| _compile_stderr_cb | |
| _compile_stderr_log | |
| _run_stdout_cb | |
| _run_stdout_log | |
| _run_stderr_cb | |
| _run_stderr_log | |
Definition at line 125 of file simulator.py.
| simulator.Simulator.__init__ | ( | self, | |
| SourceFiles | sources, | ||
| Path | run_dir, | ||
| bool | debug, | ||
| bool | save_waveform = False, |
||
| Optional[Callable[[str], None]] | run_stdout_callback = None, |
||
| Optional[Callable[[str], None]] | run_stderr_callback = None, |
||
| Optional[Callable[[str], None]] | compile_stdout_callback = None, |
||
| Optional[Callable[[str], None]] | compile_stderr_callback = None, |
||
| bool | make_default_logs = True, |
||
| Optional[Dict[str, str]] | macro_definitions = None |
||
| ) |
Simulator base class.
Optional sinks can be provided for capturing output. If not provided,
the simulator will write to log files in `run_dir`.
Args:
sources: SourceFiles describing RTL/DPI inputs.
run_dir: Directory where build/run artifacts are placed.
debug: Enable cosim debug mode.
save_waveform: When True and debug=True, dump simulator waveforms to a
waveform file. The exact format depends on the backend (e.g. FST for
Verilator, VCD for Questa). Requires debug to be enabled.
run_stdout_callback: Line-based callback for runtime stdout.
run_stderr_callback: Line-based callback for runtime stderr.
compile_stdout_callback: Line-based callback for compile stdout.
compile_stderr_callback: Line-based callback for compile stderr.
make_default_logs: If True and corresponding callback is not supplied,
create log file and emit via internally-created callback.
macro_definitions: Optional dictionary of macro definitions to be defined
during compilation.
Reimplemented in verilator.Verilator, and questa.Questa.
Definition at line 136 of file simulator.py.
Referenced by synth.LongestPathCollection.drop_non_critical_paths(), and synth.LongestPathCollection.merge().
|
protected |
Definition at line 231 of file simulator.py.
References simulator.Simulator._compile_stderr_cb, simulator.Simulator._compile_stderr_log, simulator.Simulator._compile_stdout_cb, simulator.Simulator._compile_stdout_log, simulator.Simulator._start_process_with_callbacks(), and print().
Referenced by simulator.Simulator._run_compile_step().
|
protected |
Definition at line 256 of file simulator.py.
References simulator.Simulator._run_compile_command().
Referenced by simulator.Simulator.compile().
|
protected |
Start a subprocess and stream its stdout/stderr to callbacks. If wait is True, blocks until process completes and returns its exit code. If wait is False, returns the Popen object (threads keep streaming).
Definition at line 358 of file simulator.py.
References print().
Referenced by simulator.Simulator._run_compile_command(), and simulator.Simulator.run_proc().
| int simulator.Simulator.compile | ( | self | ) |
Definition at line 266 of file simulator.py.
References simulator.Simulator._run_compile_step(), questa.Questa.compile_commands(), simulator.Simulator.compile_commands(), verilator.Verilator.compile_commands(), and simulator.Simulator.run_dir.
| List[CompileStep] simulator.Simulator.compile_commands | ( | self | ) |
Return the compile steps for the simulator. Each step may be either a shell command (`List[str]`) or a Python callback (`Callable[[], Optional[int]]`). Python callbacks should return `0` or `None` on success and a non-zero integer on failure.
Reimplemented in questa.Questa, and verilator.Verilator.
Definition at line 222 of file simulator.py.
Referenced by simulator.Simulator.compile().
|
static |
Get the environment variables to locate shared objects.
Definition at line 212 of file simulator.py.
| int simulator.Simulator.run | ( | self, | |
| str | inner_command, | ||
| bool | gui = False, |
||
| bool | server_only = False |
||
| ) |
Start the simulation then run the command specified. Kill the simulation when the command exits.
Reimplemented in questa.Questa.
Definition at line 414 of file simulator.py.
References print(), and simulator.Simulator.run_proc().
| List[str] simulator.Simulator.run_command | ( | self, | |
| bool | gui | ||
| ) |
Return the command to run the simulation.
Reimplemented in questa.Questa, and verilator.Verilator.
Definition at line 275 of file simulator.py.
Referenced by setup.NoopBuildExtension.build_extension(), Python.setup.CustomBuild.run(), setup.CustomBuild.run(), and simulator.Simulator.run_proc().
| SimProcess simulator.Simulator.run_proc | ( | self, | |
| bool | gui = False |
||
| ) |
Run the simulation process. Returns the Popen object and the port which the simulation is listening on. If user-provided stdout/stderr sinks were supplied in the constructor, they are used. Otherwise, log files are created in `run_dir`.
Definition at line 289 of file simulator.py.
References simulator.Simulator._run_stderr_cb, simulator.Simulator._run_stdout_cb, simulator.Simulator._start_process_with_callbacks(), circt::arc::runtime::impl::TraceEncoder.debug, esi::CliParser.debug, esi::Logger.debug(), esi::Logger.debug(), pytest.CosimPytestConfig.debug, simulator.Simulator.debug, simulator.is_port_open(), resolve(), questa.Questa.run_command(), simulator.Simulator.run_command(), verilator.Verilator.run_command(), simulator.Simulator.run_dir, pytest.CosimPytestConfig.save_waveform, and simulator.Simulator.save_waveform.
Referenced by simulator.Simulator.run().
| str simulator.Simulator.waveform_extension | ( | self | ) |
File extension for waveform dumps. Subclasses should override if their format differs. The Verilator C++ driver writes FST (via ``VerilatedFstC``); the generic SV driver uses ``$dumpfile/$dumpvars`` which produces VCD.
Reimplemented in verilator.Verilator.
Definition at line 280 of file simulator.py.
|
protected |
Definition at line 204 of file simulator.py.
Referenced by simulator.Simulator._run_compile_command().
|
protected |
Definition at line 204 of file simulator.py.
Referenced by simulator.Simulator._run_compile_command().
|
protected |
Definition at line 202 of file simulator.py.
Referenced by simulator.Simulator._run_compile_command().
|
protected |
Definition at line 202 of file simulator.py.
Referenced by simulator.Simulator._run_compile_command().
|
protected |
Definition at line 208 of file simulator.py.
Referenced by simulator.Simulator.run_proc().
|
protected |
Definition at line 208 of file simulator.py.
|
protected |
Definition at line 206 of file simulator.py.
Referenced by simulator.Simulator.run_proc().
|
protected |
Definition at line 206 of file simulator.py.
|
static |
Definition at line 127 of file simulator.py.
|
static |
Definition at line 128 of file simulator.py.
|
static |
Definition at line 129 of file simulator.py.
| simulator.Simulator.debug |
Definition at line 170 of file simulator.py.
Referenced by verilator.Verilator._write_cmake(), verilator.Verilator.compile_commands(), questa.Questa.run_command(), and simulator.Simulator.run_proc().
| simulator.Simulator.macro_definitions |
Definition at line 172 of file simulator.py.
Referenced by verilator.Verilator.compile_commands(), and questa.Questa.internal_compile_commands().
| simulator.Simulator.run_dir |
Definition at line 169 of file simulator.py.
Referenced by simulator.Simulator.compile(), questa.Questa.run(), and simulator.Simulator.run_proc().
| simulator.Simulator.save_waveform |
Definition at line 171 of file simulator.py.
Referenced by simulator.Simulator.run_proc().
| simulator.Simulator.sources |
Definition at line 168 of file simulator.py.
Referenced by verilator.Verilator._write_cmake(), verilator.Verilator.compile_commands(), questa.Questa.internal_compile_commands(), questa.Questa.run_command(), and verilator.Verilator.run_command().
|
static |
Definition at line 134 of file simulator.py.