Skip to main content

SimulatorBuilder

Struct SimulatorBuilder 

Source
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.

Source

pub fn sources(&self) -> &[(&'a str, &'a Path)]

Returns the source files passed to this builder.

Source

pub fn top(&self) -> &str

Returns the top module name.

Source

pub fn four_state_enabled(&self) -> bool

Returns whether four-state simulation is enabled for this builder.

Source

pub fn with_metadata(self, metadata: Metadata) -> Self

Supply project metadata (clock/reset settings, etc.) instead of defaults.

Source

pub fn clock_type(self, clock_type: ClockType) -> Self

Override the clock type (posedge/negedge) from metadata or defaults.

Source

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.

Source

pub fn param(self, name: &str, value: u64) -> Self

Override a top-level module parameter value.

Source

pub fn with_injected_components(self, components: InjectedComponents) -> Self

Make in-process component implementations available as $comp::<name>.

Source

pub fn vcd<P: AsRef<Path>>(self, path: P) -> Self

Enable VCD dumping to the specified file.

Source

pub fn four_state(self, enable: bool) -> Self

Enable 4-state (0, 1, X, Z) simulation mode.

Source

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.

Source

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.

Source

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.

Source

pub fn enable_pass(self, pass: SirPass) -> Self

Enable a specific SIR pass, overriding the OptLevel default.

Source

pub fn disable_pass(self, pass: SirPass) -> Self

Disable a specific SIR pass, overriding the OptLevel default.

Source

pub fn optimize(self, enable: bool) -> Self

Enable or disable all SIRT optimization passes at once. Shorthand: trueOptLevel::O1, falseOptLevel::O0.

Source

pub fn optimize_options(self, options: OptimizeOptions) -> Self

Set per-pass optimizer flags directly.

Source

pub fn x86_slp(self, enable: bool) -> Self

Source

pub fn cranelift_options(self, options: CraneliftOptions) -> Self

Set fine-grained Cranelift backend options.

Source

pub fn regalloc_algorithm(self, algo: RegallocAlgorithm) -> Self

Set the register allocator algorithm.

Source

pub fn enable_alias_analysis(self, enable: bool) -> Self

Enable or disable alias analysis in the Cranelift egraph pass.

Source

pub fn enable_verifier(self, enable: bool) -> Self

Enable or disable the Cranelift IR verifier.

Source

pub fn dead_store_policy(self, policy: DeadStorePolicy) -> Self

Set the dead store elimination policy.

Source

pub fn tier_promotion(self, policy: TierPromotion) -> Self

Set when the tiered backend adopts background-compiled code.

Source

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.

Source

pub fn trace(self, trace: TraceOptions) -> Self

Configure compilation tracing options.

Source

pub fn diagnostics(self, diagnostics: DiagnosticsOptions) -> Self

Configure diagnostics explicitly for this build.

Source

pub fn diagnostics_from_env(self) -> Self

Import legacy CELOX_* diagnostics switches once at the API boundary.

Source

pub fn trace_sim_modules(self) -> Self

Source

pub fn trace_pre_atomized_comb_blocks(self) -> Self

Source

pub fn trace_atomized_comb_blocks(self) -> Self

Source

pub fn trace_flattened_comb_blocks(self) -> Self

Source

pub fn trace_scheduled_units(self) -> Self

Source

pub fn trace_pre_optimized_sir(self) -> Self

Source

pub fn trace_post_optimized_sir(self) -> Self

Source

pub fn trace_analyzer_ir(self) -> Self

Source

pub fn trace_pre_optimized_clif(self) -> Self

Source

pub fn trace_post_optimized_clif(self) -> Self

Source

pub fn trace_native(self) -> Self

Source

pub fn trace_mir(self) -> Self

Source

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.

Source

pub fn trace_on_build(self) -> Self

Source

pub fn false_loop( self, from: (Vec<(String, usize)>, Vec<String>), to: (Vec<(String, usize)>, Vec<String>), ) -> Self

Explicitly ignore a dependency between two signals.

Source

pub fn true_loop( self, from: (Vec<(String, usize)>, Vec<String>), to: (Vec<(String, usize)>, Vec<String>), max_iter: usize, ) -> Self

Mark a dependency as a “true loop” and specify its convergence limit.

Source§

impl<'a> SimulatorBuilder<'a, Simulator>

Source

pub fn new(code: &'a str, top: &'a str) -> Self

Source

pub fn from_sources(sources: Vec<(&'a str, &'a Path)>, top: &'a str) -> Self

Source

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.

Source

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.

Source

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.

Source

pub fn build_cranelift(self) -> Result<Simulator<JitBackend>, SimulatorError>

Compiles using the Cranelift JIT backend.

Source

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.

Source

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.

Source

pub fn compile_native(self) -> Result<NativeCompilation, SimulatorError>

Compiles using the selected native code-generation architecture.

Source

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.

Source

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.

Source

pub fn build_native(self) -> Result<Simulator<NativeBackend>, SimulatorError>

Compiles using the native backend selected for the compilation target.

Source

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.

Source

pub fn build_wasm(self) -> Result<Simulator<WasmBackend>, SimulatorError>

Compiles using the Wasmtime WASM backend.

Source

pub fn run_test(self) -> Result<TestResult, SimulatorError>

Compiles and runs a native testbench (#[test] module).

Source

pub fn run_test_cranelift(self) -> Result<TestResult, SimulatorError>

Compiles and runs a testbench using the Cranelift JIT backend.

Source

pub fn run_test_native(self) -> Result<TestResult, SimulatorError>

Compiles and runs a testbench using the custom native backend.

Source

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.

Source

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>

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<D> OwoColorize for D

Source§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
Source§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
Source§

fn black(&self) -> FgColorDisplay<'_, Black, Self>

Change the foreground color to black
Source§

fn on_black(&self) -> BgColorDisplay<'_, Black, Self>

Change the background color to black
Source§

fn red(&self) -> FgColorDisplay<'_, Red, Self>

Change the foreground color to red
Source§

fn on_red(&self) -> BgColorDisplay<'_, Red, Self>

Change the background color to red
Source§

fn green(&self) -> FgColorDisplay<'_, Green, Self>

Change the foreground color to green
Source§

fn on_green(&self) -> BgColorDisplay<'_, Green, Self>

Change the background color to green
Source§

fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>

Change the foreground color to yellow
Source§

fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>

Change the background color to yellow
Source§

fn blue(&self) -> FgColorDisplay<'_, Blue, Self>

Change the foreground color to blue
Source§

fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>

Change the background color to blue
Source§

fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to magenta
Source§

fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to magenta
Source§

fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to purple
Source§

fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to purple
Source§

fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>

Change the foreground color to cyan
Source§

fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>

Change the background color to cyan
Source§

fn white(&self) -> FgColorDisplay<'_, White, Self>

Change the foreground color to white
Source§

fn on_white(&self) -> BgColorDisplay<'_, White, Self>

Change the background color to white
Source§

fn default_color(&self) -> FgColorDisplay<'_, Default, Self>

Change the foreground color to the terminal default
Source§

fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>

Change the background color to the terminal default
Source§

fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>

Change the foreground color to bright black
Source§

fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>

Change the background color to bright black
Source§

fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>

Change the foreground color to bright red
Source§

fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>

Change the background color to bright red
Source§

fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>

Change the foreground color to bright green
Source§

fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>

Change the background color to bright green
Source§

fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>

Change the foreground color to bright yellow
Source§

fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>

Change the background color to bright yellow
Source§

fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>

Change the foreground color to bright blue
Source§

fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>

Change the background color to bright blue
Source§

fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright magenta
Source§

fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright magenta
Source§

fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright purple
Source§

fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright purple
Source§

fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>

Change the foreground color to bright cyan
Source§

fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>

Change the background color to bright cyan
Source§

fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>

Change the foreground color to bright white
Source§

fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>

Change the background color to bright white
Source§

fn bold(&self) -> BoldDisplay<'_, Self>

Make the text bold
Source§

fn dimmed(&self) -> DimDisplay<'_, Self>

Make the text dim
Source§

fn italic(&self) -> ItalicDisplay<'_, Self>

Make the text italicized
Source§

fn underline(&self) -> UnderlineDisplay<'_, Self>

Make the text underlined
Make the text blink
Make the text blink (but fast!)
Source§

fn reversed(&self) -> ReversedDisplay<'_, Self>

Swap the foreground and background colors
Source§

fn hidden(&self) -> HiddenDisplay<'_, Self>

Hide the text
Source§

fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>

Cross out the text
Source§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
Source§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
Source§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
Source§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
Source§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
Source§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
Source§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more