How cambridgehackers/open-src-cvc works
Project type and purpose
• OSS-CVC is an open-source Verilog simulator (compiler + runtime engine) written in C, conforming to IEEE P1364. Its purpose is to parse Verilog source, build an internal representation, and execute simulation while exposing PLI/VPI/DPI plugin hooks and coverage support.
File structure
• Top-level directories:
• bin – prebuilt CLI executables (checkcvc, checkcvc32, etc.)
• src – core C source: front-end (parser/elaborator), simulation kernel, IR generators, optimization passes, plugin interface implementations, compression libs (fastlz, lz4, zlib)
• pli_incs – public header files for PLI (cv_acc_user.h, vpi_user.h), DPI (svdpi.h)
• doc – user/developer documentation, quick-starts, API guides
• tests_and_examples – categorized Verilog/PLI/DPI examples and open-core demos
• toggle_coverage – standalone helper tools for post-processing coverage toggle data
• Config/build scripts: multiple makefiles (makefile.cvc[64], makefile.lnx, makefile.lnx64), INSTALL, .gitignore.
README for additional insights
• Confirms licensing, installation steps, and that CVC is delivered as source + optional binaries.
How to represent this
a. Main components:
1. Command-Line Interface Layer
– bin/checkcvc executables
– Command-line parser & driver
2. Compiler Front-End
– Verilog parser (cvc.c, v_src.c series)
– Syntax tree/AST builder
– Elaborator/dig_main.c
3. Intermediate Representation & Optimization
– IR generators (v_bbgen.c, v_prp.c, v_xprop.c)
– Optimization passes (constant folding, coverage instrumentation)
4. Simulation Kernel
– Event queue, time management (v_sim.c, v_ex*.c)
– Gate-level and behavioral model evaluators (v_fx*.c, v_tf.c)
5. Plugin Interface Layer
– PLI/VPI modules (v_vpi*.c, v_dpi.c)
– pli_incs headers for user plugins
6. Compression & Utility Libraries
– fastlz.c/.h, lz4.c/.h, libz.a – for waveform dumps or coverage data
7. Coverage & Toggle-Coverage Tools
– Built-in coverage instrumentation in the simulator
– External toggle_coverage helpers (chk_tgldat, tvcd_to_tgldat)
8. File I/O & Persistence
– Waveform dump writer, coverage data writer
– Log files, .flist input readers
9. Tests & Example Suites
– Structured directories for PLI, DPI, TF, xprop examples
– Open-core RTL simulation examples under tests_and_examples/open_cores
b. Relationships & interactions
• CLI → invokes Front-End → produces IR → handed to Simulation Kernel
• Simulation Kernel ↔ Plugin Interfaces for external callbacks
• Simulation Kernel ↔ Compression Library when writing VCD/TVCD
• Post-run: Coverage data files consumed by toggle_coverage tools
• Tests/examples feed into CLI as input scripts and Verilog files
c. Architectural patterns & design principles
• Modular C components grouped by functionality (lexer/parser, IR, engine, plugin interfaces)
• Plugin pattern for PLI/VPI/DPI integration
• Static linking of utility libraries for portability
• Separation of concerns: parsing vs. simulation vs. post-processing
d. Key technologies
• Core: ISO C, Makefiles
• Plugin APIs: IEEE P1364 PLI, IEEE 1800 DPI, VPI
• Compression: fastlz, lz4, zlib
• Documentation: PDF/README guides
Detail without overcomplicating
• Break “src” into its logical submodules rather than listing files
• Essential flows: parsing → elaboration → simulation → plugin callbacks → output