Trait miden_processor::ProcessState

source ·
pub trait ProcessState {
    // Required methods
    fn clk(&self) -> u32;
    fn ctx(&self) -> ContextId;
    fn fmp(&self) -> u64;
    fn get_stack_item(&self, pos: usize) -> Felt;
    fn get_stack_word(&self, word_idx: usize) -> Word;
    fn get_stack_state(&self) -> Vec<Felt>;
    fn get_mem_value(&self, ctx: ContextId, addr: u32) -> Option<Word>;
    fn get_mem_state(&self, ctx: ContextId) -> Vec<(u64, Word)>;
}
Expand description

A trait that defines a set of methods which allow access to the state of the process.

Required Methods§

source

fn clk(&self) -> u32

Returns the current clock cycle of a process.

source

fn ctx(&self) -> ContextId

Returns the current execution context ID.

source

fn fmp(&self) -> u64

Returns the current value of the free memory pointer.

source

fn get_stack_item(&self, pos: usize) -> Felt

Returns the value located at the specified position on the stack at the current clock cycle.

source

fn get_stack_word(&self, word_idx: usize) -> Word

Returns a word located at the specified word index on the stack.

Specifically, word 0 is defined by the first 4 elements of the stack, word 1 is defined by the next 4 elements etc. Since the top of the stack contains 4 word, the highest valid word index is 3.

The words are created in reverse order. For example, for word 0 the top element of the stack will be at the last position in the word.

Creating a word does not change the state of the stack.

source

fn get_stack_state(&self) -> Vec<Felt>

Returns stack state at the current clock cycle. This includes the top 16 items of the stack + overflow entries.

source

fn get_mem_value(&self, ctx: ContextId, addr: u32) -> Option<Word>

Returns a word located at the specified context/address, or None if the address hasn’t been accessed previously.

source

fn get_mem_state(&self, ctx: ContextId) -> Vec<(u64, Word)>

Returns the entire memory state for the specified execution context at the current clock cycle.

The state is returned as a vector of (address, value) tuples, and includes addresses which have been accessed at least once.

Implementors§