This project addresses the growing threat of hardware Trojans—malicious modifications to chip designs—by leveraging Artificial Intelligence (AI) to detect anomalies in Register Transfer Level (RTL) code and post-silicon physical layouts (GDSII). The tool is designed to integrate seamlessly into semiconductor design workflows, providing a robust pre-silicon security checkpoint.
By combining Graph Neural Networks (GNNs) and anomaly detection techniques, the system identifies suspicious patterns in RTL designs and physical layouts, helping engineers mitigate risks before fabrication. The solution is tailored for IC design houses, foundries, and defense organizations, with a focus on securing Taiwan's semiconductor ecosystem.
-
Graph-Based RTL Modeling:
- Converts Verilog/VHDL designs into graph representations.
- Nodes represent logic elements (e.g., modules, gates), and edges represent connections.
- Enables AI-based pattern recognition of Trojan circuitry.
-
AI Anomaly Detection Engine:
- Combines supervised learning (GNN-based classifier) and unsupervised anomaly detection.
- Flags rarely-triggered logic, unexpected signal dependencies, and other suspicious patterns.
-
Physical Layout Analysis:
- Uses YOLOv8 for detecting anomalies in GDSII layouts (e.g., rogue vias, power grid tampering).
- Integrates with open-source tools like Klayout for layout parsing.
-
Trojan Test Case Library:
- Includes Trust-Hub benchmarks and custom Trojan-injected RTL designs for training and evaluation.
-
Integration with Design Flows:
- Outputs detailed reports highlighting suspect modules or signals with risk scores.
- Fits into existing EDA workflows as a security linting step.
hardware_trojan_detector/
├── data_processing/
│ ├── rtl_processor.py # Parses RTL files and builds graph representations
│ ├── layout_processor.py # Analyzes GDSII layouts for physical anomalies
│ └── graph_builder.py # Converts AST into graph structures
├── ai_models/
│ ├── gnn_model.py # Implements Graph Neural Network for RTL analysis
│ ├── yolo_model.py # YOLOv8-based detection for GDSII layouts
│ └── anomaly_detector.py # Anomaly detection models (autoencoder, isolation forest)
├── utils/
│ ├── logger.py # Logging utility
│ └── config_manager.py # Manages configuration files
├── configs/
│ ├── paths.yaml # Paths to data, models, and parameters
│ └── model_params.yaml # Model-specific hyperparameters
├── tests/
│ ├── test_rtl_processing.py # Unit tests for RTL processing
│ └── test_layout_processing.py # Unit tests for layout processing
├── scripts/
│ ├── train_model.py # Script to train AI models
│ └── run_detection.py # Main script to perform Trojan detection
├── Dockerfile # Docker container definition
├── requirements.txt # Python dependencies
└── README.md # Project documentation
- Python 3.8+
- NVIDIA CUDA Toolkit (for GPU acceleration)
- Docker (optional for containerized execution)
- Install Python dependencies:
pip install -r requirements.txt
Place your RTL design files in a directory (e.g., rtl_project/
):
rtl_project/
├── top_module.v
├── crypto_core.v
├── communication_interface.v
Update configs/paths.yaml
to point to your RTL directory:
paths:
rtl_samples: "rtl_project/"
model_weights: "models/pretrained/gnn_model.pth"
rtl_params:
embedding_size: 128
window_size: 5
layout_params:
yolo_model_path: "models/yolo/best.pt"
Train the Graph Neural Network (GNN) or YOLO model using the provided training script:
python scripts/train_model.py --config configs/model_params.yaml
This will:
- Parse RTL files into graph representations.
- Train the GNN on known Trojan examples.
- Save the trained model weights to
models/pretrained/gnn_model.pth
.
Run Trojan detection on your RTL project or GDSII layout files:
python scripts/run_detection.py \
--rtl rtl_project/top_module.v \
--config configs/paths.yaml
python scripts/run_detection.py \
--gdsii layout.gds \
--config configs/paths.yaml
To analyze all RTL files in a directory:
for file in rtl_project/*.v; do
python scripts/run_detection.py --rtl $file --config configs/paths.yaml;
done;
The tool generates detailed reports highlighting potential Trojans:
[INFO] Processing RTL file: rtl_project/top_module.v...
[INFO] Detected potential Trojan in module 'crypto_core':
- Trigger Condition: Rarely activated always block at line 120.
- Risk Score: HIGH
[INFO] Processing GDSII file: layout.gds...
[INFO] Detected anomalies in layer METAL1:
- Class 'RogueVia', Confidence: 0.92, Bounding Box: [512, 256, 600, 320]
- Class 'PowerTamper', Confidence: 0.87, Bounding Box: [1024, 512, 1200, 640]
[INFO] Detection completed. Report saved to reports/detection_report.txt.
The report (reports/detection_report.txt
) includes flagged modules/signals with explanations.
Run unit tests to validate individual components:
pytest tests/ -v
To run the project in a containerized environment:
docker build -t hardware_trojan_detector .
docker run --rm -it \
-v $(pwd)/samples:/app/samples \
-v $(pwd)/configs:/app/configs \
hardware_trojan_detector \
python scripts/run_detection.py \
--rtl samples/top_module.v \
--config configs/paths.yaml
- Graph Neural Network (GNN): Detects structural anomalies in RTL designs.
- YOLOv8 Layout Analysis: Identifies physical anomalies in GDSII files.
- Trojan Test Case Library: Includes Trust-Hub benchmarks and custom examples.
- Seamless Integration: Fits into existing EDA workflows as a security checkpoint.
- IC Design Houses: Vet third-party IP blocks during the design phase.
- Semiconductor Foundries: Ensure customer-provided designs are Trojan-free before fabrication.
- Defense Organizations: Evaluate chip designs for critical infrastructure projects.
- Expand the Trojan library with more real-world examples.
- Integrate formal verification techniques for flagged regions.
- Optimize the GNN architecture for larger designs.
We welcome contributions! Please follow these steps:
- Fork the repository on GitHub.
- Create a new branch (
feature/new-feature
). - Commit changes and submit a pull request.
For questions or feedback, please contact us at [[email protected]], [[email protected]].
- Garv Sachdev [[email protected]]
This project is licensed under the MIT License.