Skip to main content

InterpMachine

Trait InterpMachine 

Source
pub trait InterpMachine<A> {
    // Required methods
    fn load(
        &mut self,
        addr: &A,
        access: ResolvedAccess<'_>,
        bits: usize,
    ) -> Result<SIRValue, InterpError>;
    fn store(
        &mut self,
        addr: &A,
        access: ResolvedAccess<'_>,
        bits: usize,
        value: &SIRValue,
    ) -> Result<(), InterpError>;
    fn commit(
        &mut self,
        src: &A,
        dst: &A,
        access: ResolvedAccess<'_>,
        bits: usize,
    ) -> Result<(), InterpError>;
    fn notify_triggers(
        &mut self,
        addr: &A,
        access: ResolvedAccess<'_>,
        bits: usize,
        triggers: &[TriggerIdWithKind],
    ) -> Result<(), InterpError>;
    fn notify_trigger_only_store(
        &mut self,
        addr: &A,
        triggers: &[TriggerIdWithKind],
    ) -> Result<(), InterpError>;
    fn capture_store_range(
        &mut self,
        addr: &A,
        access: ResolvedAccess<'_>,
        bits: usize,
    ) -> Result<StoreSnapshot, InterpError>;
    fn enable_comb_captures(
        &mut self,
        addr: &A,
        access: ResolvedAccess<'_>,
        bits: usize,
        before: &StoreSnapshot,
        sites: &[u32],
    ) -> Result<(), InterpError>;
    fn emit_runtime_event(
        &mut self,
        site_id: u32,
        args: &[SIRValue],
    ) -> Result<(), InterpError>;
    fn emit_comb_capture_event(
        &mut self,
        site_id: u32,
        args: &[SIRValue],
        fatal_error_code: Option<i64>,
        consume_enabled: bool,
    ) -> Result<(), InterpError>;
    fn enable_comb_capture_if_changed(
        &mut self,
        old: &SIRValue,
        new: &SIRValue,
        sites: &[u32],
    ) -> Result<(), InterpError>;

    // Provided method
    fn prepare_store(
        &mut self,
        _addr: &A,
        _access: ResolvedAccess<'_>,
        _bits: usize,
    ) -> Result<(), InterpError> { ... }
}
Expand description

Storage and side-effect interface driven by the interpreter.

The production implementation wraps the simulator’s live memory image and event plumbing; tests use an in-memory fake. The address type A matches the executed SIR (for example RegionedAbsoluteAddr).

Required Methods§

Source

fn load( &mut self, addr: &A, access: ResolvedAccess<'_>, bits: usize, ) -> Result<SIRValue, InterpError>

Source

fn store( &mut self, addr: &A, access: ResolvedAccess<'_>, bits: usize, value: &SIRValue, ) -> Result<(), InterpError>

Source

fn commit( &mut self, src: &A, dst: &A, access: ResolvedAccess<'_>, bits: usize, ) -> Result<(), InterpError>

Commit: copy bits at access from src to dst.

Source

fn notify_triggers( &mut self, addr: &A, access: ResolvedAccess<'_>, bits: usize, triggers: &[TriggerIdWithKind], ) -> Result<(), InterpError>

Edge/level triggers attached to a Store or Commit.

The resolved access and width let the machine compare the stored range against its group-entry snapshot for per-kind edge detection.

Source

fn notify_trigger_only_store( &mut self, addr: &A, triggers: &[TriggerIdWithKind], ) -> Result<(), InterpError>

Trigger-only aliased store (bits == 0): no memory write happens and the source register is intentionally undefined; the machine detects a change on the aliased signal and marks its triggers.

Source

fn capture_store_range( &mut self, addr: &A, access: ResolvedAccess<'_>, bits: usize, ) -> Result<StoreSnapshot, InterpError>

Snapshot the stored range before a Store with comb capture sites so the post-store comparison can detect actual changes.

Source

fn enable_comb_captures( &mut self, addr: &A, access: ResolvedAccess<'_>, bits: usize, before: &StoreSnapshot, sites: &[u32], ) -> Result<(), InterpError>

Enable comb capture sites when the stored range differs from the pre-store snapshot.

Source

fn emit_runtime_event( &mut self, site_id: u32, args: &[SIRValue], ) -> Result<(), InterpError>

Source

fn emit_comb_capture_event( &mut self, site_id: u32, args: &[SIRValue], fatal_error_code: Option<i64>, consume_enabled: bool, ) -> Result<(), InterpError>

Emit a comb capture event. Returns Err(InterpError::Fatal) when the event carries a fatal code and its site was enabled, mirroring the compiled unit’s early return.

Source

fn enable_comb_capture_if_changed( &mut self, old: &SIRValue, new: &SIRValue, sites: &[u32], ) -> Result<(), InterpError>

Provided Methods§

Source

fn prepare_store( &mut self, _addr: &A, _access: ResolvedAccess<'_>, _bits: usize, ) -> Result<(), InterpError>

Prepare storage for an upcoming store. Invoked before any pre-store snapshot so the machine can make the destination readable (for example sparse copy-on-write chunk initialization).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§