ucb-bar / ucb-bar/chipyard

Verilator simulations can be made an order of magnitude faster

Open
#2,000 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Scala
Stars
2.4k
Forks
920
Avg merge
3d 1h
Merged PRs (30d)
5

Description

Background Work
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:

  1. Remove TL monitors (WithoutTLMonitors as stated in the documentation.
  2. Directly load the program as a hex file into the simulated RAM ($readmemhex), see here.
  3. Exclusively handle +verbose in 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.