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: Signal

Set x input to zero

nx: Signal

Negates x input

zy: Signal

Set y input to zero

ny: Signalf: Signal
  • False selects the & function
  • True selects the + function
no: Signal

Negates the output

out: Signal16zr: Signal

Whether the output is zero

ng: Signal

Whether the output is negative

Implementations

Carries out the ALU simulation.

It takes as input two main signals: x and y. Then the following:

  • zx: Set x to zero.
  • nx: Negate x.
  • zy: Set y to zero.
  • ny: Negate y.
  • f:
    • LO selects the & function
    • HI selects the + function
  • no: Negate out signal.

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.

Trait Implementations

Returns the “default value” for a type. Read more
Evaluates the logic expression as we do with arithmetic without advancing the time. Read more
Carries out the tick-phase of a clock cycle: LOW
Carries out the tock-phase of a clock cycle: HIGH

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.