ALU with function
This module explains how to build a Programmable 1-bit ALU. In computing, an arithmetic logic unit (ALU) is a digital circuit that performs arithmetic and logical operations. The ALU is a fundamental building block of the central processing unit of a computer, and even the simplest microprocessors contain one for purposes such as maintaining timers.
Most ALUs can perform the following operations:
Bitwise logic operations (AND, NOT, OR, XOR)
Integer arithmetic operations (addition, subtraction, and sometimes multiplication and division, though this is more expensive)
Bit-shifting operations (shifting or rotating a word by a specified number of bits to the left or right, with or without sign extension). Shifts can be seen as multiplications and divisions by a power of two.
Inputs and Outputs
The inputs to the ALU are the data to be operated on (called operands) and a code from the control unit indicating which operation to perform. Its output is the result of the computation.