[][src]Struct riscy::RiscV

pub struct RiscV { /* fields omitted */ }

A struct to hold the state of a RiscV core.

Implementations

impl RiscV[src]

pub fn new() -> Self[src]

Create a new RiscV core with all of its registers zeroed out.

pub fn step<M: Memory>(&mut self, memory: &mut M) -> StepResult[src]

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.

pub fn step_with_retired<M: Memory>(
    &mut self,
    memory: &mut M
) -> (StepResult, Option<Instruction>)
[src]

Same as step, but returns the decoded instruction.

pub fn set_reg<R: Into<Reg>>(&mut self, reg: R, reg_val: RegVal)[src]

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());

pub fn reg<R: Into<Reg>>(&self, reg: R) -> RegVal[src]

Gets the value of the given register.

// gets the value of the return address register, `ra`, (also known as `x1`).
riscv.reg(1);

pub fn set_pc(&mut self, addr: Addr)[src]

Sets the value of the program counter to the given address.

This is useful for specifying the entry point to the program when first initializing the machine.

pub fn pc(&self) -> Addr[src]

Gets the value of the program counter.

Trait Implementations

impl Display for RiscV[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.