Verilator simulations can be made an order of magnitude faster
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 2.4k
- Forks
- 920
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 5
Description
Background Work
- Yes, I searched the mailing list
- Yes, I searched the documentation
Feature Description
For simple tests where we only need to run an assembly program, we can make the Verilator simulations more than order of magnitude faster, by removing some functionality from the test harness.
Motivating Example
On a an AMD EPYC 9554 3.75 GHz processors, single-thread Verilator simulation of a single-core RocketChip runs at about 10 kHz, but by stripping down the harness, we could make it run at 270~kHz (single-thread on EPYC), i.e., 27x faster.
Here is how I achieved a 27x speedup:
- Remove TL monitors (
WithoutTLMonitorsas stated in the documentation. - Directly load the program as a hex file into the simulated RAM (
$readmemhex), see here. - Exclusively handle
+verbosein Verilog using a simplified all-Verilog harness
The last step has the most significant effect. It seems that Verilator really struggles with how verbose printing is handled through $c(...) PLI calls. Even when simulation is non-verbose there is a huge performance impact.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Verilator simulation harness and the referenced generators/chipyard/src/main/scala/example/simulation/HarnessExtMem.scala location. Read the Software-RTL-Simulation documentation, then compare the linked SimpleTestDriver.v approach with the existing harness. Done means supporting the simplified assembly-test path while preserving the requested simulation behavior and demonstrating the reported speedup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- performance, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100