Trait MemoryTrait

Source
pub trait MemoryTrait {
    // Required methods
    fn fetch(&self, pc: u32) -> Result<u32, RiscvError>;
    fn read_word(&self, addr: u32) -> Result<u32, RiscvError>;
    fn read_half_word(&self, addr: u32) -> Result<u32, RiscvError>;
    fn read_byte(&self, addr: u32) -> Result<u32, RiscvError>;
    fn write_word(&mut self, addr: u32, data: u32) -> Result<(), RiscvError>;
    fn write_half_word(
        &mut self,
        addr: u32,
        data: u32,
    ) -> Result<(), RiscvError>;
    fn write_byte(&mut self, addr: u32, data: u32) -> Result<(), RiscvError>;
}

Required Methods§

Source

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>

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>

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>

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>

Write a 32-bit word data to the address addr. Returns a Result containing an error, otherwise returns an empty Result.

This makes no guarantees about endianness, only that read_word returns the same data after a write_word.

Source

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.

This makes no guarantees about endianness, only that read_half_word returns the same data after a write_half_word.

Source

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.

This makes no guarantees about endianness, only that read_byte returns the same data after a write_byte.

Implementors§