Project 01

Tri-HDL 5-Stage Pipelined RISC-V CPU

Designed and implemented a 5-stage pipelined RISC-V processor in VHDL, Verilog, and SystemVerilog. The project includes pipeline control, hazard detection, data forwarding, stalls, and control-hazard handling, with extensive simulation-based verification.

VHDL Verilog SystemVerilog RISC-V Vivado Artix-7 RTL Design Testbenches Verification

Five-Stage Processor Architecture

The processor follows a five-stage pipelined architecture consisting of Instruction Fetch, Instruction Decode, Execute, Memory, and Writeback.

Pipeline registers separate each stage, allowing multiple instructions to progress through the processor simultaneously. Additional control logic manages data dependencies and changes in program flow.

IF Instruction Fetch
ID Instruction Decode
EX Execute
MEM Memory
WB Writeback

One Architecture, Three HDLs

I implemented the processor architecture using VHDL, Verilog, and SystemVerilog. Implementing the same architecture across three hardware description languages gave me experience expressing equivalent digital behavior using different RTL syntax and design constructs.

The implementations were simulated to examine pipeline behavior and verify that instructions progressed through the processor as expected.

Comparison of pipelined CPU simulations implemented in Verilog, VHDL, and SystemVerilog
Tri-HDL Simulation Comparison Simulation results from the Verilog, VHDL, and SystemVerilog implementations were compared while examining equivalent processor behavior. Click image to view full size.

Hazard Detection, Forwarding, and Stalls

Pipelining introduces dependencies when an instruction requires a value that has not yet completed its normal path through the processor.

I implemented hazard-management logic to identify these dependencies. Forwarding allows values from later pipeline stages to be supplied to dependent instructions when possible, while stall logic handles situations that cannot be resolved immediately through forwarding.

Modular Testing Before Integration

Before integrating the complete processor, I independently verified individual modules and pipeline-control logic using simulation and testbenches.

This modular approach helped isolate incorrect behavior before the components were combined into the complete CPU.

My verification approach progressed from manually defined test cases to targeted scenarios designed to trigger specific processor conditions. I later used randomized testing to exercise the design across much larger numbers of input combinations automatically.

Hazard Detection Unit Verification

The hazard detection unit was tested across different register dependencies and memory conditions. The testbench compared actual control outputs against expected results, allowing forwarding and stall decisions to be checked automatically.

Hazard detection verification waveform showing register dependencies, forwarding controls, stalls, and actual versus expected results
Hazard Detection Verification Selected waveform showing multiple dependency conditions and the resulting forwarding and stall control decisions. Actual outputs are shown alongside expected outputs. Click image to view full size.

Forwarding Disabled vs. Enabled

I tested dependent instruction sequences with forwarding disabled and enabled to observe how operand dependencies affected execution.

Comparing the simulations helped verify that the forwarding paths supplied required values from later pipeline stages when appropriate.

Pipelined CPU simulation with forwarding disabled
Forwarding Disabled Simulation of a dependent instruction sequence without the forwarding paths enabled. Click image to view full size.
Pipelined CPU simulation with forwarding enabled
Forwarding Enabled Simulation showing the dependent instruction sequence with forwarding enabled. Click image to view full size.

Branch and Jump Pipeline Flushing

Branch and jump instructions required the processor to handle instructions that had already entered the pipeline before the new program counter became effective.

I used waveform analysis to trace these instructions through the pipeline and verify that instructions from the incorrect execution path were invalidated before they could continue through later stages.

Annotated waveform demonstrating branch and jump pipeline flushing
Branch and Jump Verification Annotated simulation used to trace control-flow behavior and examine instruction invalidation across the pipeline. Click image to view full size.

Developing the Design and Verification Process

Waveform Debugging

At the beginning of the project, I understood the conceptual pipeline timing but did not yet know how that behavior would appear in an RTL simulation waveform. Through repeated simulation and debugging, I learned how to trace instructions and control signals across pipeline stages and relate waveform timing back to the processor architecture.

Modular Verification

Writing testbenches for individual modules before integration taught me how modular testing can isolate problems earlier and make system-level debugging more manageable.

Targeted Testing

I learned how to construct instruction sequences and input conditions specifically designed to trigger the behavior I wanted to verify, including different pipeline hazards.

Randomized Testing

I progressed beyond manually writing every test case by developing randomized testing approaches that allowed modules to be exercised across large numbers of test conditions automatically.

RTL Optimization

As the project developed, I learned to recognize repetitive RTL structures and improve the design by making portions of the implementation more modular and reusable.

Engineering Feedback

Feedback from engineering professionals I connected with during my learning journey exposed me to alternative RTL approaches. I evaluated that guidance while improving and debugging my own implementation.

Additional Simulation Evidence

This portfolio highlights selected simulation results rather than every test performed during development. Additional module-level and integrated CPU verification images are available in the project repository.

View Verification Results on GitHub →