pub struct SimulatorBuilder<'a, Target = Simulator> { /* private fields */ }Expand description
A fluent builder for configuring and initializing a Simulator or
Simulation.
Use Simulator::builder() or Simulation::builder()
to obtain the appropriate variant. Both share the same configuration methods;
only .build() differs in return type.
Implementations§
Source§impl<'a, Target> SimulatorBuilder<'a, Target>
Configuration methods shared by all builder variants.
impl<'a, Target> SimulatorBuilder<'a, Target>
Configuration methods shared by all builder variants.
Sourcepub fn sources(&self) -> &[(&'a str, &'a Path)]
pub fn sources(&self) -> &[(&'a str, &'a Path)]
Returns the source files passed to this builder.
Sourcepub fn four_state_enabled(&self) -> bool
pub fn four_state_enabled(&self) -> bool
Returns whether four-state simulation is enabled for this builder.
Sourcepub fn with_metadata(self, metadata: Metadata) -> Self
pub fn with_metadata(self, metadata: Metadata) -> Self
Supply project metadata (clock/reset settings, etc.) instead of defaults.
Sourcepub fn clock_type(self, clock_type: ClockType) -> Self
pub fn clock_type(self, clock_type: ClockType) -> Self
Override the clock type (posedge/negedge) from metadata or defaults.
Sourcepub fn reset_type(self, reset_type: ResetType) -> Self
pub fn reset_type(self, reset_type: ResetType) -> Self
Override the reset type (async_high/async_low/sync_high/sync_low) from metadata or defaults.
Sourcepub fn param(self, name: &str, value: u64) -> Self
pub fn param(self, name: &str, value: u64) -> Self
Override a top-level module parameter value.
Sourcepub fn with_injected_components(self, components: InjectedComponents) -> Self
pub fn with_injected_components(self, components: InjectedComponents) -> Self
Make in-process component implementations available as $comp::<name>.
Sourcepub fn four_state(self, enable: bool) -> Self
pub fn four_state(self, enable: bool) -> Self
Enable 4-state (0, 1, X, Z) simulation mode.
Sourcepub fn allow_always_ff_function_effects(self, enable: bool) -> Self
pub fn allow_always_ff_function_effects(self, enable: bool) -> Self
Allow function output and non-local write effects in always_ff.
This opts into Celox-specific lowering for constructs rejected by Veryl’s SystemVerilog compatibility checks. It is primarily useful for testing Celox’s FF lowering semantics.
Sourcepub fn native_force_support(self, enable: bool) -> Self
pub fn native_force_support(self, enable: bool) -> Self
Enable native-image support for foreign force/release operations.
This emits extra combinational entry points, so ordinary simulator builds leave it disabled. Enabling it forces SIR O0 at build time so every store boundary needed to reapply a force remains intact.
Sourcepub fn opt_level(self, level: OptLevel) -> Self
pub fn opt_level(self, level: OptLevel) -> Self
Set the overall optimization level. Sets defaults for SIR passes, Cranelift options, and DSE policy. Per-pass overrides can be applied after.
Sourcepub fn enable_pass(self, pass: SirPass) -> Self
pub fn enable_pass(self, pass: SirPass) -> Self
Enable a specific SIR pass, overriding the OptLevel default.
Sourcepub fn disable_pass(self, pass: SirPass) -> Self
pub fn disable_pass(self, pass: SirPass) -> Self
Disable a specific SIR pass, overriding the OptLevel default.
Sourcepub fn optimize(self, enable: bool) -> Self
pub fn optimize(self, enable: bool) -> Self
Enable or disable all SIRT optimization passes at once.
Shorthand: true → OptLevel::O1, false → OptLevel::O0.
Sourcepub fn optimize_options(self, options: OptimizeOptions) -> Self
pub fn optimize_options(self, options: OptimizeOptions) -> Self
Set per-pass optimizer flags directly.
pub fn x86_slp(self, enable: bool) -> Self
Sourcepub fn cranelift_options(self, options: CraneliftOptions) -> Self
pub fn cranelift_options(self, options: CraneliftOptions) -> Self
Set fine-grained Cranelift backend options.
Sourcepub fn regalloc_algorithm(self, algo: RegallocAlgorithm) -> Self
pub fn regalloc_algorithm(self, algo: RegallocAlgorithm) -> Self
Set the register allocator algorithm.
Sourcepub fn enable_alias_analysis(self, enable: bool) -> Self
pub fn enable_alias_analysis(self, enable: bool) -> Self
Enable or disable alias analysis in the Cranelift egraph pass.
Sourcepub fn enable_verifier(self, enable: bool) -> Self
pub fn enable_verifier(self, enable: bool) -> Self
Enable or disable the Cranelift IR verifier.
Sourcepub fn dead_store_policy(self, policy: DeadStorePolicy) -> Self
pub fn dead_store_policy(self, policy: DeadStorePolicy) -> Self
Set the dead store elimination policy.
Sourcepub fn tier_promotion(self, policy: TierPromotion) -> Self
pub fn tier_promotion(self, policy: TierPromotion) -> Self
Set when the tiered backend adopts background-compiled code.
Sourcepub fn live_signal(
self,
instance_path: Vec<(String, usize)>,
var_path: Vec<String>,
) -> Self
pub fn live_signal( self, instance_path: Vec<(String, usize)>, var_path: Vec<String>, ) -> Self
Mark a signal as externally observable (live) for dead store elimination.
Sourcepub fn trace(self, trace: TraceOptions) -> Self
pub fn trace(self, trace: TraceOptions) -> Self
Configure compilation tracing options.
Sourcepub fn diagnostics(self, diagnostics: DiagnosticsOptions) -> Self
pub fn diagnostics(self, diagnostics: DiagnosticsOptions) -> Self
Configure diagnostics explicitly for this build.
Sourcepub fn diagnostics_from_env(self) -> Self
pub fn diagnostics_from_env(self) -> Self
Import legacy CELOX_* diagnostics switches once at the API boundary.
pub fn trace_sim_modules(self) -> Self
pub fn trace_pre_atomized_comb_blocks(self) -> Self
pub fn trace_atomized_comb_blocks(self) -> Self
pub fn trace_flattened_comb_blocks(self) -> Self
pub fn trace_scheduled_units(self) -> Self
pub fn trace_pre_optimized_sir(self) -> Self
pub fn trace_post_optimized_sir(self) -> Self
pub fn trace_analyzer_ir(self) -> Self
pub fn trace_pre_optimized_clif(self) -> Self
pub fn trace_post_optimized_clif(self) -> Self
pub fn trace_native(self) -> Self
pub fn trace_mir(self) -> Self
Sourcepub fn trace_native_profile_block(
self,
function: impl Into<String>,
block: u32,
samples: u64,
) -> Self
pub fn trace_native_profile_block( self, function: impl Into<String>, block: u32, samples: u64, ) -> Self
Add one profile-selected native JIT block to state-layout feasibility
analysis. The analysis is captured by Self::build_with_trace or
Self::compile_native_with_trace from the exact merged SIR passed
to native instruction selection.
pub fn trace_on_build(self) -> Self
Source§impl<'a> SimulatorBuilder<'a, Simulator>
impl<'a> SimulatorBuilder<'a, Simulator>
pub fn new(code: &'a str, top: &'a str) -> Self
pub fn from_sources(sources: Vec<(&'a str, &'a Path)>, top: &'a str) -> Self
Sourcepub fn from_frontend(
artifact: FrontendArtifact,
) -> SimulatorBuilder<'static, Simulator>
pub fn from_frontend( artifact: FrontendArtifact, ) -> SimulatorBuilder<'static, Simulator>
Low-level adapter hook for a source-independent frontend artifact.
Frontend crates should wrap this with an artifact-specific public API.
Sourcepub fn from_frontend_with_testbench(
artifact: FrontendArtifact,
sources: Vec<(&'a str, &'a Path)>,
top: &'a str,
) -> Self
pub fn from_frontend_with_testbench( artifact: FrontendArtifact, sources: Vec<(&'a str, &'a Path)>, top: &'a str, ) -> Self
Low-level adapter hook for a Veryl native testbench whose
$sv::Module instances resolve from an external frontend artifact.
Sourcepub fn build(self) -> Result<Simulator<DefaultBackend>, SimulatorError>
pub fn build(self) -> Result<Simulator<DefaultBackend>, SimulatorError>
Compiles the Veryl source and constructs the simulator. Uses a custom native backend when its generated code matches the compilation target, and Cranelift for host-side cross-codegen builds.
Sourcepub fn build_cranelift(self) -> Result<Simulator<JitBackend>, SimulatorError>
pub fn build_cranelift(self) -> Result<Simulator<JitBackend>, SimulatorError>
Compiles using the Cranelift JIT backend.
Sourcepub fn build_interpreter(
self,
) -> Result<Simulator<InterpBackend>, SimulatorError>
pub fn build_interpreter( self, ) -> Result<Simulator<InterpBackend>, SimulatorError>
Compiles SIR, finalizes the state layout, and returns a simulator whose execution units run on the Tier-0 SIR interpreter instead of generated machine code.
This is the target of the all_backends! interp test arm. No
code generation happens on this path: the simulator is ready as
soon as the state layout is finalized, and every execution unit is
driven by crate::interpreter::execute_unit against the same
memory image ABI the compiled backends use.
Sourcepub fn build_tiered(self) -> Result<Simulator<TieredBackend>, SimulatorError>
pub fn build_tiered(self) -> Result<Simulator<TieredBackend>, SimulatorError>
Compiles SIR, finalizes the state layout, and returns a simulator that starts executing on the Tier-0 interpreter immediately while the host’s default compiled tier (native where available, Cranelift otherwise) is compiled in the background.
The first scheduler safe point after background compilation completes adopts the compiled code and moves the live memory image across without translation. If background compilation fails the simulator keeps running on the interpreter.
Sourcepub fn compile_native(self) -> Result<NativeCompilation, SimulatorError>
pub fn compile_native(self) -> Result<NativeCompilation, SimulatorError>
Compiles using the selected native code-generation architecture.
Sourcepub fn compile_native_with_trace(
self,
) -> Result<(NativeCompilation, CompilationTrace), SimulatorError>
pub fn compile_native_with_trace( self, ) -> Result<(NativeCompilation, CompilationTrace), SimulatorError>
Compiles using the selected native code-generation architecture and returns the trace captured from the same native compilation.
Unlike Self::build_with_trace, this method never loads or runs
the generated machine code, so it is available during cross-codegen.
Sourcepub fn build_x86_64(self) -> Result<Simulator<NativeBackend>, SimulatorError>
pub fn build_x86_64(self) -> Result<Simulator<NativeBackend>, SimulatorError>
Compiles for an x86-64 target and initializes the simulator. This includes Cargo cross-builds whose target is x86-64.
Sourcepub fn build_native(self) -> Result<Simulator<NativeBackend>, SimulatorError>
pub fn build_native(self) -> Result<Simulator<NativeBackend>, SimulatorError>
Compiles using the native backend selected for the compilation target.
Sourcepub fn build_native_from_image(
self,
image: NativeProgramImage,
) -> Result<Simulator<NativeBackend>, SimulatorError>
pub fn build_native_from_image( self, image: NativeProgramImage, ) -> Result<Simulator<NativeBackend>, SimulatorError>
Load a previously generated native image without running source parsing, SIR construction, layout, or native machine-code generation here.
This is the execution-side half of the host-codegen/QEMU workflow:
source-independent runtime metadata and the semantic testbench are
restored from image, while the target machine code is taken
entirely from it.
Sourcepub fn build_wasm(self) -> Result<Simulator<WasmBackend>, SimulatorError>
pub fn build_wasm(self) -> Result<Simulator<WasmBackend>, SimulatorError>
Compiles using the Wasmtime WASM backend.
Sourcepub fn run_test(self) -> Result<TestResult, SimulatorError>
pub fn run_test(self) -> Result<TestResult, SimulatorError>
Compiles and runs a native testbench (#[test] module).
Sourcepub fn run_test_cranelift(self) -> Result<TestResult, SimulatorError>
pub fn run_test_cranelift(self) -> Result<TestResult, SimulatorError>
Compiles and runs a testbench using the Cranelift JIT backend.
Sourcepub fn run_test_native(self) -> Result<TestResult, SimulatorError>
pub fn run_test_native(self) -> Result<TestResult, SimulatorError>
Compiles and runs a testbench using the custom native backend.
Sourcepub fn run_test_detailed(self) -> Result<TestResultDetailed, SimulatorError>
pub fn run_test_detailed(self) -> Result<TestResultDetailed, SimulatorError>
Compiles and runs a native testbench, returning assertion results observed before the test finishes or stops on a fatal failure.
Sourcepub fn build_with_trace(self) -> CompilationTraceResult
pub fn build_with_trace(self) -> CompilationTraceResult
Compiles the Veryl source and constructs the core logic simulator, while capturing compilation trace data as configured by TraceOptions.
Source§impl<'a> SimulatorBuilder<'a, Simulation>
impl<'a> SimulatorBuilder<'a, Simulation>
Sourcepub fn build(self) -> Result<Simulation, SimulatorError>
pub fn build(self) -> Result<Simulation, SimulatorError>
Compiles the Veryl source and constructs the timed simulation wrapper.
Auto Trait Implementations§
impl<'a, Target = Simulator> !RefUnwindSafe for SimulatorBuilder<'a, Target>
impl<'a, Target = Simulator> !UnwindSafe for SimulatorBuilder<'a, Target>
impl<'a, Target> Freeze for SimulatorBuilder<'a, Target>where
PhantomData<Target>: Freeze,
impl<'a, Target> Send for SimulatorBuilder<'a, Target>where
PhantomData<Target>: Send,
impl<'a, Target> Sync for SimulatorBuilder<'a, Target>where
PhantomData<Target>: Sync,
impl<'a, Target> Unpin for SimulatorBuilder<'a, Target>where
PhantomData<Target>: Unpin,
impl<'a, Target> UnsafeUnpin for SimulatorBuilder<'a, Target>where
PhantomData<Target>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more