
Verilator divides its code into two categories. That which is
executed every cycle ("fast" code) and that which is executed less
frequently ("slow" code). The OPT_FAST macro of
the Verilator generated Makefile specifies
optimizations to be applied to the "fast" code. Conversely the
OPT_SLOW macro specifies optimizations to be
applied to the "slow" code. For convenience the macro
OPT can be used to specify optimizations that
will be applied to both categories of code.
The separation allows focusing of optimization effort for large
designs, where compile times are significant. Just specifying
OPT_FAST gains most of the model performance
benefit, without the overhead of optimizing the "slow" code.
Table 7.2 shows the effect of using the GNU
C++ compiler's highest level of optimization
(-O3) with OPT_FAST,
OPT_SLOW and OPT. These can be
passed as macros to the Makefile in the example
for this application note:
make verilate COMMAND_FILE=cf-optimized-8.scr NUM_RUNS=1000 OPT_FAST="-O3"
|
Run Description |
Build Time |
Run Time |
Performance |
|---|---|---|---|
|
No optimization |
13.91 s |
24.85 s |
47.49 kHz |
|
|
33.78 s |
12.35 s |
95.51 kHz |
|
|
14.20 s |
25.35 s |
46.58 kHz |
|
|
35.35 s |
12.39 s |
95.25 kHz |
Table 7.2.
Comparison of model performance with different
Verilator OPT flag settings.
In the example used in this application note (which is not huge),
none of the model build times are unreasonable. As can be seen
OPT_SLOW profiling has no significant effect in
this example.
