pub struct RiscV { /* private fields */ }
Expand description
A struct to hold the state of a RiscV core.
Implementations§
source§impl RiscV
impl RiscV
sourcepub fn step<M: Memory>(&mut self, memory: &mut M) -> StepResult
pub fn step<M: Memory>(&mut self, memory: &mut M) -> StepResult
Fetch, execute, and retire a single instruction.
When the core attempts to interact with memory, whether to fetch an instruction,
to perform a load or store operation, etc, it makes use of the supplied memory
.
sourcepub fn step_with_retired<M: Memory>(
&mut self,
memory: &mut M
) -> (StepResult, Option<Instruction>)
pub fn step_with_retired<M: Memory>( &mut self, memory: &mut M ) -> (StepResult, Option<Instruction>)
Same as step
, but returns the decoded instruction.
sourcepub fn set_reg<R: Into<Reg>>(&mut self, reg: R, reg_val: RegVal)
pub fn set_reg<R: Into<Reg>>(&mut self, reg: R, reg_val: RegVal)
Sets the given register to the given value.
// sets the the stack pointer, `sp`, (also known as `x2`) to the value `0x2000_0000`.
riscv.set_reg(2, 0x2000_0000.into());
sourcepub fn reg<R: Into<Reg>>(&self, reg: R) -> RegVal
pub fn reg<R: Into<Reg>>(&self, reg: R) -> RegVal
Gets the value of the given register.
// gets the value of the return address register, `ra`, (also known as `x1`).
riscv.reg(1);
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for RiscV
impl Send for RiscV
impl Sync for RiscV
impl Unpin for RiscV
impl UnwindSafe for RiscV
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
Mutably borrows from an owned value. Read more