This document provides an overview of the VHDLTest tool architecture, design decisions, and key components.
VHDLTest is a command-line tool written in C# that executes VHDL test benches using various HDL simulators and generates standardized test reports. The tool follows a modular architecture with clear separation of concerns.
- Simulator Independence: Support multiple VHDL simulators through a common interface
- Standards Compliance: Generate standard test result formats (TRX)
- Cross-Platform: Run on Windows and Linux
- Tool Validation: Support self-validation for regulated industries
- Minimal Dependencies: Keep external dependencies to a minimum
The main entry point handles:
- Command-line argument parsing
- Exception handling and error reporting
- Version information display
- Delegating to the appropriate execution path
The Context class manages:
- Parsed command-line arguments
- Output configuration (silent, verbose, logging)
- Exit code management
- Console output formatting
Configuration management includes:
- YAML configuration file parsing using YamlDotNet
- Working directory resolution
- File and test bench enumeration
Configuration file format:
files:
- source1.vhd
- source2.vhd
tests:
- testbench1
- testbench2The simulator layer provides a common interface for HDL simulators:
Simulator: Abstract base class defining the compile/test interfaceSimulatorFactory: Factory for creating simulator instances
GhdlSimulator: GHDL (open-source VHDL simulator)ModelSimSimulator: ModelSim (Mentor Graphics)QuestaSimSimulator: QuestaSim (Siemens)VivadoSimulator: Vivado Simulator (Xilinx)ActiveHdlSimulator: Active-HDL (Aldec)NvcSimulator: NVC (open-source VHDL simulator)MockSimulator: Mock for testing purposes
Each simulator implementation:
- Generates appropriate compilation scripts
- Executes the simulator
- Parses simulator output
- Reports success/failure
The test execution layer processes simulator output:
RunProgram: Executes external processes (simulators)RunProcessor: Parses simulator output using configurable rulesRunLineRule: Defines patterns for parsing output linesRunLine: Represents a classified output lineRunResults: Aggregates execution results
Lines are classified as:
- Info: General information
- Report: Test status messages
- Warning: Non-fatal issues
- Error: Errors and failures
- Fatal: Fatal errors
Test results are managed and reported through:
TestResult: Individual test result with status, duration, and messagesTestResults: Collection of test results with:- Summary statistics (passed, failed, skipped)
- TRX file generation for CI/CD integration
- Console output formatting
Self-validation capabilities for regulated industries:
- Embedded test resources
- Version information reporting
- Environment information capture
- Validation report generation
SimulatorFactory creates simulator instances based on name or environment detection.
Each simulator implementation provides a different strategy for compilation and testing.
Simulator base class defines the overall workflow while concrete implementations provide specific steps.
Simulators build command scripts dynamically based on configuration.
-
Initialization
- Parse command-line arguments →
Context - Load configuration file →
ConfigDocument - Create simulator instance →
SimulatorFactory
- Parse command-line arguments →
-
Compilation
- Generate compilation script → Simulator
- Execute compilation →
RunProgram - Parse output →
RunProcessor - Check for errors →
RunResults
-
Testing
- For each test bench:
- Generate test script → Simulator
- Execute test →
RunProgram - Parse output →
RunProcessor - Create test result →
TestResult
- For each test bench:
-
Reporting
- Aggregate results →
TestResults - Generate console summary
- Optionally save TRX file
- Return appropriate exit code
- Aggregate results →
Simulators are located using environment variables:
VHDLTEST_GHDL_PATH: Path to GHDL installationVHDLTEST_MODELSIM_PATH: Path to ModelSim installationVHDLTEST_QUESTASIM_PATH: Path to QuestaSim installationVHDLTEST_VIVADO_PATH: Path to Vivado installationVHDLTEST_ACTIVEHDL_PATH: Path to Active-HDL installationVHDLTEST_NVC_PATH: Path to NVC installation
- Create a new class inheriting from
Simulator - Implement
Compile(Context, Options)method - Implement
Test(Context, Options, string)method - Add detection logic to
SimulatorFactory - Add corresponding environment variable support
Extend RunLineRule with new patterns for simulator-specific output formats.
- Unit Tests: Test individual components in isolation
- Integration Tests: Test simulator interfaces with mock implementations
- Validation Tests: Embedded validation test benches
- .NET 8/9/10: Target frameworks
- YamlDotNet: YAML parsing
- MSTest: Testing framework
- Coverlet: Code coverage
The tool is distributed as a .NET tool package:
- NuGet package:
DemaConsulting.VHDLTest - Command name:
vhdltest - Cross-platform support via .NET runtime
- JSON configuration format support
- Parallel test execution
- Test result caching
- Enhanced error diagnostics
- Plugin architecture for custom simulators