|
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[List[str]] | 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 | |
| bool | UsesStderr = True |
Protected Member Functions | |
| 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 108 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 115 of file simulator.py.
Referenced by synth.LongestPathCollection.drop_non_critical_paths(), and synth.LongestPathCollection.merge().
|
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 316 of file simulator.py.
References print().
Referenced by simulator.Simulator.compile(), and simulator.Simulator.run_proc().
| int simulator.Simulator.compile | ( | self | ) |
Reimplemented in verilator.Verilator.
Definition at line 205 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(), questa.Questa.compile_commands(), simulator.Simulator.compile_commands(), verilator.Verilator.compile_commands(), print(), simulator.Simulator.run_dir, questa.Questa.UsesStderr, and simulator.Simulator.UsesStderr.
| List[List[str]] simulator.Simulator.compile_commands | ( | self | ) |
Compile the sources. Returns the exit code of the simulation compiler.
Reimplemented in questa.Questa, and verilator.Verilator.
Definition at line 201 of file simulator.py.
Referenced by simulator.Simulator.compile().
|
static |
Get the environment variables to locate shared objects.
Definition at line 191 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 372 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 233 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 247 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 238 of file simulator.py.
|
protected |
Definition at line 183 of file simulator.py.
Referenced by simulator.Simulator.compile().
|
protected |
Definition at line 183 of file simulator.py.
Referenced by simulator.Simulator.compile().
|
protected |
Definition at line 181 of file simulator.py.
Referenced by simulator.Simulator.compile().
|
protected |
Definition at line 181 of file simulator.py.
Referenced by simulator.Simulator.compile().
|
protected |
Definition at line 187 of file simulator.py.
Referenced by simulator.Simulator.run_proc().
|
protected |
Definition at line 187 of file simulator.py.
|
protected |
Definition at line 185 of file simulator.py.
Referenced by simulator.Simulator.run_proc().
|
protected |
Definition at line 185 of file simulator.py.
| simulator.Simulator.debug |
Definition at line 149 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 151 of file simulator.py.
Referenced by verilator.Verilator.compile_commands(), and questa.Questa.internal_compile_commands().
| simulator.Simulator.run_dir |
Definition at line 148 of file simulator.py.
Referenced by simulator.Simulator.compile(), questa.Questa.run(), and simulator.Simulator.run_proc().
| simulator.Simulator.save_waveform |
Definition at line 150 of file simulator.py.
Referenced by simulator.Simulator.run_proc().
| simulator.Simulator.sources |
Definition at line 147 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 113 of file simulator.py.
Referenced by simulator.Simulator.compile().