pub struct Memory {
pub size: usize,
/* private fields */
}
Expand description
Heap allocated, little-endian implementation of memory.
Fields§
§size: usize
Implementations§
Source§impl Memory
impl Memory
Sourcepub fn program_le_bytes(&mut self, bytes: &[u8]) -> Result<(), RiscvError>
pub fn program_le_bytes(&mut self, bytes: &[u8]) -> Result<(), RiscvError>
Program the memory from a vector of little-endian bytes.
Sourcepub fn program_words(&mut self, words: &[u32]) -> Result<(), RiscvError>
pub fn program_words(&mut self, words: &[u32]) -> Result<(), RiscvError>
Program the memory from a vector of words.
Sourcepub fn program_from_file(&mut self, path: &Path) -> Result<u32, RiscvError>
pub fn program_from_file(&mut self, path: &Path) -> Result<u32, RiscvError>
Program the memory from a binary file generally created by gcc or clang.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Memory
impl<'de> Deserialize<'de> for Memory
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Memory for Memory
impl Memory for Memory
Source§fn fetch(&self, pc: u32) -> Result<u32, RiscvError>
fn fetch(&self, pc: u32) -> Result<u32, RiscvError>
This should have the same behavior as
read_word
, with the distinction that
it does not generate logs or count as an access for the purpose of performance
counters.Source§fn read_word(&self, addr: u32) -> Result<u32, RiscvError>
fn read_word(&self, addr: u32) -> Result<u32, RiscvError>
Read a 32-bit word from the address
addr
. Returns a Result
containing
an error, or the u32
data contained.Source§fn read_half_word(&self, addr: u32) -> Result<u32, RiscvError>
fn read_half_word(&self, addr: u32) -> Result<u32, RiscvError>
Read a 16-bit half-word from the address
addr
. Returns a Result
containing
an error, or the u32
data contained.Source§fn read_byte(&self, addr: u32) -> Result<u32, RiscvError>
fn read_byte(&self, addr: u32) -> Result<u32, RiscvError>
Read a byte from the address
addr
. Returns a Result
containing
an error, or the u32
data contained.Source§fn write_word(&mut self, addr: u32, data: u32) -> Result<(), RiscvError>
fn write_word(&mut self, addr: u32, data: u32) -> Result<(), RiscvError>
Write a 32-bit word
data
to the address addr
. Returns a Result
containing
an error, otherwise returns an empty Result
. Read moreSource§fn write_half_word(&mut self, addr: u32, data: u32) -> Result<(), RiscvError>
fn write_half_word(&mut self, addr: u32, data: u32) -> Result<(), RiscvError>
Write 16-bit half-word
data
to the address addr
. Returns a Result
containing
an error, otherwise returns an empty Result
. Read moreSource§fn write_byte(&mut self, addr: u32, data: u32) -> Result<(), RiscvError>
fn write_byte(&mut self, addr: u32, data: u32) -> Result<(), RiscvError>
Write byte
data
to the address addr
. Returns a Result
containing
an error, otherwise returns an empty Result
. Read moreAuto Trait Implementations§
impl Freeze for Memory
impl RefUnwindSafe for Memory
impl Send for Memory
impl Sync for Memory
impl Unpin for Memory
impl UnwindSafe for Memory
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