pub struct Alu {
pub x: Signal16,
pub y: Signal16,
pub zx: Signal,
pub nx: Signal,
pub zy: Signal,
pub ny: Signal,
pub f: Signal,
pub no: Signal,
pub out: Signal16,
pub zr: Signal,
pub ng: Signal,
}Expand description
Arithmetic Logic Unit
Fields
x: Signal16y: Signal16zx: SignalSet x input to zero
nx: SignalNegates x input
zy: SignalSet y input to zero
ny: Signalf: Signal- False selects the & function
- True selects the + function
no: SignalNegates the output
out: Signal16zr: SignalWhether the output is zero
ng: SignalWhether the output is negative
Implementations
sourceimpl Alu
impl Alu
sourcepub fn sim(
&mut self,
x: Signal16,
y: Signal16,
zx: Signal,
nx: Signal,
zy: Signal,
ny: Signal,
f: Signal,
no: Signal
) -> (Signal16, Signal, Signal)
pub fn sim(
&mut self,
x: Signal16,
y: Signal16,
zx: Signal,
nx: Signal,
zy: Signal,
ny: Signal,
f: Signal,
no: Signal
) -> (Signal16, Signal, Signal)
Carries out the ALU simulation.
It takes as input two main signals: x and y. Then the following:
zx: Setxto zero.nx: Negatex.zy: Setyto zero.ny: Negatey.f:LOselects the&functionHIselects the+function
no: Negateoutsignal.
It can return one of the following:
0, 1, -1, x, y, !x, !y, -x, -y,
x+1, y+1, x-1, y-1, x+y, x-y, y-x, x&y, x|y,
And two more signals which tell whether the result is zero or negative in this exact order.
pub fn set_x(&mut self, x: Signal16)
pub fn set_y(&mut self, y: Signal16)
pub fn out(&self) -> Signal16
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Alu
impl Send for Alu
impl Sync for Alu
impl Unpin for Alu
impl UnwindSafe for Alu
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more