A Verilog implementation of a 4-bit Arithmetic Logic Unit that performs basic arithmetic and logical operations.
- Sanskaar
- GitHub: CodeFreak2186
https://github.com/CodeFreak2186/4-bit-ALU.git
This 4-bit ALU implements the following operations:
- Addition (4-bit)
- Subtraction (4-bit)
- Logical Operations:
- AND
- OR
- XOR
- NOT
├── alu_gate.json # Digital circuit configuration
├── alu_gate.png # Circuit diagram (PNG format)
├── alu_gate.svg # Circuit diagram (SVG format)
├── alu_gate.v # Top-level ALU gate implementation
├── synth.ys # Synthesis script
├── src/
│ ├── add4.v # 4-bit adder module
│ ├── alu_4bit.v # Main ALU implementation
│ ├── alu_mux.v # Multiplexer for ALU operations
│ ├── flag_unit.v # Flag generation unit
│ ├── logic4.v # Logic operations implementation
│ └── sub4.v # 4-bit subtractor module
└── tb/
└── alu4_tb.v # Testbench for ALU verification
To run and simulate this project, you need:
- Icarus Verilog (iverilog) - for simulation
- GTKWave - for viewing waveforms
- Yosys - for synthesis (optional)
-
Simulation:
# Compile the design and testbench iverilog -o alu_sim tb/alu4_tb.v src/*.v # Run the simulation vvp alu_sim # View waveforms gtkwave alu4_tb.vcd
-
Synthesis (if using Yosys):
# Run synthesis yosys -s synth.ys
The simulation results can be found in alu4_results.txt file.
This project is open source and available under the MIT License.