Trait lc3_ensemble::sim::device::ExternalDevice

source ·
pub trait ExternalDevice:
    Send
    + Sync
    + 'static {
    // Required methods
    fn io_read(&mut self, addr: u16, effectful: bool) -> Option<u16>;
    fn io_write(&mut self, addr: u16, data: u16) -> bool;
    fn io_reset(&mut self);
    fn poll_interrupt(&mut self) -> Option<Interrupt>;
}
Expand description

An external device, which can be accessed via memory-mapped IO or via interrupts.

Required Methods§

source

fn io_read(&mut self, addr: u16, effectful: bool) -> Option<u16>

Reads the data at the given memory-mapped address.

If successful, this returns the value returned from that address. If unsuccessful, this returns None.

source

fn io_write(&mut self, addr: u16, data: u16) -> bool

Writes the data to the given memory-mapped address.

This returns whether the write was successful or not.

source

fn io_reset(&mut self)

Resets device.

source

fn poll_interrupt(&mut self) -> Option<Interrupt>

During each instruction cycle, this function is called once to see whether to trigger an interrupt.

Of course, in the real world, the devices would send an interrupt signal which would be detected, but that can’t really be done here.

Implementations on Foreign Types§

source§

impl<D: ExternalDevice> ExternalDevice for Arc<Mutex<D>>

source§

fn io_read(&mut self, addr: u16, effectful: bool) -> Option<u16>

source§

fn io_write(&mut self, addr: u16, data: u16) -> bool

source§

fn io_reset(&mut self)

source§

fn poll_interrupt(&mut self) -> Option<Interrupt>

source§

impl<D: ExternalDevice> ExternalDevice for Arc<RwLock<D>>

source§

fn io_read(&mut self, addr: u16, effectful: bool) -> Option<u16>

source§

fn io_write(&mut self, addr: u16, data: u16) -> bool

source§

fn io_reset(&mut self)

source§

fn poll_interrupt(&mut self) -> Option<Interrupt>

Implementors§