Part 7 · Advanced & Integration · Intermediate
Plusargs, Files & Runtime Configuration
Hub — plusarg parsing, file I/O, configuration architecture, memory preload/dump, and wave-dump runtime control.
Overview
A compiled simulation image is expensive to build and cheap to run. Runtime configuration is what lets one image serve a thousand tests: plusargs select the test and tune its knobs, files feed stimulus and memory images in and carry logs and dumps out, and wave-dump controls decide what gets recorded. Teams that configure at run time iterate in seconds; teams that recompile for every knob change iterate in hours.
This topic covers the whole runtime boundary: $value$plusargs and $test$plusargs for command-line knobs, $fopen/$readmemh for file traffic, the three-layer configuration architecture that keeps it all sane, and the dump/exit controls that make regressions debuggable.
Sub-topics
$test$plusargs & $value$plusargs — existence vs value parsing, defaults, and the knob registry idiom.
File I/O — $fopen/$fclose, formatted writes, parsing reads, and $readmemh memory preload.
Config Architecture: Files vs Plusargs vs Objects — the three-layer model and precedence design.
Memory Preload & Dump — hierarchical readmem, generated images, end-of-test dump and compare.
Wave Dumping & Runtime Control — dump scope and windows, $finish/$stop/$fatal, verbosity switching.
TOPIC MAP — THE RUNTIME BOUNDARY
build once run many times
────────── ──────────────
compile + elaborate ──► simv ◄── +TESTNAME=smoke +VERBOSITY=HIGH
│ ◄── +PRELOAD=image.hex +DUMP_START=12us
│
┌───────────────┼────────────────┐
│ │ │
▼ ▼ ▼
plusargs file I/O wave control
(lesson 1) (lesson 2) (lesson 5)
│ │
▼ ▼
config object memory preload
architecture & dump compare
(lesson 3) (lesson 4)Key takeaways
One compiled image, many configured runs — plusargs and files are the levers that make regressions fast.
Parse plusargs once into a central config object; never scatter $value$plusargs calls across the testbench.
Files carry data both ways: preload images and stimulus in, logs, memory dumps, and waves out.