|
CIRCT 24.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, Optional[str]]] macro_definitions=None) | |
| Path | verilator_bin (self) |
| List[Simulator.CompileStep] | compile_commands (self) |
| str | waveform_extension (self) |
| run_command (self, bool gui) | |
| Public Member Functions inherited from 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, Optional[str]]] macro_definitions=None) | |
| int | compile (self) |
| SimProcess | run_proc (self, bool gui=False) |
| int | run (self, str inner_command, bool gui=False, bool server_only=False) |
Static Public Attributes | |
| str | DefaultDriver = CosimCollateralDir / "driver.cpp" |
| tuple | VerilatorBinNotFound |
| tuple | VerilatorRootNotFound |
| tuple | VerilatorPathInvalid |
| tuple | VerilatorRootInvalid |
| Static Public Attributes inherited from simulator.Simulator | |
| CompileCommand = List[str] | |
| CompileFunction = Callable[[], Optional[int]] | |
| CompileStep = Union[CompileCommand, CompileFunction] | |
| bool | UsesStderr = True |
Protected Member Functions | |
| bool | _use_cmake (self) |
| Path | _depfile_path (self, Path obj_dir) |
| List[Path] | _generated_targets (self, Path depfile) |
| int | _write_cmake_from_depfile (self) |
| List[Path] | _generated_cpp_sources (self, Path depfile) |
| Path | _write_cmake (self, Path obj_dir, List[Path] generated_sources, Optional[Path] pch_header=None) |
| Protected Member Functions inherited from simulator.Simulator | |
| 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) |
Static Protected Member Functions | |
| Optional[Path] | _find_verilator_bin () |
| Optional[Path] | _find_verilator_root () |
| None | _raise_stack_limit () |
| List[str] | _toolchain_args () |
| str | _cmake_signature (List[str] cmake_cmd) |
| bool | _is_slow (Path source) |
Protected Attributes | |
| bool | _cmake_dirty = True |
| _use_cmake | |
| _write_cmake_from_depfile | |
| Protected Attributes inherited from simulator.Simulator | |
| list | _default_files = [] |
| _compile_stdout_cb | |
| _compile_stdout_log | |
| _compile_stderr_cb | |
| _compile_stderr_log | |
| _run_stdout_cb | |
| _run_stdout_log | |
| _run_stderr_cb | |
| _run_stderr_log | |
Static Protected Attributes | |
| str | _CMakeSignatureFilename = ".esi-cosim-cmake-config.json" |
| tuple | _CMakeSignatureEnv |
Additional Inherited Members | |
| Static Public Member Functions inherited from simulator.Simulator | |
| Dict[str, str] | get_env () |
| Public Attributes inherited from simulator.Simulator | |
| sources = sources | |
| run_dir = run_dir | |
| debug = debug | |
| save_waveform = save_waveform | |
| macro_definitions = macro_definitions | |
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 15 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, Optional[str]]] | macro_definitions = None ) |
|
staticprotected |
Serialize inputs that can affect CMake configuration.
Definition at line 176 of file verilator.py.
|
protected |
Definition at line 307 of file verilator.py.
Referenced by _write_cmake_from_depfile().
|
staticprotected |
Locate the ``verilator_bin`` executable. When ``VERILATOR_PATH`` is set it must point to a valid executable; otherwise a ``RuntimeError`` is raised. Without it, ``verilator_bin`` is looked up on ``PATH``. Returns ``None`` when nothing is found.
Definition at line 80 of file verilator.py.
Referenced by compile_commands().
|
staticprotected |
Locate the Verilator root containing ``include/verilated.h``. When ``VERILATOR_ROOT`` is set it must contain ``include/verilated.h``; otherwise a ``RuntimeError`` is raised. Without it, the packaged root (``$PREFIX/share/verilator``) is derived from the ``verilator_bin`` location. Returns ``None`` when nothing is found.
Definition at line 105 of file verilator.py.
Referenced by _write_cmake(), and compile_commands().
|
protected |
Definition at line 331 of file verilator.py.
References _generated_targets().
|
protected |
Definition at line 310 of file verilator.py.
References resolve().
Referenced by _generated_cpp_sources(), and _write_cmake_from_depfile().
|
staticprotected |
Verilator suffixes cold-path TUs, including Syms/ConstPool, with ``__Slow``.
Definition at line 342 of file verilator.py.
Referenced by _write_cmake().
|
staticprotected |
Lift the stack soft limit to the hard limit for the verilator process. Verilator recurses over the design AST and segfaults on large designs with the usual 8MB stack. Its ``verilator`` wrapper script normally runs ``ulimit -s unlimited`` first; we invoke ``verilator_bin`` directly and so have to do it ourselves. Subprocesses inherit the raised limit.
Definition at line 137 of file verilator.py.
Referenced by compile_commands().
|
staticprotected |
Prefer clang and lld when they are available. Verilated code compiles about twice as fast with clang as with gcc, and the model is a throwaway simulation binary, so the toolchain only affects build time. Setting ``CXX`` or ``LDFLAGS`` opts back out.
Definition at line 157 of file verilator.py.
|
protected |
True when both cmake and ninja are available on PATH.
Definition at line 131 of file verilator.py.
|
protected |
Write a CMakeLists.txt for building the verilated simulation. Returns the path to the CMake build directory.
Definition at line 347 of file verilator.py.
References _cmake_dirty, _find_verilator_root(), _is_slow(), circt::arc::runtime::impl::TraceEncoder.debug, esi::CliParser.debug, pytest.CosimPytestConfig.debug, questa.Questa.debug, simulator.Simulator.debug, and simulator.Simulator.sources.
Referenced by _write_cmake_from_depfile().
|
protected |
Definition at line 318 of file verilator.py.
References _depfile_path(), _generated_targets(), and _write_cmake().
| List[Simulator.CompileStep] verilator.Verilator.compile_commands | ( | self | ) |
Return the compile steps for the full compile flow. When cmake and ninja are available the returned list contains four sequential steps: 1. ``verilator_bin`` – generates C++ from RTL. 2. Python callback – generates the CMakeLists.txt from the depfile. 3. Python callback – configures the C++ build when inputs changed. 4. ``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 186 of file verilator.py.
References _find_verilator_bin(), _find_verilator_root(), and _raise_stack_limit().
| verilator.Verilator.run_command | ( | self, | |
| bool | gui ) |
Return the command to run the simulation.
Reimplemented from simulator.Simulator.
Definition at line 515 of file verilator.py.
References _use_cmake, and simulator.Simulator.sources.
Referenced by Python.setup.CustomBuild.run(), and setup.CustomBuild.run().
| Path verilator.Verilator.verilator_bin | ( | self | ) |
Definition at line 73 of file verilator.py.
| str verilator.Verilator.waveform_extension | ( | self | ) |
Verilator's C++ driver uses ``VerilatedFstC`` — FST format.
Reimplemented from simulator.Simulator.
Definition at line 511 of file verilator.py.
|
protected |
Definition at line 70 of file verilator.py.
Referenced by _write_cmake().
|
staticprotected |
Definition at line 24 of file verilator.py.
|
staticprotected |
Definition at line 23 of file verilator.py.
|
protected |
Definition at line 242 of file verilator.py.
Referenced by run_command().
|
protected |
Definition at line 284 of file verilator.py.
|
static |
Definition at line 22 of file verilator.py.
|
static |
Definition at line 32 of file verilator.py.
|
static |
Definition at line 38 of file verilator.py.
|
static |
Definition at line 40 of file verilator.py.
|
static |
Definition at line 35 of file verilator.py.