Arithmetic logic unit
In computing, an arithmetic logic unit is a combinational digital circuit that performs arithmetic and bitwise operations on integer binary numbers. This is in contrast to a floating-point unit, which operates on floating point numbers. (Wikipedia)
A single bit of an ALU:
- To do a - b, we set ai = 0, bi = 1, carryIn = if(LSB) 1: 0;
- The reason why bi = 1 and carryIn = 1 is because the former flips the bits, and then carryIn will add 1 (which is the operation to *= -1 a number). This is not very useful to think about for just a single bit ALU.
- CarryIn into a multi-bit ALU is generally hardwired in so that whenever bi = 1, then the LSB would have a CarryIn of 1.
- Overflow detection is some hardware that will detect hardware. It looks at the MSB of the two incoming operands (after ai and bi are applied), and the result.