Runs Verilator inside Docker for build and lint-only flows.
This module stages SystemVerilog source files, and in build mode a generated C++ wrapper, into a host-side work directory. It then mounts that directory into a Docker container and invokes Verilator.
compile_executable/4 preserves the original executable-producing API and is
equivalent to compile/4 with mode: :build. lint/3 and compile/4 with
mode: :lint_only run Verilator with --lint-only and do not require or
return a wrapper executable.
Summary
Functions
Runs Verilator through Docker in either build or lint-only mode.
Compiles a Verilated executable by running Verilator inside Docker.
Returns the default host-side Verilator work directory for top_module.
Runs Verilator lint-only validation through Docker.
Types
@type compile_mode() :: :build | :lint_only
@type compile_result() :: build_result() | lint_result()
Functions
Runs Verilator through Docker in either build or lint-only mode.
Options
:mode-:buildor:lint_only. Defaults to:build.:docker_mode-:run_onceor:persistent. Defaults to:run_once. Persistent mode usesSvPortSim.Verilator.DockerWorkeranddocker execto reuse a long-running container.:image- Docker image to use. Defaults to"verilator/verilator:latest".:work_dir- Host-side build directory. Defaults todefault_work_dir(top_module). The directory is expanded before use.:docker- Docker executable path. When omitted, the executable is resolved withDockerAvailability.executable/0.:check_docker- Whether to check Docker daemon reachability before preparing the workspace and running Verilator. Defaults totrue.:make_jobs- Value passed to Verilator's-joption in build mode. Accepts a non-negative integer or a non-empty string. Defaults to0.:extra_args- Additional Verilator arguments. Must be a list of strings. Defaults to[].:user- Docker user option. Defaults to:current, which attempts to pass the currentuid:gidto Docker. Usenilorfalseto omit--user, or pass a non-empty string such as"1000:1000".:clean- Whether to remove stagedrtl/,cpp/, andobj_dir/directories before preparing the workspace. Defaults totrue.:verify_executable- Whether to require the expected executableobj_dir/V<top_module>to exist after Docker finishes successfully in build mode. Defaults totrue.:docker_worker- ExistingSvPortSim.Verilator.DockerWorkerpid or registered name to use whendocker_mode: :persistent.:docker_worker_name- Container and registry name for persistent mode. Defaults to a stable name derived fromwork_dir.:docker_worker_cleanup-:manualor:on_exit. Defaults to:manual.
Build mode returns {:ok, build} with :executable. Lint-only mode returns
{:ok, lint} without :executable.
@spec compile_executable(term(), term(), term(), keyword()) :: {:ok, build_result()} | {:error, term()}
Compiles a Verilated executable by running Verilator inside Docker.
This function keeps the historical public API stable. It always runs build
mode, stages wrapper_cpp, and verifies obj_dir/V<top_module> by default.
Returns the default host-side Verilator work directory for top_module.
The returned path is application-local and is currently resolved as:
Application.app_dir(:sv_port_sim, Path.join(["verilator", top_module]))For example, the default work directory for "Counter" is under the
application's verilator/Counter directory.
@spec lint(term(), term(), keyword()) :: {:ok, lint_result()} | {:error, term()}
Runs Verilator lint-only validation through Docker.
Lint-only mode stages only the SystemVerilog sources, invokes Verilator with
--lint-only, and returns {:error, {:verilator_lint_failed, status, log, command}} when Verilator reports diagnostics with a non-zero exit status.