pub struct Program {
pub instructions: Vec<Instruction>,
pub pc_start: u32,
pub pc_base: u32,
pub memory_image: HashMap<u32, u32>,
pub preprocessed_shape: Option<Shape<RiscvAirId>>,
}
Expand description
A program that can be executed by the SP1 zkVM.
Contains a series of instructions along with the initial memory image. It also contains the start address and base address of the program.
Fields§
§instructions: Vec<Instruction>
The instructions of the program.
pc_start: u32
The start address of the program.
pc_base: u32
The base address of the program.
memory_image: HashMap<u32, u32>
The initial memory image, useful for global constants.
preprocessed_shape: Option<Shape<RiscvAirId>>
The shape for the preprocessed tables.
Implementations§
Source§impl Program
impl Program
Sourcepub fn new(instructions: Vec<Instruction>, pc_start: u32, pc_base: u32) -> Self
pub fn new(instructions: Vec<Instruction>, pc_start: u32, pc_base: u32) -> Self
Create a new Program.
Sourcepub fn from(input: &[u8]) -> Result<Self>
pub fn from(input: &[u8]) -> Result<Self>
Disassemble a RV32IM ELF to a program that be executed by the VM.
§Errors
This function may return an error if the ELF is not valid.
Sourcepub fn from_elf(path: &str) -> Result<Self>
pub fn from_elf(path: &str) -> Result<Self>
Disassemble a RV32IM ELF to a program that be executed by the VM from a file path.
§Errors
This function will return an error if the file cannot be opened or read.
Sourcepub fn fixed_log2_rows<F: Field, A: MachineAir<F>>(
&self,
air: &A,
) -> Option<usize>
pub fn fixed_log2_rows<F: Field, A: MachineAir<F>>( &self, air: &A, ) -> Option<usize>
Custom logic for padding the trace to a power of two according to the proof shape.
Sourcepub fn fetch(&self, pc: u32) -> &Instruction
pub fn fetch(&self, pc: u32) -> &Instruction
Fetch the instruction at the given program counter.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Program
impl<'de> Deserialize<'de> for Program
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<F: PrimeField32> MachineProgram<F> for Program
impl<F: PrimeField32> MachineProgram<F> for Program
Source§fn initial_global_cumulative_sum(&self) -> SepticDigest<F>
fn initial_global_cumulative_sum(&self) -> SepticDigest<F>
Auto Trait Implementations§
impl Freeze for Program
impl RefUnwindSafe for Program
impl Send for Program
impl Sync for Program
impl Unpin for Program
impl UnwindSafe for Program
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for 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 more