Skip to content

devansh0703/chip_design_agent

Repository files navigation

ASIC-Agent πŸ”¬

Autonomous Multi-Agent System for ASIC Design - LLM-powered end-to-end chip design workflow from natural language specification to silicon-ready GDSII.

OpenLane Sky130 Python

πŸš€ Features

  • LLM-Powered RTL Generation: Generate Verilog from natural language using Gemini/Mistral
  • Automated Verification: cocotb testbench generation and simulation with Icarus Verilog
  • Real ASIC Hardening: Complete RTL-to-GDSII flow using OpenLane in Docker
  • Caravel Integration: Automatic integration with Efabless Caravel for tapeout
  • Knowledge Base: RAG-powered design assistance using ChromaDB
  • Multi-Agent Architecture: Specialized agents for each design stage

NO SIMULATIONS - 100% REAL TOOLS:

  • βœ… Real Docker OpenLane execution (Yosys, OpenROAD, Magic)
  • βœ… Real Sky130 PDK (2.4GB process design kit)
  • βœ… Real GDSII generation (fabrication-ready layouts)
  • βœ… Real git operations (Caravel clone)

πŸ“‹ Requirements

Software

  • Python 3.10+
  • Docker (for OpenLane)
  • Git (for Caravel integration)
  • Icarus Verilog (iverilog)
  • Verilator (linting)

Python Packages

pip install -r requirements.txt

Core dependencies:

  • openai - LLM API client
  • mistralai - Mistral LLM support
  • chromadb - Vector database for RAG
  • cocotb - Hardware verification framework
  • langchain - Agent orchestration

API Keys

  • OpenRouter API Key (for Gemini/Claude) OR
  • Mistral API Key

Set via environment variable:

export OPENROUTER_API_KEY="your-key-here"
# OR
export MISTRAL_API_KEY="your-key-here"

πŸ› οΈ Installation

1. Install System Dependencies

Ubuntu/Debian:

sudo apt update
sudo apt install -y docker.io git iverilog verilator python3-pip
sudo usermod -aG docker $USER  # Allow Docker without sudo
newgrp docker  # Apply group change

macOS:

brew install docker git icarus-verilog verilator python3

2. Install Python Dependencies

git clone https://github.com/yourusername/asic-agent.git
cd asic-agent
pip install -r requirements.txt

3. Build Knowledge Base from Real Documentation

CRITICAL: Build the knowledge base with real scraped documentation:

# Automated setup (recommended)
./scripts/setup_knowledge_base.sh

# OR manual build
python3 scripts/build_knowledge_base.py

This scrapes REAL documentation from:

  • cocotb official docs (docs.cocotb.org)
  • cocotb GitHub examples
  • OpenLane documentation
  • Curated Verilog patterns

Takes ~30-60 seconds, creates chroma_db/ with vector database.

4. Set Up API Key

echo 'export OPENROUTER_API_KEY="sk-or-v1-..."' >> ~/.bashrc
source ~/.bashrc

5. First Run (Downloads Sky130 PDK ~2.4GB)

python3 main.py "Design a 4-bit counter" --name counter4bit

The first run will download the Sky130 PDK to ~/.volare/ (one-time, ~5 minutes).

πŸ’» Usage

Basic Usage

python3 main.py "Design a [your specification]" --name [design_name]

Examples

Simple Counter:

python3 main.py "Design a 8-bit counter with synchronous reset" --name counter8bit

Shift Register:

python3 main.py "Design a 16-bit shift register with parallel load" --name shift_reg

Custom Configuration:

python3 main.py "Design a 2-bit counter" \
  --name counter2bit \
  --provider openrouter \
  --model google/gemini-2.0-flash-001 \
  --max-iterations 3 \
  --rate-limit 4.0

Command-Line Options

--name NAME              Design name (required)
--provider PROVIDER      LLM provider: 'openrouter' or 'mistral' (default: openrouter)
--model MODEL           Model name (default: google/gemini-2.0-flash-001)
--max-iterations N      Max debug iterations per stage (default: 5)
--rate-limit SECONDS    Delay between API calls (default: 6.0)
--no-rate-limit         Disable rate limiting

πŸ—οΈ Workflow Stages

1. RTL Generation πŸ€–

  • LLM generates Verilog from natural language
  • Automatic module inference and port generation
  • Best practices from knowledge base

2. Linting πŸ”

  • Verilator syntax checking
  • LLM-powered error fixing
  • Iterative refinement

3. Verification βœ…

  • Automatic cocotb testbench generation
  • Icarus Verilog simulation
  • Coverage-driven test generation

4. Hardening 🏭

REAL OpenLane Docker Execution:

  • Yosys synthesis
  • Floorplanning (OpenROAD)
  • Placement & routing
  • Clock tree synthesis
  • Magic GDSII generation

Output: workspace/design.gds (818KB+ silicon-ready layout)

5. Integration πŸš€

REAL Caravel Repository Clone:

  • Git clone efabless/caravel_user_project
  • GDS integration
  • Wrapper generation
  • Tapeout preparation

πŸ“‚ Project Structure

asic-agent/
β”œβ”€β”€ asic_agent/
β”‚   β”œβ”€β”€ agents/           # Specialized agents
β”‚   β”‚   β”œβ”€β”€ main_agent.py          # RTL generation
β”‚   β”‚   β”œβ”€β”€ verification_agent.py   # Testbench generation
β”‚   β”‚   β”œβ”€β”€ hardening_agent.py      # OpenLane execution
β”‚   β”‚   └── caravel_agent.py        # Caravel integration
β”‚   β”œβ”€β”€ workflows/        # Orchestration
β”‚   β”‚   └── orchestrator.py
β”‚   β”œβ”€β”€ database/         # Knowledge base
β”‚   β”‚   └── knowledge_base.py
β”‚   β”œβ”€β”€ llm_client.py     # LLM API wrapper
β”‚   └── config.py         # Configuration
β”œβ”€β”€ workspace/            # Design outputs (gitignored)
β”‚   β”œβ”€β”€ design.v          # Generated RTL
β”‚   β”œβ”€β”€ design.gds        # Final GDSII
β”‚   └── openlane_run/     # OpenLane artifacts
β”œβ”€β”€ main.py              # CLI entry point
β”œβ”€β”€ requirements.txt     # Python dependencies
└── README.md           # This file

🎯 Output Files

After successful workflow:

workspace/
β”œβ”€β”€ [design_name].v              # RTL Verilog
β”œβ”€β”€ test_[design_name].py        # cocotb testbench
β”œβ”€β”€ design.gds                   # GDSII layout (818KB+)
β”œβ”€β”€ config.json                  # OpenLane configuration
β”œβ”€β”€ openlane_run/
β”‚   └── designs/[name]/runs/run1/
β”‚       └── results/final/
β”‚           β”œβ”€β”€ gds/            # GDSII files
β”‚           β”œβ”€β”€ verilog/gl/    # Gate-level netlist
β”‚           β”œβ”€β”€ lef/           # Cell abstracts
β”‚           β”œβ”€β”€ spef/          # Parasitic extraction
β”‚           └── sdf/           # Timing data
└── caravel_user_project/       # Cloned Caravel repo
    β”œβ”€β”€ gds/                    # Integrated GDS
    └── verilog/rtl/           # Integrated RTL

πŸ”¬ Real Tool Integration

OpenLane (Docker)

subprocess.run([
    'docker', 'run', '--rm',
    '-v', f'{design_dir}:/openlane',
    '-v', f'{pdk_root}:/root/.volare',
    'efabless/openlane:latest',
    'flow.tcl', '-tag', 'run1', '-overwrite'
])

Caravel (Git)

subprocess.run([
    'git', 'clone', '--depth', '1',
    'https://github.com/efabless/caravel_user_project.git',
    caravel_dir
])

Runtime: 15-30 minutes for complete RTL-to-GDSII flow (small designs)

πŸ› Troubleshooting

Docker Permission Denied

sudo usermod -aG docker $USER
newgrp docker

PDK Not Found

# Manual PDK fetch
docker run --rm -v ~/.volare:/root/.volare efabless/openlane:latest \
  volare fetch sky130 bdc9412b3e468c102d01b7cf6337be06ec6e9c9a

Rate Limit Errors (Gemini)

# Increase delay between requests
python3 main.py "..." --rate-limit 10.0

Verification Failures

Check cocotb test logic in workspace/test_*.py - LLM may generate incorrect timing

πŸ“Š Example Output

╔═══════════════════════════════════════════════════════════════╗
β•‘                         ASIC-Agent                            β•‘
β•‘         Autonomous Multi-Agent System for ASIC Design         β•‘
β•‘  Powered by: OpenRouter/Gemini + ChromaDB + LangGraph      β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

Configuration: Provider=openrouter, Model=google/gemini-2.0-flash-001

=== RTL Generation Stage ===
βœ“ Generated RTL saved to: workspace/counter2bit.v

=== Linting Stage ===
βœ“ Linting passed

=== Verification Stage ===
βœ“ Verification passed

=== Hardening Stage ===
βœ“ OpenLane synthesis complete
βœ“ Place & route complete
βœ“ GDSII generated: workspace/design.gds (818KB)

=== Integration Stage ===
βœ“ Caravel cloned successfully
βœ“ GDS integrated

============================================================
WORKFLOW RESULTS
============================================================
Design Name: counter2bit
Final Stage: integration

RTL Files Generated:
  βœ“ counter2bit.v

βœ“ Linting: PASSED
βœ“ Verification: PASSED
βœ“ Hardening: PASSED (design.gds)
βœ“ Integration: PASSED
============================================================

🀝 Contributing

Contributions welcome! Areas for improvement:

  • More complex design patterns in knowledge base
  • Additional verification strategies
  • Timing optimization heuristics
  • Multi-module design support

πŸ“„ License

MIT License - See LICENSE file

πŸ™ Acknowledgments

  • OpenLane: RTL-to-GDSII flow (Efabless)
  • Sky130 PDK: Open-source process design kit (Google/Skywater)
  • Caravel: Open-source chip harness (Efabless)
  • cocotb: Python verification framework
  • OpenRouter: LLM API gateway

⚠️ Disclaimer

This tool generates real GDSII layouts but does not validate designs for production. For actual tapeout:

  1. Run full DRC/LVS verification
  2. Perform timing closure analysis
  3. Add proper power/ground distribution
  4. Follow foundry design rules
  5. Use professional EDA tools for sign-off

Educational/Research Use Only

About

LLM-powered end-to-end chip design workflow from natural language specification to silicon-ready GDSII.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors