Saturday, 1 September 2012

ALU - logical design




First design for the ALU. The ALU takes two 8-bit inputs 'A' and 'B' plus the Carry Flag 'C' and can perform 6 operations based upon how control inputs 1 to 6 are set.

Mathematical Operations

  • Add
  • Subtract
Subtraction relies on the fact that A + (-B) is the same A - B. B is converted to a negative number using 2s complement representation which requires all the bits to be inverted and then adding 1 by forcing the carry flag input to 1.

Logical Operations

  • AND
  • OR
  • XOR
  • NOT 

Outputs

  • Result
  • Zero flag - 1 if the output is equal to zero; 0 if the output is non-zero. The zero flag is set for every operation.
  • Carry flag
The intention of the Zero Flag is to support Conditional Jump statements. It will be possible to implement compare instructions by not writing the Result to the Accumulator register.

The control lines are used as follows.

Control 1

  • '0' select non-inverted 'B' into Adder (i.e. perform addition)
  • '1' select inverted 'B' into Adder. (used to to perform subtraction)

Controls 2 and 3 

  • '23'
  • '00' select Carry Flag as input to Adder
  • '10' force Carry Flag value to '1' as input into Adder (used to perform subtraction)
  • '01' force Carry Flag value to '0' as input into Adder

Controls  4, 5 and 6 - select which operation to output as the result

  • '456'
  • '000' output the result of 'A' AND 'B'
  • '100' output the result of 'A' OR 'B'
  • '010' output the result of 'A' XOR 'B'
  • '110' output the result of NOT 'B'
  • '001' output the result of the Adder
NB Control lines 1 and 3 used to enable subtraction have been kept separate on the off chance it is useful to be able to control inversion and carry separately. 

No comments:

Post a Comment