GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Amin-Maky/CVA6-Lab: Simulating and extending CVA6: Focused on resolving a computational gap between the Issue and EX stages (Superscalar disabled), while getting hands-on experience with modern RTL/EDA tools.

BranchesTags
Open more actions menu

Latest commit

 

History

28 Commits
28 Commits

Folders and files

NameName
Last commit message
Last commit date
benchmarks
benchmarks
 
 
docs
docs
 
 
fpga
fpga
 
 
rtl
rtl
 
 
scripts
scripts
 
 
sim
sim
 
 
tb
tb
 
 
.gitignore
.gitignore
 
 
Directory.txt
Directory.txt
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
benchmarks_sim_github_dark.png
benchmarks_sim_github_dark.png
 
 
benchmarks_sim_github_light.png
benchmarks_sim_github_light.png
 
 
results_syn_github_dark.png
results_syn_github_dark.png
 
 
results_syn_github_light.png
results_syn_github_light.png
 
 

Repository files navigation

CVA6-Lab: Architectural Analysis, Custom RTL Optimization & Verification Framework

An End-to-End Hardware Exploration, Co-Simulation, and FPGA Synthesis Environment for the OpenHW Group CVA6 RISC-V Processor

RISC-V SystemVerilog Verilator Vivado Bender License

Overview • Repository Layout • Quick Start • Documentation • Results at a Glance


1. Overview

CVA6-lab is an independent, end-to-end educational and developmental framework built around the CVA6 RISC-V CPU. The primary goal of this project was to break away from the "black box" automated scripts provided by the official repository and achieve a deep, hands-on understanding of a production-grade RISC-V core. This repository documents the entire journey: from setting up the complex environment and toolchains, to running custom behavioral simulations from scratch, analyzing the hardware architecture at the signal level, and ultimately modifying the RTL to improve performance.

A significant portion of this project focuses on mastering the hardware design flow. Instead of relying solely on predefined Python wrappers, this project establishes a completely manual, automated-via-Makefile simulation environment using Verilator and Spike (for co-simulation/verification). Furthermore, it comprehensively details the Vivado Synthesis process, exploring how different processor configurations (e.g., 32-bit vs. 64-bit, single-issue vs. dual-issue) impact logic utilization, critical paths, and overall Fmax.

The capstone of this project is the Custom 64-bit Architecture Implementation. By analyzing the pipeline behavior under specific workloads, a structural hazard was identified in the execution stage: multi-cycle operations (like division) were blocking the shared write-back bus, forcing fast, single-cycle ALU instructions to stall. Through targeted RTL modifications—including decoupling ready signals, introducing holding buffers, and implementing back-pressure mechanisms—the write-back contention was resolved. The result is a custom configuration that offers a measurable performance boost (+3.57% in division-heavy benchmarks) with virtually zero hardware overhead compared to the standard single-issue baseline.

CVA6 Architecture and Issue Stage Microarchitecture

Top-level CVA6 pipeline architecture with a detailed view of the Issue Stage (Scoreboard & Operand Read) and its interface with Execution/Commit stages.

Key Highlights of this Repository:

  • Transparent Environment: Detailed guides on setting up the RISC-V toolchain, Bender, Verilator, and Spike from scratch.
  • Custom Simulation Flow: A self-checking C++ testbench using Verilator, bypassing opaque default scripts.
  • In-Depth FPGA Synthesis: Scripts and analysis for synthesizing standard and superscalar configurations in Vivado.
  • Architectural Analysis: Waveform-level tracing of the issue, execution, and commit stages.
  • RTL Modification & Verification: A step-by-step guide on resolving structural hazards, verified by custom benchmarks and fault-injection scenarios.

Cycle-Accurate Waveform Analysis & Debugging Gallery

32-bit Pipeline Tracing
Pipeline Stage Tracing: Tracking instruction flow (A–D) across Issue, Execute, and Commit stages.
Write-back Bottleneck
The Structural Hazard: Baseline 64-bit core stalling fast ALU ops during a long division.
Issue Stage Decoupling
Issue Decoupling & Bug Fix: Resolving pointer lockups to allow continuous instruction dispatch.
Forced Hazard Verification
Custom Holding Buffer in Action: Verifying collision-free write-back under forced hazard scenarios (A–F).

Click on any waveform to view full-resolution signal traces. Detailed cycle-by-cycle explanations are available in Doc 4 and Doc 5.


2. Repository Layout

CVA6-lab/ - Main repository root

benchmarks/ - Software only (formerly firmware)
├── src/                        # Source files 
│   ├── avg.c
│   ├── boot.S
│   ├── bug_32.S
│   ├── bug_64.S
│   ├── complex_32.S
│   ├── complex_64.S
│   ├── complex_avg.c
│   ├── main_.c
│   ├── main-syn.S
│   ├── main_32.S
│   ├── main_64.S
│   └── matmul.c
├── linker/                     # Linker scripts
│   └── link.ld
└── spike-checking/             # Spike simulation logs
docs/ - Documentation files
├── 1-environment-setup.md      # Unified setup: Clone, Bender, GCC, and Spike installation
├── 2-vivado-synthesis.md       # Vivado synthesis flow and resource reports
├── 3-simulation-flow.md        # Official and manual simulation with Verilator (+ Post-Synthesis Simulation)
├── 4-arch-32b-analysis.md      # 32-bit analysis
└── 5-arch-64b-custom.md        # 64-bit dev history, FLU Write-back architecture, and results
fpga/ - FPGA and Synthesis files
├── vivado                      # Vivado Tcl scripts
│   ├── cv32a6_imac_sv32.tcl
│   ├── cv32a6_imac_sv32_syn.tcl
│   ├── cv32a6_imac_sv32_post_syn_sim.tcl
│   ├── cv64a6_imafdc_sv39.tcl
│   ├── cv64a6_imafdc_sv39_syn.tcl
│   └── cv64a6_imafdc_sv39_post_syn_sim.tcl
├── constraints/
│   └── cva6_ooc.xdc
└── build/                      # (gitignored) All Vivado outputs generated here
    ├── vivado_prj_cv32a6/
    └── vivado_prj_cv64a6/
scripts/ - Helper scripts
├── plotting			        # Generating plots
└── f-maker                     # CVA6 File Tree Copier & .f File Updater
sim/ - Simulation execution environment (Workspace)
├── Makefile                    # Makefile for Verilator simulation
└── filelists/                  # Bender output .f files
    ├── cv32a6_imac_sv32_verilator.f
    └── cv64a6_imafdc_sv39_verilator.f
tb/ - All verification sources
├── sv/                         # SystemVerilog testbenches
│   └── cva6_tb.sv
├── cpp/                        # Verilator testbenches
│   ├── tb_cva6_ww.cpp          # With waveform
│   └── tb_cva6_wow.cpp         # Without waveform
└── wrappers/                   # Simulation wrappers
    └── cva6_axi_wrapper.sv
rtl/ & Root Files
├── rtl/                        # Processor RTL only (no testbenches)
├── README.md                   # Main README
├── Makefile                    # Main Makefile
└── .git

3. Quick Start (Makefile)

A single root Makefile drives both flows — simulation (delegated to sim/Makefile) and FPGA/Vivado. Print the full target list, variables, and options any time:

make help

1. Simple Simulation Runs the default RTL simulation: 64-bit, assembly playground with waveform dump (CMD=run).

make sim

Override the defaults with variables — ARCH (default 64) and CMD (default run):

make sim ARCH=32 CMD=run_matmul

Available CMD values:

  • run (assembly playground, waves ON)
  • run_c (C playground, waves ON)
  • run_complex (speed benchmark, no waves)
  • run_bug (bug hunt, waves ON)
  • run_matmul (matrix multiplication program, no waves)
  • run_avg (averaging over an array, no waves)

2. Create Vivado Project Generate the GUI project (files land in fpga/build/):

make cva6-64        # 64-bit: cv64a6_imafdc_sv39
make cva6-32        # 32-bit: cv32a6_imac_sv32

3. Run Synthesis Full logic synthesis in Vivado batch mode (long run):

make synth-64       # or: make synth-32

Long-running. Post-synthesis simulation is also available via make post-syn-sim-64 / make post-syn-sim-32.

4. Clean Repository Remove simulation artifacts, then delete and recreate fpga/build/:

make clean         # sim + fpga
make clean-sim     # simulation artifacts only

Note: synth-* and cva6-* require Vivado on PATH; sim targets require the RISC-V toolchain and Verilator used inside sim/Makefile.


4. Documentation Index

1. Environment Setup
  • View Full Document
  • 1. System Requirements
    • 1.1 Operating System & Filesystem
    • 1.2 Storage & RAM
    • 1.3 Network
  • 2. Repository Setup
    • 2.1 Cloning the Repository
    • 2.2 Initializing Submodules
  • 3. System Dependencies
    • 3.1 APT Packages
    • 3.2 Python Virtual Environment
  • 4. RISC-V GCC Toolchain
    • 4.1 Build Prerequisites
    • 4.2 Setting the $RISCV Environment Variable
    • 4.3 Building the Toolchain
    • 4.4 Resource Estimates
    • 4.5 Common Build Errors & Fixes
    • 4.6 Verifying the Installation
  • 5. Bender (Dependency Manager)
    • 5.1 Installing Bender
    • 5.2 Verifying Bender
  • 6. Simulators (Verilator & Spike)
    • 6.1 Configuring the Environment
    • 6.2 Known Patches Before Build
    • 6.3 Building Verilator & Spike
  • 7. Setup Checklist
    • 7.1 Pre-Flight Checklist
    • 7.2 Error Quick-Reference
    • 7.3 Session Startup
2. Vivado Synthesis
  • View Full Document
  • 1. Project Creation
    • 1.1 Using the Official CVA6 Repository
    • 1.2 Using the Project Makefile Flow
  • 2. Processor Configuration
    • 2.0 Locating and Modifying Configuration Packages
    • 2.1 Datapath Width Parameters (XLEN and VLEN)
    • 2.2 Issue Control, Scoreboard Depth, and Execution Pipeline
    • 2.3 ISA Extension Flags and Functional Unit Instantiation
    • 2.4 Memory Management Unit and TLB Configuration
    • 2.5 Cache Subsystem
  • 3. Version Comparison
    • 3.1 Resource Utilization Comparison
    • 3.2 Timing Analysis & Critical Path Evaluation
  • 4. Summary and Conclusions
3. Simulation Flow
  • View Full Document
  • 1. Post-Synthesis Simulation (Vivado / XSIM)
    • 1.1 AXI Testbench and Firmware Setup
    • 1.2 Elaboration and Simulation in XSIM
    • 1.3 Waveform Inspection
  • 2. Developer Simulation Flow (cva6.py + Verilator + Spike)
    • 2.1 Running the Default Test Suite (smoke test)
    • 2.2 Custom C and Assembly Programs
    • 2.3 Waveform Debugging & Architectural Signal Analysis
    • 2.4 C Code Analysis & HTIF Communication Mechanism
    • 2.5 Conclusion: End-to-End Proof of Functionality
  • 3. Manual Simulation from Scratch (Standalone Verilator)
    • 3.0 Overview & Motivation
    • 3.1 Dependency Generation via Bender
    • 3.2 CVA6 AXI Wrapper (cva6_axi_wrapper.sv)
    • 3.3 Spike as Instruction-Level Reference
    • 3.4 Firmware Suite & Linker Script
    • 3.5 Self-Checking C++ Testbench
    • 3.6 Makefile Automation
  • 4. Processor Performance Comparison
    • 4.1 Executed Benchmarks
    • 4.2 Results
4. 32-bit Architecture Analysis
  • View Full Document
  • 1. The Big Picture: CVA6 Top-Level Structure
  • 2. Inside the Issue Stage: Scoreboard and Operand Read
    • 2.1 Issue Stage Overview
    • 2.2 The Scoreboard: A Ledger for In-Flight Instructions
    • 2.3 Issue Read Operands: The Gatekeeper of Dispatch
    • 2.4 Commit Process
  • 3. Seeing It in the Waveform
    • 3.1 Step 1: Designing the .S Test Program
    • 3.2 Step 2: Following the Waveform
    • 3.3 Step 3: Conclusion
  • 4. Summary: It Can Be Further Developed
5. 64-bit Custom Architecture
  • View Full Document
  • Introduction
    • 1.1 Design Space: New Channel vs. Shared Channel
    • 1.2 Implementation Roadmap
  • 2. Prerequisite Analysis (Phase 0)
    • 2.1 Divider Data Safety (Latching)
    • 2.2 Decoupling the Ready Signals in the Issue Stage
  • 3. Issue Decoupling (Phase 1)
    • 3.1 The Coupling Point
    • 3.2 Implementation
    • 3.3 Result: The Issue Path Is Free
    • 3.4 What Phase 1 Breaks
  • 4. Write-back Collision & the Holding Buffer (Phase 2.1)
    • 4.1 Implementation
    • 4.2 Operation
    • 4.3 Result: Collision Resolved
  • 5. Back-Pressure (Phase 2.2)
    • 5.1 The Hypothetical Failure
    • 5.3 Making It Bullet-Proof Anyway
    • 5.4 Cost
  • 6. Functional Verification via Forced Hazard Scenarios
    • 6.1 Concurrent ALU Operation During an Active Division
    • 6.2 Control-Flow Redirection During an Active Division
    • 6.3 Overlapping Multi-Cycle Instructions
  • 7. Comparison
    • 7.1 Resource Utilization
    • 7.2 Timing Analysis & Critical Path
    • 7.3 Performance & Execution Speed (Benchmarks)
    • 7.4 Conclusion

5. Results at a Glance

Comparison Synthesis Results

Timing Performance (WNS & $F_{max}$):

Configuration (Core) Superscalar WNS (ns) $F_{max}$ (MHz) Logic Levels Routing Share
64-bit (cv64a6_imafdc_sv39) OFF −9.118 52.31 45 72.0 %
64-bit-custom (cv64a6_imafdc_sv39) OFF −9.160 52.19 45 71.097 %
64-bit (cv64a6_imafdc_sv39) ON −9.968 50.08 47 71.8 %

Logic Utilization (LUT/FF):

Configuration (Core) Superscalar LUT FF BRAM DSP IO
64-bit (cv64a6_imafdc_sv39) OFF 54,326 23,728 36 27 0
64-bit-custom (cv64a6_imafdc_sv39) OFF 54,023 23,803 36 27 0
64-bit (cv64a6_imafdc_sv39) ON 63,685 25,108 36 27 0

Discussion: Between the two reference configurations, the custom version sits almost exactly on top of the standard non-superscalar build. On timing, the gap is negligible — 52.19 MHz against 52.31 MHz, and a WNS of −9.160 ns against −9.118 ns — while the superscalar build trails well behind at 50.08 MHz. Area tells the same story: 54,023 LUTs and 23,803 FFs, i.e. a few hundred LUTs below and a few dozen FFs above the Superscalar-OFF baseline, both far short of the 63,685 LUTs and 25,108 FFs the Superscalar-ON build requires. In other words, the change to the write-back path costs essentially nothing in frequency or logic, and the custom core behaves as the OFF configuration with a marginal area/timing trade.

Comparison Synthesis Results Comparison Synthesis Results

Synthesis metrics for the three 64-bit configurations: clock frequency and worst negative slack alongside LUT/FF utilization.

Comparison Benchmarks Simulation

Configuration (Core) Superscalar Random Program (Cycles) Matrix Multiplication (Cycles) Averaging (Cycles)
64-bit (cv64a6_imafdc_sv39) OFF 2,656,954 117,244 11,235,565
64-bit-custom (cv64a6_imafdc_sv39) OFF 2,615,871 117,244 10,834,566
64-bit (cv64a6_imafdc_sv39) ON 2,076,882 112,486 9,875,796

Discussion: The custom build consistently beats the standard Superscalar-OFF core — 2,615,871 vs 2,656,954 Cycles on the random program, and 10,834,566 vs 11,235,565 Cycles on averaging — while remaining clearly behind the Superscalar-ON build (2,076,882 and 9,875,796 Cycles). The matrix-multiplication figure is unchanged at 117,244 Cycles, where the workload is dominated by memory traffic rather than issue width. The custom version therefore lands between the two standard configurations, but much closer to the OFF baseline than to the superscalar performance level.

Comparison Benchmarks Simulation Comparison Benchmarks Simulation

Cycle-count comparison across the three benchmarks for each 64-bit configuration.

Conclusion: The custom configuration retains a footprint and timing profile that is essentially on par with the standard non-superscalar core — a negligible ~0.2–0.5% difference in $F_{max}$, WNS, and FF — while delivering a measurable runtime improvement on ILP-sensitive benchmarks: +1.55% on the random program and +3.57% on the averaging benchmark, with no change on matrix multiplication. This confirms the custom build as a low-cost intermediate tier, gaining real execution-time benefits from the write-back path fix without materially affecting synthesis-side area or timing.


6. References and License

References

  • CVA6 Official Repository & Documentation
  • Bender: Dependency Management Tool for Hardware Projects
  • Xilinx Vivado Design Suite Documentation
  • RISC-V Instruction Set Manual
  • RISC-V GNU Compiler Toolchain
  • Spike RISC-V ISA Simulator
  • Verilator: Open-Source SystemVerilog Simulator
  • Matplotlib: Visualization with Python - Used for generating performance and resource utilization plots.

License

This project is open-source and distributed under the Apache License 2.0. See the LICENSE file for more details.

Note: The base CVA6 core RTL and some associated files remain under their original OpenHW Group licenses (Solderpad Hardware License v2.1 / Apache 2.0). The custom modifications (holding buffer, structural hazard resolution logic) and the evaluation framework (benchmarks, Python plotting scripts, Makefiles) provided in this repository are distributed under the Apache 2.0 license.

About

Simulating and extending CVA6: Focused on resolving a computational gap between the Issue and EX stages (Superscalar disabled), while getting hands-on experience with modern RTL/EDA tools.

Topics

computer-architecturecva6hardware-engineeringmicroarchitecturerisc-vrtl-designsystemverilog

Resources

Readme
Apache-2.0 license
Activity

Stars

4 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.