GHDL and NVC on a RISC-V Core: a VHDL Simulator Benchmark

#VHDL#simulation#GHDL#NVC#bazel#RISC-V#auto

Which open-source VHDL simulator runs a RISC-V core faster, GHDL or NVC? On this benchmark, NVC finishes CoreMark in 60.03 seconds and GHDL in 268.95. Both compile the design in under a second, so the simulation speed decides.

This is the second article on hdl-simbench. The first one compared three SystemVerilog simulators. This one uses the same machine and the same rules, on a VHDL design. The two sets of numbers are not comparable with each other, because the designs differ.

What was compared

  • GHDL 6.0.0, built from source by its Bazel Central Registry module (6.0.0.bcr.5). This build uses GHDL’s mcode back end.
  • NVC, built from its commit 324ed157 with LLVM 18.1.8. nvc --version reports it as 1.22-devel. The bench takes the binary from release 1.22.0-324ed157-r2 of bazel_toolchains_nvc, pinned by its SHA-256.

The design is NEORV32, a RISC-V processor written in VHDL. It runs CoreMark for 1,252,946 clock cycles.

How it was measured

The rules are those of the first article, written in the repository’s README:

  • One machine. All runs were on one Intel Core i7-7700, pinned to one core, with the machine’s CI runners paused. A run was dropped if that core’s hyperthread sibling was more than 25% busy, or if CPU steal was over 1%. None of these runs was dropped: 5 of 5 were kept for each simulator.
  • Medians. Each number is the median of the 5 runs. The minimum and maximum follow in brackets.
  • The flags. Each run records its exact command lines. Both simulators use VHDL-2008. NVC elaborates at -O2, its default, written out. GHDL runs with the options that NEORV32’s own simulation script uses.
  • The check. The testbench prints the number of cycles it simulated. A run without that line fails.

The two steps differ

“Compile” and “run” split the work differently for the two simulators.

  • GHDL’s compile is only the analysis of the source files. Its mcode back end generates the design’s machine code when the run starts, so that work is timed in “run”.
  • NVC’s compile includes analysis and elaboration.

So the total, compile plus run, is the number to compare. Cycles per second are counted over the run alone. GHDL’s run time includes generating machine code, which mcode does when the run starts. For NVC, the bench did not separate whether code is generated at elaboration, counted under compile (0.57 s), or during the run.

The results

NEORV32 running CoreMark, 1,252,946 cycles. Times in seconds (lower is better); simulation speed in cycles per second (higher is better).

GHDL NVC
compile 0.07 s [0.07 to 0.10] 0.57 s [0.55 to 0.59]
run 268.88 s [252.61 to 281.81] 59.46 s [59.15 to 60.14]
total 268.95 s [252.68 to 281.89] 60.03 s [59.73 to 60.69]
cycles per second 4,660 [4,446 to 4,960] 2.107e+04 [2.083e+04 to 2.118e+04]

Peak memory while simulating, in KiB (lower is better).

GHDL NVC
run 212,032 [211,908 to 212,096] 101,628 [101,192 to 101,784]

NVC’s runs are also steadier. Its 5 run times span 59.15 to 60.14 seconds. GHDL’s span 252.61 to 281.81 seconds.

What these numbers do not show

  • One GHDL back end. GHDL also has LLVM and GCC back ends, which generate code ahead of time. The BCR module builds only mcode, so the other two were not measured.
  • One machine, one design. All the numbers come from one Intel Core i7-7700 and one program on one processor.
  • A development NVC. Commit 324ed157 is a development version of NVC, between releases.
  • CoreMark’s own verdict. CoreMark prints “Errors detected” at the end of each run. That is its rule that a valid score needs at least 10 seconds of execution, and one simulated iteration is far shorter. Its checksums match. This bench times the simulators, not CoreMark’s score.

Feedback and technical corrections are welcome.