|
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) |
| str | waveform_extension (self) |
| run_command (self, bool gui) | |
Public Member Functions inherited from simulator.Simulator | |
| SimProcess | run_proc (self, bool gui=False) |
| int | run (self, str inner_command, bool gui=False, bool server_only=False) |
Public Attributes | |
| verilator_bin | |
Public Attributes inherited from simulator.Simulator | |
| sources | |
| run_dir | |
| debug | |
| save_waveform | |
| macro_definitions | |
Static Public Attributes | |
| str | DefaultDriver = CosimCollateralDir / "driver.cpp" |
Static Public Attributes inherited from simulator.Simulator | |
| bool | UsesStderr = True |
Protected Member Functions | |
| Path | _find_verilator_root (self) |
| bool | _use_cmake (self) |
| Path | _write_cmake (self, Path obj_dir) |
Protected Member Functions inherited from simulator.Simulator | |
| 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) |
Additional Inherited Members | |
Static Public Member Functions inherited from simulator.Simulator | |
| Dict[str, str] | get_env () |
Protected Attributes inherited from simulator.Simulator | |
| _compile_stdout_cb | |
| _compile_stdout_log | |
| _compile_stderr_cb | |
| _compile_stderr_log | |
| _run_stdout_cb | |
| _run_stdout_log | |
| _run_stderr_cb | |
| _run_stderr_log | |
Run and compile funcs for Verilator. Calls ``verilator_bin`` directly (bypassing the Perl wrapper) to generate C++ from RTL, then builds the simulation executable with CMake + Ninja. Falls back to ``make`` when cmake/ninja are not available.
Definition at line 13 of file verilator.py.
| verilator.Verilator.__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 from simulator.Simulator.
Definition at line 22 of file verilator.py.
References verilator.Verilator.__init__().
Referenced by verilator.Verilator.__init__(), synth.LongestPathCollection.drop_non_critical_paths(), and synth.LongestPathCollection.merge().
|
protected |
Locate VERILATOR_ROOT for runtime includes and sources. Checks the ``VERILATOR_ROOT`` environment variable first, then attempts to derive the root from the location of ``verilator_bin``. Supports both source-tree layouts (``$ROOT/include/verilated.h``) and system package layouts (``$PREFIX/share/verilator/include/verilated.h``).
Definition at line 58 of file verilator.py.
References resolve(), and verilator.Verilator.verilator_bin.
Referenced by verilator.Verilator._write_cmake(), and verilator.Verilator.compile().
|
protected |
True when both cmake and ninja are available on PATH.
Definition at line 85 of file verilator.py.
Referenced by verilator.Verilator.compile(), verilator.Verilator.compile_commands(), and verilator.Verilator.run_command().
|
protected |
Write a CMakeLists.txt for building the verilated simulation. Returns the path to the CMake build directory.
Definition at line 155 of file verilator.py.
References verilator.Verilator._find_verilator_root(), circt::arc::runtime::impl::TraceEncoder.debug, esi::CliParser.debug, esi::Logger.debug(), esi::Logger.debug(), pytest.CosimPytestConfig.debug, simulator.Simulator.debug, and simulator.Simulator.sources.
Referenced by verilator.Verilator.compile().
| int verilator.Verilator.compile | ( | self | ) |
Set VERILATOR_ROOT, write the CMakeLists.txt (if using cmake), then delegate to the base class which runs all commands from :meth:`compile_commands`.
Reimplemented from simulator.Simulator.
Definition at line 221 of file verilator.py.
References verilator.Verilator._find_verilator_root(), verilator.Verilator._use_cmake(), verilator.Verilator._write_cmake(), and verilator.Verilator.compile().
Referenced by verilator.Verilator.compile().
| List[List[str]] verilator.Verilator.compile_commands | ( | self | ) |
Return the commands for the full compile flow. When cmake and ninja are available the returned list contains three commands run sequentially: 1. ``verilator_bin`` – generates C++ from RTL. 2. ``cmake`` – configures the C++ build (Ninja generator). 3. ``ninja`` – builds the simulation executable. Otherwise falls back to two commands: 1. ``verilator_bin --exe`` – generates C++ and a Makefile. 2. ``make`` – builds via the generated Makefile.
Reimplemented from simulator.Simulator.
Definition at line 90 of file verilator.py.
References verilator.Verilator._use_cmake(), circt::arc::runtime::impl::TraceEncoder.debug, esi::CliParser.debug, esi::Logger.debug(), esi::Logger.debug(), pytest.CosimPytestConfig.debug, simulator.Simulator.debug, simulator.Simulator.macro_definitions, simulator.Simulator.sources, and verilator.Verilator.verilator_bin.
Referenced by simulator.Simulator.compile().
| verilator.Verilator.run_command | ( | self, | |
| bool | gui | ||
| ) |
Return the command to run the simulation.
Reimplemented from simulator.Simulator.
Definition at line 236 of file verilator.py.
References verilator.Verilator._use_cmake(), and simulator.Simulator.sources.
Referenced by setup.NoopBuildExtension.build_extension(), Python.setup.CustomBuild.run(), setup.CustomBuild.run(), and simulator.Simulator.run_proc().
| str verilator.Verilator.waveform_extension | ( | self | ) |
Verilator's C++ driver uses ``VerilatedFstC`` — FST format.
Reimplemented from simulator.Simulator.
Definition at line 232 of file verilator.py.
|
static |
Definition at line 20 of file verilator.py.
| verilator.Verilator.verilator_bin |
Definition at line 47 of file verilator.py.
Referenced by verilator.Verilator._find_verilator_root(), and verilator.Verilator.compile_commands().