An intelligent agent that parses functional coverage reports, identifies uncovered bins, generates targeted test suggestions using LLM, prioritizes them, and predicts coverage closure metrics.
- Python 3.9 or higher
- pip package manager
-
Clone the repository
git clone git@github.com:vinayakjaas/Assignment-2-Verification-Coverage-Analyzer-with-LLM-Integration.git cd Assignment-2-Verification-Coverage-Analyzer-with-LLM-IntegrationOr using HTTPS:
git clone https://github.com/vinayakjaas/Assignment-2-Verification-Coverage-Analyzer-with-LLM-Integration.git cd Assignment-2-Verification-Coverage-Analyzer-with-LLM-Integration -
Install dependencies
pip install -r requirements.txt
-
Set up API keys (Optional - for LLM features)
Edit
setup_api_key.shand replacesk-proj-your-key-herewith your actual API key, then:source setup_api_key.shOr manually set environment variables:
export OPENAI_API_KEY="sk-proj-your-key-here" export COVERAGE_LLM_PROVIDER="openai"
Note: The system works without API keys using heuristic fallbacks, but LLM integration provides better suggestions.
-
Install package in editable mode (Optional)
pip install -e .Or use
PYTHONPATH=srcprefix for commands.
- Python 3.9+ - Programming language
- Pydantic 2.7.1 - Data validation and models
- Typer 0.12.3 - CLI framework
- Rich 13.7.1 - Terminal formatting and tables
- OpenAI 1.23.6 - GPT-4o-mini for test suggestions
- Anthropic 0.25.4 - Claude 3.5 Sonnet alternative
- httpx 0.27.0 - HTTP client for API calls
- Streamlit 1.33.0 - Interactive web UI
- python-dotenv 1.0.1 - Environment variable management
- Regex-based parsing - Pattern matching for report extraction
- State machine parser - Line-by-line parsing with context tracking
- Heuristic fallbacks - Local suggestions when LLM unavailable
- Pydantic models - Type-safe data structures
Command:
PYTHONPATH=src python3 -m coverage_analyzer.cli parse examples/sample_report.txtWhat it does:
- Parses coverage report text file
- Extracts design name, overall coverage, covergroups, coverpoints, bins, and cross-coverage
- Outputs structured JSON with all parsed data
Example Output:
{
"design": "dma_controller",
"overall_coverage": 54.84,
"covergroups": [
{
"name": "cg_transfer_size",
"coverage": 75.0,
"coverpoints": [
{
"name": "cp_size",
"bins": [
{
"name": "small",
"range": "[0:255]",
"hits": 1523,
"covered": true
},
{
"name": "max",
"range": "[4096]",
"hits": 0,
"covered": false
}
]
}
]
}
],
"cross_coverage": [...],
"uncovered_bins": [...]
}How it's solved:
- Uses regex patterns to identify key sections (design, coverage percentages, bins)
- Implements state machine to track current covergroup/coverpoint context
- Automatically identifies uncovered bins
- Returns Pydantic models for type safety
Save parsed output:
PYTHONPATH=src python3 -m coverage_analyzer.cli parse examples/sample_report.txt --out parsed_data/sample_parsed.jsonCommand:
PYTHONPATH=src python3 -m coverage_analyzer.cli suggest examples/sample_report.txt --out examples/sample_output.jsonWhat it does:
- Generates natural-language test suggestions for each uncovered bin
- Uses LLM (OpenAI/Anthropic) for intelligent suggestions
- Falls back to heuristic-based suggestions if no API key
Example Output:
Suggestions
βββββββββββββββββββββββββ³βββββββββββ³βββββββββββββ³ββββββββ³βββββββββββββββββββββββ
β Target β Priority β Difficulty β Score β Suggestion β
β‘βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ©
β cross_size_burst.medi β medium β easy β 0.80 β Set burst type to β
β um, fixed β β β β MEDIUM, FIXED mode β
β β β β β (register offset β
β β β β β 0x04, value 0x3)... β
βββββββββββββββββββββββββΌβββββββββββΌβββββββββββββΌββββββββΌβββββββββββββββββββββββ€
β cross_size_burst.larg β medium β easy β 0.80 β Set burst type to β
β e, incr β β β β LARGE, INCR mode... β
βββββββββββββββββββββββββ΄βββββββββββ΄βββββββββββββ΄ββββββββ΄βββββββββββββββββββββββ
The JSON output file contains detailed suggestions with test outlines:
{
"suggestions": [
{
"target_bin": "cross_size_burst.medium, fixed",
"priority": "medium",
"difficulty": "easy",
"priority_score": 0.8,
"suggestion": "Set burst type to MEDIUM, FIXED mode...",
"test_outline": [
"1. Configure DMA channel 0...",
"2. Set source address...",
"3. Set transfer length...",
"4. Verify address sequence..."
],
"reasoning": "Basic burst type coverage...",
"dependencies": []
}
]
}How it's solved:
- LLM Integration: Sends prompts with design context, uncovered bin details, and covered examples for pattern analysis
- Prompt Engineering: Includes covered bins as examples to help LLM understand patterns
- Heuristic Fallback: Keyword-based pattern matching (e.g., "wrap" β wrap burst tests, "timeout" β timeout scenarios)
- Context Building: Analyzes related covered bins to generate targeted suggestions
- Outputs structured JSON with suggestion, reasoning, test outline, difficulty, and dependencies
Command:
# Prioritization is automatically included in Part 2 output
# Verify with:
cat examples/sample_output.json | python3 -c "import json,sys; d=json.load(sys.stdin); [print(f\"{s['target_bin']}: {s['priority_score']:.3f}\") for s in sorted(d['suggestions'], key=lambda x: x['priority_score'], reverse=True)[:5]]"What it does:
- Scores and prioritizes test suggestions
- Sorts suggestions by priority score (highest first)
Example Output: The suggestions table (shown in Part 2) is automatically sorted by priority score. You can verify top scores:
$ cat examples/sample_output.json | python3 -c "import json,sys; d=json.load(sys.stdin); [print(f\"{s['target_bin']}: {s['priority_score']:.3f}\") for s in sorted(d['suggestions'], key=lambda x: x['priority_score'], reverse=True)[:5]]"
cross_size_burst.medium, fixed: 0.800
cross_size_burst.large, incr: 0.800
cross_size_burst.large, fixed: 0.800
cg_error_scenarios.cp_error_recovery.retry_success: 0.720
cg_error_scenarios.cp_error_recovery.abort: 0.720How it's solved:
- Formula:
Priority Score = (Coverage Impact Γ 0.4) + (Inverse Difficulty Γ 0.3) + (Dependency Score Γ 0.3) - Coverage Impact: Calculates gap in coverage (1.0 - current_coverage/100) - higher gap = higher impact
- Inverse Difficulty: Easy=1.0, Medium=0.5, Hard=0.33
- Dependency Score: 1.0 if no dependencies, 0.5 if dependencies exist
- Bins in low-coverage groups get higher priority
Command:
PYTHONPATH=src python3 -m coverage_analyzer.cli predict examples/sample_report.txtWhat it does:
- Predicts estimated time to closure
- Calculates closure probability
- Identifies potentially blocking bins
Example Output:
{
"estimated_hours_to_closure": 2.8,
"closure_probability": 0.6,
"blocking_bins": [
"cg_error_scenarios.cp_error_recovery.retry_success",
"cg_error_scenarios.cp_error_recovery.abort",
"cg_error_scenarios.cp_error_type.decode_error",
"cg_error_scenarios.cp_error_type.timeout",
"cross_size_burst.small, wrap",
"cross_size_burst.medium, wrap",
"cross_size_burst.large, wrap",
"cg_channel_arbitration.cp_active_channels.all_eight",
"cg_transfer_size.cp_burst_type.wrap"
]
}How it's solved:
- Time Estimation:
Time = uncovered_bins_count / velocity(default velocity: 5 bins/hour) - Probability Calculation:
- Few bins (<5): 90% probability
- Medium (5-14): 75% probability
- Many (15+): 60% probability
- Hard bins reduce probability by 15%
- Blocking Detection: Identifies bins marked as "hard" or with dependencies as potentially blocking
Run end-to-end demo:
PYTHONPATH=src python3 -m coverage_analyzer.cli demo --path examples/sample_report.txtExample Output:
βββββββββββββββββββββββββββββββ Coverage Summary βββββββββββββββββββββββββββββββ
Design: dma_controller
Overall: 54.84%
Uncovered bins: 8 + cross 6
βββββββββββββββββββββββββββββββ Top Suggestions ββββββββββββββββββββββββββββββββ
cross_size_burst.medium, fixed | priority medium | score 0.80
Set burst type to MEDIUM, FIXED mode (register offset 0x04, value 0x3) and run
a minimal transfer. Configure DMA channel 0 with source address 0x10000000...
cross_size_burst.large, incr | priority medium | score 0.80
Set burst type to LARGE, INCR mode (register offset 0x04, value 0x1) and run a
minimal transfer. Configure DMA channel 0 with source address 0x10000000...
ββββββββββββββββββββββββββββββββββ Prediction ββββββββββββββββββββββββββββββββββ
{
"estimated_hours_to_closure": 2.8,
"closure_probability": 0.6,
"blocking_bins": [...]
}
This runs all 4 parts and displays:
- Coverage summary
- Top 5 prioritized suggestions
- Closure prediction
Launch Streamlit interface:
PYTHONPATH=src streamlit run src/coverage_analyzer/web.pyThen open: http://localhost:8501
The web UI provides:
- Interactive report upload
- Visual display of all 4 parts
- Real-time suggestion generation
- Prioritized results table
πΉ UI Demo Video: Watch the web UI in action: UI Demo Video
Assignment-2-Verification-Coverage-Analyzer-with-LLM-Integration/
βββ src/coverage_analyzer/
β βββ parser.py # Part 1: Report parsing
β βββ suggester.py # Part 2: LLM suggestions
β βββ prioritizer.py # Part 3: Prioritization
β βββ predictor.py # Part 4: Closure prediction
β βββ models.py # Pydantic data models
β βββ cli.py # CLI interface
β βββ web.py # Streamlit web UI
βββ examples/ # Sample reports and outputs
βββ parsed_data/ # Parsed JSON outputs
βββ requirements.txt # Python dependencies
βββ setup_api_key.sh # API key setup script (edit before use)
βββ .gitignore # Git ignore rules
βββ README.md # This file
The project includes sample coverage reports and their corresponding outputs:
-
sample_report.txt - DMA Controller coverage report
- Design:
dma_controller - Overall Coverage: 54.84%
- Output:
examples/sample_output.json - Parsed:
parsed_data/sample_parsed.json
- Design:
-
additional_report.txt - AES Engine coverage report
- Design:
aes_engine - Overall Coverage: 44.44%
- Output:
examples/additional_output.json - Parsed:
parsed_data/test_parsed.json
- Design:
-
pcie_controller_report.txt - PCIe Controller coverage report (newly created)
- Design:
pcie_controller - Overall Coverage: 48.57%
- Output:
examples/pcie_output.json - Parsed:
parsed_data/pcie_parsed.json
- Design:
# Part 1: Parse the report
PYTHONPATH=src python3 -m coverage_analyzer.cli parse examples/pcie_controller_report.txt --out parsed_data/pcie_parsed.json
# Part 2 & 3: Generate suggestions with prioritization
PYTHONPATH=src python3 -m coverage_analyzer.cli suggest examples/pcie_controller_report.txt --out examples/pcie_output.json
# Part 4: Predict closure
PYTHONPATH=src python3 -m coverage_analyzer.cli predict examples/pcie_controller_report.txt
# Complete demo
PYTHONPATH=src python3 -m coverage_analyzer.cli demo --path examples/pcie_controller_report.txtPCIe Controller Results:
- Uncovered bins: 7 regular bins + 7 cross-coverage bins
- Total suggestions generated: 14 prioritized suggestions
- Top priority: Error handling scenarios (malformed_packet, crc_error, timeout)
- Estimated closure time: 2.8 hours
- Closure probability: 60%
This project implements a complete coverage analysis pipeline:
- Parser extracts structured data from text reports using regex and state machines
- Suggester generates intelligent test suggestions using LLM with heuristic fallbacks
- Prioritizer scores suggestions using coverage impact, difficulty, and dependencies
- Predictor estimates closure time and probability based on uncovered bins
All parts work together seamlessly through the CLI or web interface, providing a comprehensive solution for verification coverage analysis.