# chandansaipavanpadala/spectra architecture

> Architecture diagram of the GitHub repository chandansaipavanpadala/spectra, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chandansaipavanpadala/spectra
- Repository: https://github.com/chandansaipavanpadala/spectra

## Overview

SPECTRA is a side-channel Hardware Trojan detection framework, with a documented workflow from power-trace acquisition through spectral features, unsupervised cluster labeling, PCA, and fusion-distance classification. The repository implements the core stages as separate Python scripts that exchange JSON reports; README documents additional noise-robustness, benchmark-generalization, and RTL utilization analyses. Trace acquisition is simulated in the scripts rather than sampled from physical hardware. Edges are limited to relationships shown in excerpts or the README.

Main entry points: [`reports/spectral_eigenvectors.json`](https://github.com/chandansaipavanpadala/spectra/blob/main/reports/spectral_eigenvectors.json) (Spectral Features Data), [`scripts/04_fusion_classifier.py`](https://github.com/chandansaipavanpadala/spectra/blob/main/scripts/04_fusion_classifier.py) (Fusion Classifier), [`scripts/07_synth_utilization_table.py`](https://github.com/chandansaipavanpadala/spectra/blob/main/scripts/07_synth_utilization_table.py) (RTL Utilization Analysis), [`src/aes_128.v`](https://github.com/chandansaipavanpadala/spectra/blob/main/src/aes_128.v) (Golden AES)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_rtl["RTL Examples"]
  node_aes["Golden AES<br/>[aes_128.v]"]
  node_trojan_aes["Trojan AES<br/>[aes_128_trojan.v]"]
  node_testbench["Simulation Bench<br/>[tb_sidechannel.v]"]
end

subgraph group_pipeline["Detection Pipeline"]
  node_trace["Trace Synthesis"]
  node_sfa["Spectral Features"]
  node_fcm["FCM and SEA"]
  node_pca["PCA Subspace"]
  node_fusion["Fusion Classifier"]
  node_eigen_report["Spectral Features Data"]
  node_cluster_report["Cluster Centers"]
  node_pca_report["PCA Parameters<br/>[pca_subspace.json]"]
  node_detection_report["Detection Results"]
end

subgraph group_evaluation["Evaluation"]
  node_noise_eval["Noise Robustness"]
  node_benchmark_eval["Benchmark Generalization"]
  node_utilization["RTL Utilization Analysis"]
  node_util_report["Utilization Report"]
end

node_vectors(("Test Vectors"))

node_vectors -.->|"stimulates"| node_trace
node_aes -.->|"simulated by"| node_testbench
node_trojan_aes -.->|"simulated by"| node_testbench
node_trace -->|"generates traces"| node_sfa
node_sfa -->|"writes features"| node_eigen_report
node_eigen_report -->|"loads features"| node_fcm
node_fcm -->|"writes centers"| node_cluster_report
node_eigen_report -->|"loads features"| node_pca
node_pca -->|"writes subspace"| node_pca_report
node_eigen_report -->|"loads validation data"| node_fusion
node_cluster_report -->|"loads centers"| node_fusion
node_pca_report -->|"loads projection"| node_fusion
node_fusion -->|"writes metrics"| node_detection_report
node_aes -->|"analyzes RTL"| node_utilization
node_trojan_aes -->|"analyzes RTL"| node_utilization
node_utilization -->|"writes report"| node_util_report

click node_aes "https://github.com/chandansaipavanpadala/spectra/blob/main/src/aes_128.v"
click node_trojan_aes "https://github.com/chandansaipavanpadala/spectra/blob/main/src/aes_128_trojan.v"
click node_testbench "https://github.com/chandansaipavanpadala/spectra/blob/main/src/tb_sidechannel.v"
click node_trace "https://github.com/chandansaipavanpadala/spectra/blob/main/scripts/01_sfa_feature_extract.py"
click node_sfa "https://github.com/chandansaipavanpadala/spectra/blob/main/scripts/01_sfa_feature_extract.py"
click node_fcm "https://github.com/chandansaipavanpadala/spectra/blob/main/scripts/02_fcc_sea_clustering.py"
click node_pca "https://github.com/chandansaipavanpadala/spectra/blob/main/scripts/03_pca_dimension_reduc.py"
click node_fusion "https://github.com/chandansaipavanpadala/spectra/blob/main/scripts/04_fusion_classifier.py"
click node_eigen_report "https://github.com/chandansaipavanpadala/spectra/blob/main/reports/spectral_eigenvectors.json"
click node_cluster_report "https://github.com/chandansaipavanpadala/spectra/blob/main/reports/clustering_results.json"
click node_pca_report "https://github.com/chandansaipavanpadala/spectra/blob/main/reports/pca_subspace.json"
click node_detection_report "https://github.com/chandansaipavanpadala/spectra/blob/main/reports/detection_report.json"
click node_noise_eval "https://github.com/chandansaipavanpadala/spectra/blob/main/scripts/05_noise_robustness_sweep.py"
click node_benchmark_eval "https://github.com/chandansaipavanpadala/spectra/blob/main/scripts/06_benchmark_generalization.py"
click node_utilization "https://github.com/chandansaipavanpadala/spectra/blob/main/scripts/07_synth_utilization_table.py"
click node_util_report "https://github.com/chandansaipavanpadala/spectra/blob/main/reports/fpga_hardware_utilization.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_aes,node_trojan_aes,node_testbench toneBlue
class node_trace,node_sfa,node_fcm,node_pca,node_fusion,node_eigen_report,node_cluster_report,node_pca_report,node_detection_report toneAmber
class node_noise_eval,node_benchmark_eval,node_utilization,node_util_report toneMint
class node_vectors toneIndigo
```

## Components

### RTL Examples

- [Golden AES](https://github.com/chandansaipavanpadala/spectra/blob/main/src/aes_128.v): `src/aes_128.v`
- [Trojan AES](https://github.com/chandansaipavanpadala/spectra/blob/main/src/aes_128_trojan.v): `src/aes_128_trojan.v`
- [Simulation Bench](https://github.com/chandansaipavanpadala/spectra/blob/main/src/tb_sidechannel.v): `src/tb_sidechannel.v`

### Detection Pipeline

- [Trace Synthesis](https://github.com/chandansaipavanpadala/spectra/blob/main/scripts/01_sfa_feature_extract.py): `scripts/01_sfa_feature_extract.py`
- [Spectral Features](https://github.com/chandansaipavanpadala/spectra/blob/main/scripts/01_sfa_feature_extract.py): `scripts/01_sfa_feature_extract.py`
- [FCM and SEA](https://github.com/chandansaipavanpadala/spectra/blob/main/scripts/02_fcc_sea_clustering.py): `scripts/02_fcc_sea_clustering.py`
- [PCA Subspace](https://github.com/chandansaipavanpadala/spectra/blob/main/scripts/03_pca_dimension_reduc.py): `scripts/03_pca_dimension_reduc.py`
- [Fusion Classifier](https://github.com/chandansaipavanpadala/spectra/blob/main/scripts/04_fusion_classifier.py): `scripts/04_fusion_classifier.py`
- [Spectral Features Data](https://github.com/chandansaipavanpadala/spectra/blob/main/reports/spectral_eigenvectors.json): `reports/spectral_eigenvectors.json`
- [Cluster Centers](https://github.com/chandansaipavanpadala/spectra/blob/main/reports/clustering_results.json): `reports/clustering_results.json`
- [PCA Parameters](https://github.com/chandansaipavanpadala/spectra/blob/main/reports/pca_subspace.json): `reports/pca_subspace.json`
- [Detection Results](https://github.com/chandansaipavanpadala/spectra/blob/main/reports/detection_report.json): `reports/detection_report.json`

### Evaluation

- [Noise Robustness](https://github.com/chandansaipavanpadala/spectra/blob/main/scripts/05_noise_robustness_sweep.py): `scripts/05_noise_robustness_sweep.py`
- [Benchmark Generalization](https://github.com/chandansaipavanpadala/spectra/blob/main/scripts/06_benchmark_generalization.py): `scripts/06_benchmark_generalization.py`
- [RTL Utilization Analysis](https://github.com/chandansaipavanpadala/spectra/blob/main/scripts/07_synth_utilization_table.py): `scripts/07_synth_utilization_table.py`
- [Utilization Report](https://github.com/chandansaipavanpadala/spectra/blob/main/reports/fpga_hardware_utilization.json): `reports/fpga_hardware_utilization.json`

### Other components

- **Test Vectors**

## Connections

- Test Vectors → Trace Synthesis: stimulates (evidence: `README.md`)
- Golden AES → Simulation Bench: simulated by
- Trojan AES → Simulation Bench: simulated by
- Trace Synthesis → Spectral Features: generates traces (evidence: `scripts/01_sfa_feature_extract.py`)
- Spectral Features → Spectral Features Data: writes features (evidence: `scripts/01_sfa_feature_extract.py`)
- Spectral Features Data → FCM and SEA: loads features (evidence: `scripts/02_fcc_sea_clustering.py`)
- FCM and SEA → Cluster Centers: writes centers (evidence: `scripts/02_fcc_sea_clustering.py`)
- Spectral Features Data → PCA Subspace: loads features (evidence: `scripts/03_pca_dimension_reduc.py`)
- PCA Subspace → PCA Parameters: writes subspace (evidence: `scripts/03_pca_dimension_reduc.py`)
- Spectral Features Data → Fusion Classifier: loads validation data (evidence: `scripts/04_fusion_classifier.py`)
- Cluster Centers → Fusion Classifier: loads centers (evidence: `scripts/04_fusion_classifier.py`)
- PCA Parameters → Fusion Classifier: loads projection (evidence: `scripts/04_fusion_classifier.py`)
- Fusion Classifier → Detection Results: writes metrics (evidence: `scripts/04_fusion_classifier.py`)
- Golden AES → RTL Utilization Analysis: analyzes RTL (evidence: `scripts/07_synth_utilization_table.py`)
- Trojan AES → RTL Utilization Analysis: analyzes RTL (evidence: `scripts/07_synth_utilization_table.py`)
- RTL Utilization Analysis → Utilization Report: writes report (evidence: `scripts/07_synth_utilization_table.py`)
