Skip to main content

Bus

Struct Bus 

Source
pub struct Bus {
    pub ram: Memory,
    pub console: Console,
    pub timer: Timer,
    pub block: BlockDevice,
}
Expand description

RAM plus the memory-mapped devices.

Addresses at or above zero go to RAM. Addresses inside the device range go to whichever device owns the slot. Addresses below the device range are RAM as well, so the negative half is not reserved wholesale.

Fields§

§ram: Memory

Random access memory.

§console: Console

The console.

§timer: Timer

The tick counter.

§block: BlockDevice

The block device.

Implementations§

Source§

impl Bus

Source

pub fn new(console: Console, timer: Timer, block: BlockDevice) -> Bus

A bus with empty RAM and the given devices.

Source

pub fn with_image(image: impl Into<Vec<u8>>) -> Bus

A bus with a console, a timer, and a block device holding image.

Source

pub fn tick(&mut self)

Advances the timer by one tick.

Trait Implementations§

Source§

impl Addressable for Bus

Source§

fn is_privileged(&self, addr: Word) -> bool

Device addresses need supervisor privilege; RAM does not.

Source§

fn interrupts(&self) -> Word

One trit per source: positive while that device is asserting.

Source§

fn read_tryte(&mut self, addr: Word) -> Result<Tryte, MemoryError>

Reads one tryte.
Source§

fn write_tryte(&mut self, addr: Word, value: Tryte) -> Result<(), MemoryError>

Writes one tryte.
Source§

fn read_word(&mut self, addr: Word) -> Result<Word, MemoryError>

Reads a word: three trytes, least significant first.
Source§

fn write_word(&mut self, addr: Word, value: Word) -> Result<(), MemoryError>

Writes a word: three trytes, least significant first.

Auto Trait Implementations§

§

impl Freeze for Bus

§

impl RefUnwindSafe for Bus

§

impl Send for Bus

§

impl Sync for Bus

§

impl Unpin for Bus

§

impl UnsafeUnpin for Bus

§

impl UnwindSafe for Bus

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>,

Source§

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>,

Source§

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.