# trnam41/verilogdb-ai architecture

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

- Interactive diagram: https://gitdiagram.com/trnam41/verilogdb-ai
- Repository: https://github.com/trnam41/verilogdb-ai

## Overview

VerilogDB-AI turns a Vietnamese or English hardware request into a verified Verilog-2001 design and Quartus project. Its main workflow plans a test contract, retrieves relevant examples, generates and lints RTL, simulates it with repair on failure, then optionally compiles and emits project artifacts. Separate data curation and model-training capabilities sustain the RAG database and LoRA adapter. Several internal links are based on README descriptions or SOURCE INDEX references; unsampled implementation details are not inferred.

Main entry points: [`agent/design.py`](https://github.com/trnam41/verilogdb-ai/blob/main/agent/design.py) (Workflow coordinator), [`knowledge_base/hardware_db.json`](https://github.com/trnam41/verilogdb-ai/blob/main/knowledge_base/hardware_db.json) (VerilogDB), [`agent/local_api.py`](https://github.com/trnam41/verilogdb-ai/blob/main/agent/local_api.py) (Local model service), [`agent/knowledge_matcher.py`](https://github.com/trnam41/verilogdb-ai/blob/main/agent/knowledge_matcher.py) (Semantic RAG)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_planning["Specification planning"]
  node_design["Workflow coordinator<br/>[design.py]"]
  node_analyzer["Spec analyzer<br/>[spec_analyzer.py]"]
  node_contract["Contract planner<br/>[design_contract.py]"]
end

subgraph group_generation["RTL generation"]
  node_llm["Local model service<br/>[local_api.py]"]
  node_generator["RTL generator<br/>[rtl_generator.py]"]
end

subgraph group_verification["Verification and repair"]
  node_linter["Verilog linter<br/>[verilog_linter.py]"]
  node_testbench["Testbench generator<br/>[tb_generator.py]"]
  node_simulator["Simulation runner<br/>[simulator.py]"]
  node_reflection["Repair loop<br/>[reflection_loop.py]"]
  node_port_audit["Port auditor<br/>[port_auditor.py]"]
end

subgraph group_eda["Quartus outputs"]
  node_profiler["Synthesis profiler"]
  node_bdf["Block diagram exporter<br/>[bdf_generator.py]"]
  node_vwf["Waveform exporter<br/>[vwf_generator.py]"]
end

subgraph group_learning["Knowledge and training"]
  node_rag["Semantic RAG"]
  node_flywheel["Verified-data flywheel<br/>[flywheel.py]"]
  node_hardware_db[("VerilogDB<br/>[hardware_db.json]")]
  node_curation["Database curation"]
  node_ingestion["Dataset ingestion"]
  node_corpus["Corpus builder<br/>[build_corpus.py]"]
  node_semantic_training["RAG training"]
  node_lora_training["LoRA training"]
  node_adapter["LoRA adapter"]
end

node_engineer(("Hardware designer"))
node_eda_tools["EDA toolchain"]

node_engineer -->|"submits request"| node_design
node_design -->|"analyzes spec"| node_analyzer
node_design -->|"plans contract"| node_contract
node_design -->|"retrieves examples"| node_rag
node_design -->|"requests generation"| node_llm
node_llm -->|"generates RTL"| node_generator
node_design -->|"checks RTL"| node_linter
node_design -->|"builds tests"| node_testbench
node_design -->|"runs simulation"| node_simulator
node_simulator -->|"executes simulation"| node_eda_tools
node_design -->|"repairs failures"| node_reflection
node_reflection -->|"requests repair"| node_llm
node_design -->|"audits ports"| node_port_audit
node_design -->|"checks synthesis"| node_profiler
node_profiler -->|"reads reports"| node_eda_tools
node_design -->|"exports diagram"| node_bdf
node_design -->|"exports waveform"| node_vwf
node_design -->|"harvests successes"| node_flywheel
node_flywheel -->|"updates database"| node_hardware_db
node_curation -->|"curates entries"| node_hardware_db
node_ingestion -->|"ingests examples"| node_hardware_db
node_corpus -.->|"builds corpus"| node_hardware_db
node_semantic_training -->|"trains retrieval"| node_rag
node_lora_training -->|"produces adapter"| node_adapter
node_adapter -->|"configures model"| node_llm
node_hardware_db -.->|"provides examples"| node_rag

click node_design "https://github.com/trnam41/verilogdb-ai/blob/main/agent/design.py"
click node_analyzer "https://github.com/trnam41/verilogdb-ai/blob/main/agent/spec_analyzer.py"
click node_contract "https://github.com/trnam41/verilogdb-ai/blob/main/agent/design_contract.py"
click node_rag "https://github.com/trnam41/verilogdb-ai/blob/main/agent/knowledge_matcher.py"
click node_llm "https://github.com/trnam41/verilogdb-ai/blob/main/agent/local_api.py"
click node_generator "https://github.com/trnam41/verilogdb-ai/blob/main/agent/rtl_generator.py"
click node_linter "https://github.com/trnam41/verilogdb-ai/blob/main/agent/verilog_linter.py"
click node_testbench "https://github.com/trnam41/verilogdb-ai/blob/main/agent/tb_generator.py"
click node_simulator "https://github.com/trnam41/verilogdb-ai/blob/main/agent/simulator.py"
click node_reflection "https://github.com/trnam41/verilogdb-ai/blob/main/agent/reflection_loop.py"
click node_port_audit "https://github.com/trnam41/verilogdb-ai/blob/main/agent/port_auditor.py"
click node_profiler "https://github.com/trnam41/verilogdb-ai/blob/main/agent/synthesis_profiler.py"
click node_bdf "https://github.com/trnam41/verilogdb-ai/blob/main/agent/bdf_generator.py"
click node_vwf "https://github.com/trnam41/verilogdb-ai/blob/main/agent/vwf_generator.py"
click node_flywheel "https://github.com/trnam41/verilogdb-ai/blob/main/agent/flywheel.py"
click node_hardware_db "https://github.com/trnam41/verilogdb-ai/blob/main/knowledge_base/hardware_db.json"
click node_curation "https://github.com/trnam41/verilogdb-ai/blob/main/training/curate_verilogdb.py"
click node_ingestion "https://github.com/trnam41/verilogdb-ai/blob/main/training/ingest_clean_1000.py"
click node_corpus "https://github.com/trnam41/verilogdb-ai/blob/main/training/build_corpus.py"
click node_semantic_training "https://github.com/trnam41/verilogdb-ai/blob/main/training/train_semantic_rag.py"
click node_lora_training "https://github.com/trnam41/verilogdb-ai/blob/main/training/train_output_lora.py"
click node_adapter "https://github.com/trnam41/verilogdb-ai/blob/main/training/artifacts/rtl-output-lora.gguf"

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_design,node_analyzer,node_contract toneBlue
class node_llm,node_generator toneAmber
class node_linter,node_testbench,node_simulator,node_reflection,node_port_audit toneMint
class node_profiler,node_bdf,node_vwf toneRose
class node_rag,node_flywheel,node_hardware_db,node_curation,node_ingestion,node_corpus,node_semantic_training,node_lora_training,node_adapter,node_engineer,node_eda_tools toneIndigo
```

## Components

### Specification planning

- [Workflow coordinator](https://github.com/trnam41/verilogdb-ai/blob/main/agent/design.py): `agent/design.py`
- [Spec analyzer](https://github.com/trnam41/verilogdb-ai/blob/main/agent/spec_analyzer.py): `agent/spec_analyzer.py`
- [Contract planner](https://github.com/trnam41/verilogdb-ai/blob/main/agent/design_contract.py): `agent/design_contract.py`

### RTL generation

- [Local model service](https://github.com/trnam41/verilogdb-ai/blob/main/agent/local_api.py): `agent/local_api.py`
- [RTL generator](https://github.com/trnam41/verilogdb-ai/blob/main/agent/rtl_generator.py): `agent/rtl_generator.py`

### Verification and repair

- [Verilog linter](https://github.com/trnam41/verilogdb-ai/blob/main/agent/verilog_linter.py): `agent/verilog_linter.py`
- [Testbench generator](https://github.com/trnam41/verilogdb-ai/blob/main/agent/tb_generator.py): `agent/tb_generator.py`
- [Simulation runner](https://github.com/trnam41/verilogdb-ai/blob/main/agent/simulator.py): `agent/simulator.py`
- [Repair loop](https://github.com/trnam41/verilogdb-ai/blob/main/agent/reflection_loop.py): `agent/reflection_loop.py`
- [Port auditor](https://github.com/trnam41/verilogdb-ai/blob/main/agent/port_auditor.py): `agent/port_auditor.py`

### Quartus outputs

- [Synthesis profiler](https://github.com/trnam41/verilogdb-ai/blob/main/agent/synthesis_profiler.py): `agent/synthesis_profiler.py`
- [Block diagram exporter](https://github.com/trnam41/verilogdb-ai/blob/main/agent/bdf_generator.py): `agent/bdf_generator.py`
- [Waveform exporter](https://github.com/trnam41/verilogdb-ai/blob/main/agent/vwf_generator.py): `agent/vwf_generator.py`

### Knowledge and training

- [Semantic RAG](https://github.com/trnam41/verilogdb-ai/blob/main/agent/knowledge_matcher.py): `agent/knowledge_matcher.py`
- [Verified-data flywheel](https://github.com/trnam41/verilogdb-ai/blob/main/agent/flywheel.py): `agent/flywheel.py`
- [VerilogDB](https://github.com/trnam41/verilogdb-ai/blob/main/knowledge_base/hardware_db.json): `knowledge_base/hardware_db.json`
- [Database curation](https://github.com/trnam41/verilogdb-ai/blob/main/training/curate_verilogdb.py): `training/curate_verilogdb.py`
- [Dataset ingestion](https://github.com/trnam41/verilogdb-ai/blob/main/training/ingest_clean_1000.py): `training/ingest_clean_1000.py`
- [Corpus builder](https://github.com/trnam41/verilogdb-ai/blob/main/training/build_corpus.py): `training/build_corpus.py`
- [RAG training](https://github.com/trnam41/verilogdb-ai/blob/main/training/train_semantic_rag.py): `training/train_semantic_rag.py`
- [LoRA training](https://github.com/trnam41/verilogdb-ai/blob/main/training/train_output_lora.py): `training/train_output_lora.py`
- [LoRA adapter](https://github.com/trnam41/verilogdb-ai/blob/main/training/artifacts/rtl-output-lora.gguf): `training/artifacts/rtl-output-lora.gguf`

### Other components

- **Hardware designer**
- **EDA toolchain**

## Connections

- Hardware designer → Workflow coordinator: submits request (evidence: `README.md`)
- Workflow coordinator → Spec analyzer: analyzes spec (evidence: `agent/design.py`)
- Workflow coordinator → Contract planner: plans contract (evidence: `README.md`)
- Workflow coordinator → Semantic RAG: retrieves examples (evidence: `README.md`)
- Workflow coordinator → Local model service: requests generation (evidence: `README.md`)
- Local model service → RTL generator: generates RTL (evidence: `README.md`)
- Workflow coordinator → Verilog linter: checks RTL (evidence: `README.md`)
- Workflow coordinator → Testbench generator: builds tests (evidence: `README.md`)
- Workflow coordinator → Simulation runner: runs simulation (evidence: `README.md`)
- Simulation runner → EDA toolchain: executes simulation (evidence: `README.md`)
- Workflow coordinator → Repair loop: repairs failures (evidence: `README.md`)
- Repair loop → Local model service: requests repair (evidence: `README.md`)
- Workflow coordinator → Port auditor: audits ports
- Workflow coordinator → Synthesis profiler: checks synthesis
- Synthesis profiler → EDA toolchain: reads reports (evidence: `agent/synthesis_profiler.py`)
- Workflow coordinator → Block diagram exporter: exports diagram
- Workflow coordinator → Waveform exporter: exports waveform
- Workflow coordinator → Verified-data flywheel: harvests successes (evidence: `README.md`)
- Verified-data flywheel → VerilogDB: updates database (evidence: `README.md`)
- Database curation → VerilogDB: curates entries (evidence: `training/curate_verilogdb.py`)
- Dataset ingestion → VerilogDB: ingests examples (evidence: `training/ingest_clean_1000.py`)
- Corpus builder → VerilogDB: builds corpus
- RAG training → Semantic RAG: trains retrieval (evidence: `README.md`)
- LoRA training → LoRA adapter: produces adapter (evidence: `README.md`)
- LoRA adapter → Local model service: configures model (evidence: `README.md`)
- VerilogDB → Semantic RAG: provides examples
