Coordinates the high-level build pipeline for generated SystemVerilog modules.
This module is a convenience facade over the lower-level build steps provided by this package:
SvPortSim.Rtl.expand/2writes in-memory SystemVerilog sources to RTL files.SvPortSim.Verilator.Wrapper.write/2orwrite/3generates and writes the C++ wrapper source.SvPortSim.Verilator.Docker.compile/4validates or builds the generated design through Docker.
compile/3 defaults to mode: :build, preserving the existing behavior that
produces a Verilated executable. mode: :lint_only, or the lint/3 helper,
runs Verilator in a lighter validation mode that does not require or return a
runnable executable.
Summary
Functions
Compiles or validates SystemVerilog sources through the selected backend.
Validates generated SystemVerilog sources with Verilator lint-only mode.
Types
Functions
@spec compile(term(), term(), keyword()) :: {:ok, compile_result()} | {:error, term()}
Compiles or validates SystemVerilog sources through the selected backend.
top_module is the SystemVerilog top-module name. sources is a map from
module names to SystemVerilog source strings. The source map is validated and
written by SvPortSim.Rtl.expand/2.
Compilation performs the following steps in order:
- expands the SystemVerilog source map into RTL files
- writes a generated C++ wrapper for
top_module - invokes the selected backend in
:buildor:lint_onlymode
The current implementation supports only the Docker backend.
Options
:mode-:buildor:lint_only. Defaults to:build.:backend- Backend to use. Defaults to:docker. Any value other than:dockerreturns{:error, {:unsupported_backend, backend}}.:wrapper_dir- Directory where the generated C++ wrapper is written. Defaults toApplication.app_dir(:sv_port_sim, Path.join(["wrapper", top_module])). The directory path is expanded before use.:signal_specs- Optional list ofSvPortSim.SignalSpecmetadata maps. When present, the generated wrapper includespokeandpeekaccessors for supported top-level Verilated fields.:verilator_args- Additional Verilator arguments. These are converted to the Docker backend's:extra_argsoption. Defaults to[].:cache- Whentrue, successful backend results are stored in and retrieved from a content-addressed cache. Defaults tofalse.:cache_dir- Cache root used whencache: true. Defaults to"_build/sv_port_sim/cache".
All other options are forwarded to SvPortSim.Verilator.Docker.compile/4 when
the Docker backend is used. Pipeline-only options such as :backend,
:wrapper_dir, :signal_specs, :verilator_args, :cache, and :cache_dir
are not forwarded.
Return value
Returns {:ok, result} on success. The returned result map contains:
:top_module- the top-module name passed to this function:mode-:buildor:lint_only:rtl- the result returned bySvPortSim.Rtl.expand/2:wrapper- a map containing the generated wrapper file path:build- the backend build or lint result:executable- the generated executable path, only in:buildmode
Returns {:error, reason} on failure.
@spec lint(term(), term(), keyword()) :: {:ok, compile_result()} | {:error, term()}
Validates generated SystemVerilog sources with Verilator lint-only mode.
This is equivalent to calling compile/3 with mode: :lint_only. The wrapper
source is still generated so that signal metadata is validated consistently,
but the Docker backend invokes Verilator with --lint-only and the returned
result does not contain :executable.