MathAccelerator

Struct MathAccelerator 

Source
#[repr(C, packed(1))]
pub struct MathAccelerator { pub divout_fraction: RO<u32>, pub divout_whole: RO<u32>, pub multin_a: WO<u32>, pub multin_b: WO<u32>, pub multout: RO<u64>, }
Expand description

Registers for Math Acceleration

See the MEGA64 book, Section G-19. The hardware registers use little endian storage.

Fields§

§divout_fraction: RO<u32>

32-bit fractional part DIVOUT(0-3) of MULTINA divided by MULTINB

§divout_whole: RO<u32>

32-bit whole part DIVOUT(4-7) of MULTINA divided by MULTINB

§multin_a: WO<u32>

32-bit input A

§multin_b: WO<u32>

32-bit input B

§multout: RO<u64>

64-bit product MULTOUT of MULTINA and MULTINB

Implementations§

Source§

impl MathAccelerator

Source

pub fn multiply(&self, a: u32, b: u32) -> u64

32 bit multiplication using hardware multiplier

Cycles: 1

Source

pub fn multiply_divide(&self, a: u32, b: u32) -> (u64, u32, u32)

32 bit multiplication and division using hardware multiplier

Returns a tuple with:

  1. 64-bit a x b product
  2. 32-bit whole part of a / b;
  3. 32-bit fractional part of a / b

Cycles: less than 20

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

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.