A comprehensive RISC-V processor implementation in Verilog featuring multiple processor variants, a 5-stage pipeline, and extensive testing framework.
- 5-Stage Pipelined RISC-V Core with full forwarding logic
- Multiple Processor Variants: stalling, bypass, and long pipeline implementations
- Integer Multiply/Divide Unit with iterative algorithms
- Comprehensive Test Suite including assembly tests and benchmarks
- VCD Waveform Generation for debugging and analysis
- Icarus Verilog (
iverilog) compiler - Make build system
- Perl (for test result parsing)
cd build
make # Build all executables
make check # Run all unit tests# Run assembly tests on the long pipeline variant
make check-asm-riscvlong
# Run benchmarks
make run-bmark-riscvlong
# Run individual test with VCD output
./riscvlong-sim +stats=1 +vcd=1 +exe=riscv-add.vmh- riscvlong: 5-stage pipelined processor with full forwarding (recommended)
- riscvstall: Processor that stalls on hazards
- riscvbyp: Processor with basic bypass logic
- Control Unit: Instruction decode and pipeline control
- Datapath: 5-stage pipeline with ALU, register file, and forwarding
- Multiply/Divide Unit: Pipelined integer arithmetic operations
- Memory Interface: Instruction and data memory ports
The project includes extensive testing:
- 87 Assembly Tests: Individual RISC-V instruction verification
- 4 Benchmarks: Performance evaluation programs
- Unit Tests: Module-level verification
- Random Delay Testing: Memory timing variation testing
├── build/ # Build system and executables
├── imuldiv/ # Multiply/divide unit implementation
├── riscvlong/ # 5-stage pipelined processor
├── tests/ # Assembly test sources
└── ubmark/ # Benchmark sources
- Arithmetic: ADD, SUB, MUL, DIV, REM (signed/unsigned)
- Logical: AND, OR, XOR, shifts (SLL, SRL, SRA)
- Immediate: ADDI, ANDI, ORI, XORI, SLLI, SRLI, SRAI
- Memory: LW, LH, LB, SW, SH, SB (with signed/unsigned variants)
- Branches: BEQ, BNE, BLT, BGE, BLTU, BGEU
- Jumps: JAL, JALR
- Compare: SLT, SLTU, SLTI, SLTIU
- Upper Immediate: LUI
The riscvlong processor implements a classic 5-stage RISC pipeline:
- Fetch (F): Instruction fetch from memory
- Decode (D): Instruction decode and register file read
- Execute (X): ALU operations and address calculation
- Memory (M): Data memory access
- Writeback (W): Register file write
- Data Forwarding: Full forwarding network to eliminate data hazards
- Control Hazards: Branch prediction and pipeline flushing
- Memory Hazards: Pipeline stalling for memory dependencies
- riscvlong-Core.v: Top-level integration of control and datapath
- riscvlong-CoreCtrl.v: Pipeline control, instruction decode, and hazard detection
- riscvlong-CoreDpath.v: Complete datapath with forwarding logic
- riscvlong-CoreDpathAlu.v: 32-bit ALU supporting all RISC-V operations
- riscvlong-CoreDpathRegfile.v: 32-register file with dual read ports
- riscvlong-CoreDpathPipeMulDiv.v: Pipelined multiply/divide unit
- Instruction Memory: 32-bit address, 32-bit data interface
- Data Memory: 32-bit address, 32-bit data with byte/halfword/word access
- Memory Request/Response: Standardized message format with ready/valid handshaking
Each module includes comprehensive unit tests (.t.v files):
- Module-level verification with directed test vectors
- Self-checking testbenches with pass/fail reporting
- Coverage of corner cases and error conditions
Individual instruction verification:
- 87 assembly tests covering all supported RISC-V instructions
- Tests run on all processor variants for comparison
- Both normal and random-delay execution modes
- Automatic pass/fail detection and reporting
Performance evaluation with realistic programs:
- Vector-vector add (ubmark-vvadd.vmh)
- Complex multiplication (ubmark-cmplx-mult.vmh)
- Masked filter (ubmark-masked-filter.vmh)
- Binary search (ubmark-bin-search.vmh)
- VCD Generation: Waveform output for signal analysis
- Statistics Mode: Cycle counts and performance metrics
- Verbose Output: Detailed execution tracing
- Random Delays: Memory timing variation testing