Struct lc3_ensemble::sim::io::BiChannelIO

source ·
pub struct BiChannelIO { /* private fields */ }
Expand description

An IO that reads from one channel and writes to another.

This binds the reader channel to the KBSR and KBDR. When a character is ready from the reader channel, the KBSR status is enabled and the character is accessible from the KBDR.

This binds the writer channel to the DSR and DDR. When a character is ready to be written to the writer channel, the DSR status is enabled and the character can be written to the DDR.

This IO type also exposes the MCR in the MCR MMIO address.

Implementations§

source§

impl BiChannelIO

source

pub fn new( reader: impl Read + Send + 'static, writer: impl Write + Send + 'static, flush_every_byte: bool ) -> Self

Creates a new bi-channel IO device with the given reader and writer.

This invokes the reader’s Read::read method every time the IO input receives a byte. Note that internally, this uses the Read::bytes iterator. Thus, the same cautions of using that iterator apply here.

This calls the writer’s Write::write_all method every time a byte needs to be written to the IO output.

This IO calls Write::flush when the IO is ready to drop. This function also has a flush_every_byte flag, which designates whether Write::flush is also called for every byte. This may be useful to enable for displaying real time output.

This uses threads to read and write from input and output. As such, the channels will continue to poll input and output even when the simulator is not running. As such, care should be taken to not send messages through the reader thread while the simulator is not running.

source

pub fn stdio() -> Self

Creates a bi-channel IO device with std::io::stdin being the reader channel and std::io::stdout being the writer channel.

Note that the simulator will only have access to the input data after a new line is typed (in terminal stdin). Similarly, printed output will only appear once (terminal) stdout is flushed or once a new line is sent.

Trait Implementations§

source§

impl From<BiChannelIO> for SimIO

source§

fn from(value: BiChannelIO) -> Self

Converts to this type from the input type.
source§

impl IODevice for BiChannelIO

source§

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

Reads the data at the given memory-mapped address. Read more
source§

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

Writes the data to the given memory-mapped address. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V