openvm_circuit::arch

Trait VmAdapterChip

Source
pub trait VmAdapterChip<F> {
    type ReadRecord: Send;
    type WriteRecord: Send;
    type Air: BaseAir<F> + Clone;
    type Interface: VmAdapterInterface<F>;

    // Required methods
    fn preprocess(
        &mut self,
        memory: &mut MemoryController<F>,
        instruction: &Instruction<F>,
    ) -> Result<(<Self::Interface as VmAdapterInterface<F>>::Reads, Self::ReadRecord)>;
    fn postprocess(
        &mut self,
        memory: &mut MemoryController<F>,
        instruction: &Instruction<F>,
        from_state: ExecutionState<u32>,
        output: AdapterRuntimeContext<F, Self::Interface>,
        read_record: &Self::ReadRecord,
    ) -> Result<(ExecutionState<u32>, Self::WriteRecord)>;
    fn generate_trace_row(
        &self,
        row_slice: &mut [F],
        read_record: Self::ReadRecord,
        write_record: Self::WriteRecord,
        aux_cols_factory: &MemoryAuxColsFactory<F>,
    );
    fn air(&self) -> &Self::Air;
}
Expand description

The adapter owns all memory accesses and timestamp changes. The adapter AIR should also own ExecutionBridge and MemoryBridge.

Required Associated Types§

Source

type ReadRecord: Send

Records generated by adapter before main instruction execution

Source

type WriteRecord: Send

Records generated by adapter after main instruction execution

Source

type Air: BaseAir<F> + Clone

AdapterAir should not have public values

Source

type Interface: VmAdapterInterface<F>

Required Methods§

Source

fn preprocess( &mut self, memory: &mut MemoryController<F>, instruction: &Instruction<F>, ) -> Result<(<Self::Interface as VmAdapterInterface<F>>::Reads, Self::ReadRecord)>

Given instruction, perform memory reads and return only the read data that the integrator needs to use. This is called at the start of instruction execution.

The implementor may choose to store data in the Self::ReadRecord struct, for example in an Option, which will later be sent to the postprocess method.

Source

fn postprocess( &mut self, memory: &mut MemoryController<F>, instruction: &Instruction<F>, from_state: ExecutionState<u32>, output: AdapterRuntimeContext<F, Self::Interface>, read_record: &Self::ReadRecord, ) -> Result<(ExecutionState<u32>, Self::WriteRecord)>

Given instruction and the data to write, perform memory writes and return the (record, timestamp_delta) of the full adapter record for this instruction. This is guaranteed to be called after preprocess.

Source

fn generate_trace_row( &self, row_slice: &mut [F], read_record: Self::ReadRecord, write_record: Self::WriteRecord, aux_cols_factory: &MemoryAuxColsFactory<F>, )

Populates row_slice with values corresponding to record. The provided row_slice will have length equal to self.air().width(). This function will be called for each row in the trace which is being used, and all other rows in the trace will be filled with zeroes.

Source

fn air(&self) -> &Self::Air

Implementors§