
This project implements a configurable 4-bit Arithmetic Logic Unit (ALU) with registered inputs and an independent, synchronous Status Flag Generator. The architecture is optimized for educational digital design and compact ASIC implementations.
The design contains two internal 4-bit registers: A and B.
The hardware is split into two specialized combinational blocks:
The project requires synchronous operation. Ensure your clock (clk) is toggling and the active-low reset (rst_n) has been pulsed high-to-low-to-high before starting.
Set the operation code on the ALUcontrol bus (uio_in[2:0]). The result will instantly appear as a combinational output on uo_out[7:0].
| ALUcontrol (uio[2:0]) | Operation | Mathematical Description |
|---|---|---|
| 3'b000 | Addition | out = A + B |
| 3'b001 | Subtraction | out = A - B |
| 3'b010 | Logical Shift Right | out = A >> 1 (Padded with 0s) |
| 3'b011 | Logical Shift Left | out = A << 1 (Padded with 0s) |
| 3'b100 | Bitwise AND | out = A & B |
| 3'b101 | Bitwise OR | out = A |
| 3'b110 | Bitwise XOR | out = A ^ B |
| 3'b111 | Multiplication | out = A * B |
Set the condition code on the flagcontrol bus (uio_in[6:4]). Read the resulting boolean true/false state from the physical pin uio_out[7].
| flagcontrol (uio[6:4]) | Condition Target | Condition Evaluated (Status_Flag) |
|---|---|---|
| 3'b000 | Register A | 1 if A > B, else 0 |
| 3'b001 | Core Identity | 1 if A == B, else 0 |
| 3'b010 | Register A | 1 if A == 0, else 0 (Zero-detect) |
| 3'b011 | Register A | 1 if A is Even, else 0 (Even parity) |
| 3'b100 | Register B | 1 if B > A, else 0 |
| 3'b101 | Core Identity | 1 if A == B, else 0 (Redundant Check) |
| 3'b110 | Register B | 1 if B == 0, else 0 (Zero-detect) |
| 3'b111 | Register B | 1 if B is Even, else 0 (Even parity) |
This project is completely self-contained and does not mandate specialized external peripherals or custom PMODs to function. It is fully compatible with standard digital testing environments.
| # | Input | Output | Bidirectional |
|---|---|---|---|
| 0 | A[0] (Input) | ALU_Out[0] | ALU_Control[0] (In) |
| 1 | A[1] (Input) | ALU_Out[1] | ALU_Control[1] (In) |
| 2 | A[2] (Input) | ALU_Out[2] | ALU_Control[2] (In) |
| 3 | A[3] (Input) | ALU_Out[3] | Enable_Reg (In) |
| 4 | B[0] (Input) | ALU_Out[4] | Flag_Control[0] (In) |
| 5 | B[1] (Input) | ALU_Out[5] | Flag_Control[1] (In) |
| 6 | B[2] (Input) | ALU_Out[6] | Flag_Control[2] (In) |
| 7 | B[3] (Input) | ALU_Out[7] | Status_Flag (Out) |