- Author: Richard Xu, Louis Barbosa, Hallie Ho, Emmy Xu, Gia Bhatia, Emily Chen
- Description: The 4-bit ALU is designed to perform basic arithmetic and logical operations on 4-bit binary numbers
- GitHub repository
- Clock: 0 Hz

The 4-Bit ALU is designed to perform various arithmetic and logical operations on 4-bit binary numbers. It supports operations such as addition, subtraction, multiplication, division, and several logical operations. Additionally, it includes an encryption function that can be used to encrypt 4-bit inputs using an 8-bit key. This capstone project is from the MIT BWSI Basics of ASICs class.

The module accepts two 4-bit binary numbers, `a`

and `b`

, and a 4-bit operation code (`opcode`

) that determines the operation to be performed. The results are then output through the `uo_out`

wire, while additional status information, such as carry out and overflow, is output through the `uio_out`

wire. The `uio_oe`

wire controls the enable or disable functionality for the `uio_in`

and `uio_out`

wires.

**ADD**: Adds`a`

and`b`

, producing a 4-bit result and a carry out.**SUB**: Subtracts`b`

from`a`

, producing a 4-bit result and a borrow indication.**MUL**: Multiplies`a`

and`b`

, producing an 8-bit result.**DIV**: Divides`a`

by`b`

, producing a 4-bit quotient and remainder. Division by zero is handled by returning a zero result.**AND**: Performs a logical AND operation on`a`

and`b`

.**OR**: Performs a logical OR operation on`a`

and`b`

.**XOR**: Performs a logical XOR operation on`a`

and`b`

.**NOT**: Performs a logical NOT operation on`a`

, with`b`

being ignored.**ENC**: Encrypts the inputs`a`

and`b`

using an 8-bit key derived from concatenating`a`

and`b`

. The encryption function applies an XOR operation between this 8-bit concatenated value and a fixed 8-bit key. The result is an 8-bit encrypted value.

To test this 4-bit ALU chip, set the values for a and b based on the 4-bit binary values for each, as well as the 4-bit operation code. The output can be up to 8-bits, using the uo pins along with the first 4 bidirectional pins. The uio pin 6 is used for the carry out, and the uio 7 is used for the overflow.

N/A

# | Input | Output | Bidirectional |
---|---|---|---|

0 | a[0] | result[0] | opcode[0] |

1 | a[1] | result[1] | opcode[1] |

2 | a[2] | result[2] | opcode[2] |

3 | a[3] | result[3] | opcode[3] |

4 | b[0] | result[4] | |

5 | b[1] | result[5] | |

6 | b[2] | result[6] | carry_out |

7 | b[3] | result[7] | overflow |