|
| 1 | +# CVA6 cycle-accurate performance model |
| 2 | + |
| 3 | +This repository contains a cycle-accurate performance model of CVA6 control-path. |
| 4 | + |
| 5 | +It was developed to explore microarchitecture changes in CVA6 before implementing them. |
| 6 | + |
| 7 | +To cite this model, please head to the end of this document. |
| 8 | + |
| 9 | + |
| 10 | +## Getting started |
| 11 | + |
| 12 | +### Adapt RVFI trace generation |
| 13 | + |
| 14 | +The regular expression expects the cycle number to be in the RVFI trace. |
| 15 | +The value is not used by the model but it is used to compare the model and CVA6. |
| 16 | + |
| 17 | +To emit cycle number in RVFI trace, modify `corev_apu/tb/rvfi_tracer.sv` in CVA6 repository as below. |
| 18 | + |
| 19 | +```diff |
| 20 | +- $fwrite(f, "core 0: 0x%h (0x%h) DASM(%h)\n", |
| 21 | +- pc64, rvfi_i[i].insn, rvfi_i[i].insn); |
| 22 | ++ $fwrite(f, "core 0: 0x%h (0x%h) @%d DASM(%h)\n", |
| 23 | ++ pc64, rvfi_i[i].insn, cycles, rvfi_i[i].insn); |
| 24 | +``` |
| 25 | + |
| 26 | + |
| 27 | +### Generate an RVFI trace |
| 28 | + |
| 29 | +To generate an RVFI trace, follow the instructions in the CVA6 repository to run a simulation. |
| 30 | +The RVFI trace will be in `verif/sim/out_<date>/<simulator>/<test-name>.log`. |
| 31 | + |
| 32 | + |
| 33 | +### Running the model |
| 34 | + |
| 35 | +```bash |
| 36 | +python3 model.py verif/sim/out_<date>/<simulator>/<test-name>.log |
| 37 | +``` |
| 38 | + |
| 39 | + |
| 40 | +### Exploring design space |
| 41 | + |
| 42 | +In `model.py`, the `main` function runs the model with arguments which override default values. |
| 43 | +Generic parameters are available in `Model.__init__`. |
| 44 | +You can add new parameters to explore here. |
| 45 | + |
| 46 | +To perform exploration, run the model in a loop, like `issue_commit_graph` does. |
| 47 | +The `display_scores` function is meant to print a 3D plot if you have `matplotlib`. |
| 48 | +`issue_commit_graph` prints the scores so that you can store it and display the figure without re-running the model. |
| 49 | + |
| 50 | + |
| 51 | +## Files |
| 52 | + |
| 53 | +| Name | Description | |
| 54 | +| :--- | :--- | |
| 55 | +| `cycle_diff.py` | Calculates duration of each instruction in an RVFI trace | |
| 56 | +| `isa.py` | Module to create Python objects from RISC-V instructions | |
| 57 | +| `model.py` | The CVA6 performance model | |
| 58 | + |
| 59 | + |
| 60 | +## Citing |
| 61 | + |
| 62 | +```bibtex |
| 63 | +@inproceedings{cf24, |
| 64 | + author = {Allart, C\^{o}me and Coulon, Jean-Roch and Sintzoff, Andr\'{e} and Potin, Olivier and Rigaud, Jean-Baptiste}, |
| 65 | + title = {Using a Performance Model to Implement a Superscalar CVA6}, |
| 66 | + year = {2024}, |
| 67 | + isbn = {9798400704925}, |
| 68 | + publisher = {Association for Computing Machinery}, |
| 69 | + url = {https://doi.org/10.1145/3637543.3652871}, |
| 70 | + doi = {10.1145/3637543.3652871}, |
| 71 | + abstract = {A performance model of CVA6 RISC-V processor is built to evaluate performance-related modifications before implementing them in RTL. Its accuracy is 99.2\% on CoreMark. This model is used to evaluate a superscalar feature for CVA6. During design phase, the model helped detecting and fixing performance bugs. The superscalar feature resulted in a CVA6 performance improvement of 40\% on CoreMark.}, |
| 72 | + booktitle = {Proceedings of the 21st ACM International Conference on Computing Frontiers: Workshops and Special Sessions}, |
| 73 | + pages = {43–46}, |
| 74 | + numpages = {4}, |
| 75 | + keywords = {CVA6, Cycle-Based Model, Multi-Issue, Performance, RISC-V, Superscalar}, |
| 76 | + location = {Ischia, Italy}, |
| 77 | + series = {CF '24 Companion} |
| 78 | +} |
| 79 | +``` |
0 commit comments