This repository contains a 64-bit ARM-style CPU implemented in SystemVerilog, including both a single-cycle and a 5-stage pipelined design.
The project focuses on a clean datapath implementation, explicit hazard handling, and modular hardware design.
- Implemented in
singlecpu.sv - Executes one instruction per clock cycle
- Serves as a functional reference for the pipelined CPU
- Implemented in
pipecpu.sv - Uses a classic pipeline structure:
- Instruction Fetch (IF)
- Instruction Decode / Register Fetch (ID)
- Execute (EX)
- Memory Access (MEM)
- Write Back (WB)
- Pipeline registers separate each stage to enable instruction overlap
The CPU supports the following instruction subset:
ADDIADDSSUBSANDEORLSRLDURSTURCBZBB.LT
- Load-use hazards are detected and handled with a single-cycle stall
- Data hazards are resolved using forwarding logic
- Forwarding paths exist from EX/MEM and MEM/WB pipeline stages
singlecpu.sv– Single-cycle CPUpipecpu.sv– 5-stage pipelined CPUcontroller.sv– Instruction decode and control logic
alu.sv– Arithmetic Logic Unitadder1bit.sv– 1-bit adder used in arithmetic constructionmath.sv– Supporting arithmetic logicregfile.sv– 32×64 register filereg_en.sv– Register modules with enabledecoder.sv– Instruction decoding logicforwarding_unit.sv– Data forwarding logicor_reduce64.sv– Reduction logicmux2.sv– 2:1 multiplexermux32.sv– 32:1 multiplexergate_lib.sv– Basic gate-level primitives
instructmem.sv– Instruction memorydatamem.sv– Data memorycpustim.sv– CPU testbenchrunlab.do– ModelSim run script
The design is verified using waveform-based simulation.
Verification includes:
- Correct instruction execution
- Proper pipeline operation
- Correct stall and forwarding behavior
- Correct register and memory updates
- Datapath logic is primarily structural
- Control logic uses RTL where appropriate
The CPU successfully executes the supported instruction set in both single-cycle and pipelined configurations with correct hazard handling.