This directory contains comprehensive test suites for the Vigna RISC-V processor core.
Basic testbench that exercises various instruction types and monitors execution.
Enhanced testbench with result verification through memory stores. Tests:
- Arithmetic operations (ADD, SUB, AND, OR, XOR)
- Immediate operations (ADDI, ANDI, ORI, XORI)
- Load/Store operations (LW, SW)
- Comparison operations (SLT, SLTI)
Comprehensive testbench that adds:
- Shift operations (SLLI, SRLI, SRAI)
- Upper immediate operations (LUI, AUIPC)
- Branch operations (BEQ, BNE, etc.)
Memory simulator module that provides instruction and data memory interfaces.
The included Makefile provides several targets:
make syntax # Check basic testbench
make enhanced_syntax # Check enhanced testbench
make comprehensive_syntax # Check comprehensive testbenchmake test # Run basic testbench
make enhanced_test # Run enhanced testbench
make comprehensive_test # Run comprehensive testbench
# Quick tests (no waveform generation)
make quick_test
make enhanced_quick_test
make comprehensive_quick_testmake wave # View basic test waveforms
make enhanced_wave # View enhanced test waveforms
make comprehensive_wave # View comprehensive test waveformsWhen run successfully, all tests should PASS. Example output:
Starting Enhanced Vigna Processor Tests
======================================
Setting up arithmetic test...
Running test: Arithmetic Operations
PASS: ADD result = 15 (expected 15)
PASS: SUB result = 5 (expected 5)
PASS: AND result = 0 (expected 0)
PASS: OR result = 15 (expected 15)
PASS: XOR result = 15 (expected 15)
Test Summary:
=============
Tests Passed: 13
Tests Failed: 0
Total Tests: 13
All tests PASSED!
Since we cannot directly access processor registers in the testbench, we use a store-and-verify approach:
- Load test instructions into instruction memory
- Execute instructions on the processor
- Use SW (Store Word) instructions to write register values to data memory
- Read data memory in testbench to verify expected results
Each test follows this pattern:
- Initialize registers with known values using ADDI
- Perform operations to test
- Store results to memory using SW
- Verify memory contents match expected values
The testbench includes helper functions to generate properly encoded RISC-V instructions:
make_r_type()- R-type instructions (register-register)make_i_type()- I-type instructions (immediate)make_s_type()- S-type instructions (store)make_b_type()- B-type instructions (branch)make_u_type()- U-type instructions (upper immediate)
- Icarus Verilog (iverilog) for simulation
- GTKWave for waveform viewing (optional)
- Make for build automation
On Ubuntu/Debian:
sudo apt update
sudo apt install iverilog gtkwave make- Navigate to the project root directory
- Run the desired test:
make comprehensive_quick_test
- Check the output for PASS/FAIL results
To add new test cases:
- Create test instructions using the helper functions
- Store instruction sequence in instruction_memory array
- Add result verification by storing to data_memory and checking values
- Follow the existing pattern of setup -> run -> verify
Example:
// Test new instruction
instruction_memory[0] = make_i_type(12'd42, 5'd0, 3'b000, 5'd1, 7'b0010011); // ADDI x1, x0, 42
instruction_memory[1] = make_s_type(12'd0, 5'd1, 5'd0, 3'b010, 7'b0100011); // SW x1, 0(x0)
instruction_memory[2] = make_i_type(-12'd4, 5'd0, 3'b000, 5'd0, 7'b1100111); // Halt
// Verify result
if (data_memory[0] == 32'd42) begin
$display(" PASS: New test = %d (expected 42)", data_memory[0]);
test_pass_count = test_pass_count + 1;
endThis test infrastructure provides comprehensive verification of the Vigna processor's instruction execution capabilities.