# niftylab/laygo2 architecture

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

- Interactive diagram: https://gitdiagram.com/niftylab/laygo2
- Repository: https://github.com/niftylab/laygo2

## Overview

LAYGO2 is a Python framework for generating custom IC layouts. A designer defines technology-specific templates and placement/routing grids, builds a design from physical objects, and exports the result through tool or data-format interfaces. The graph preserves the documented object-model stages and the major interface options. Some runtime links are based only on imports or examples in the supplied excerpts; unverified workflow links are dashed.

Main entry points: [`laygo2/object/database.py`](https://github.com/niftylab/laygo2/blob/master/laygo2/object/database.py) (Design database), [`laygo2/object/grid/routing.py`](https://github.com/niftylab/laygo2/blob/master/laygo2/object/grid/routing.py) (Routing grids), [`laygo2_tech_quick_start/laygo2_tech_templates.py`](https://github.com/niftylab/laygo2/blob/master/laygo2_tech_quick_start/laygo2_tech_templates.py) (Tech templates), [`laygo2/object/grid/core.py`](https://github.com/niftylab/laygo2/blob/master/laygo2/object/grid/core.py) (Coordinate grids)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_design["Design model"]
  node_templates["Layout templates<br/>[core.py]"]
  node_route_templates["Routing meshes<br/>[routing.py]"]
  node_grids["Coordinate grids<br/>[core.py]"]
  node_place_grid["Placement grids<br/>[placement.py]"]
  node_route_grid["Routing grids<br/>[routing.py]"]
  node_physical["Layout objects<br/>[physical.py]"]
  node_database[("Design database<br/>[database.py]")]
end

subgraph group_tech["Technology setup"]
  node_tech_config["Technology config<br/>[laygo2_tech.yaml]"]
  node_tech_templates["Tech templates"]
  node_tech_grids["Tech grids"]
end

subgraph group_interfaces["Interchange interfaces"]
  node_yaml["YAML templates<br/>[yaml.py]"]
  node_gds["GDS export<br/>[gdspy.py]"]
  node_skill["SKILL export<br/>[skill.py]"]
  node_bag["BAG export<br/>[bag.py]"]
  node_magic["Magic export<br/>[magic.py]"]
  node_plot["Layout plotting<br/>[mpl.py]"]
end

subgraph group_tools["External tools"]
  node_cad_tool{{"CAD tools"}}
  node_yaml_files["YAML files"]
end

node_designer(("IC designer"))

node_designer -.->|"creates design"| node_database
node_designer -.->|"selects technology"| node_tech_templates
node_tech_config -->|"configures"| node_tech_templates
node_tech_templates -->|"builds templates"| node_templates
node_tech_grids -->|"builds grids"| node_grids
node_tech_grids -->|"uses design database"| node_database
node_database -->|"stores objects"| node_physical
node_database -.->|"instantiates from"| node_templates
node_database -.->|"places on"| node_place_grid
node_database -.->|"routes on"| node_route_grid
node_place_grid -->|"extends"| node_grids
node_route_grid -->|"extends"| node_grids
node_route_grid -->|"creates wires"| node_physical
node_route_templates -->|"generates instances"| node_physical
node_designer -.->|"imports templates"| node_yaml
node_yaml -->|"reads or writes"| node_yaml_files
node_database -.->|"exports layout"| node_gds
node_database -.->|"exports layout"| node_skill
node_database -.->|"exports layout"| node_bag
node_database -.->|"exports layout"| node_magic
node_database -.->|"plots layout"| node_plot
node_gds -.->|"writes layout"| node_cad_tool
node_skill -.->|"targets"| node_cad_tool
node_bag -.->|"targets"| node_cad_tool
node_magic -.->|"targets"| node_cad_tool

click node_templates "https://github.com/niftylab/laygo2/blob/master/laygo2/object/template/core.py"
click node_route_templates "https://github.com/niftylab/laygo2/blob/master/laygo2/object/template/routing.py"
click node_grids "https://github.com/niftylab/laygo2/blob/master/laygo2/object/grid/core.py"
click node_place_grid "https://github.com/niftylab/laygo2/blob/master/laygo2/object/grid/placement.py"
click node_route_grid "https://github.com/niftylab/laygo2/blob/master/laygo2/object/grid/routing.py"
click node_physical "https://github.com/niftylab/laygo2/blob/master/laygo2/object/physical.py"
click node_database "https://github.com/niftylab/laygo2/blob/master/laygo2/object/database.py"
click node_tech_config "https://github.com/niftylab/laygo2/blob/master/laygo2_tech_quick_start/laygo2_tech.yaml"
click node_tech_templates "https://github.com/niftylab/laygo2/blob/master/laygo2_tech_quick_start/laygo2_tech_templates.py"
click node_tech_grids "https://github.com/niftylab/laygo2/blob/master/laygo2_tech_quick_start/laygo2_tech_grids.py"
click node_yaml "https://github.com/niftylab/laygo2/blob/master/laygo2/interface/yaml.py"
click node_gds "https://github.com/niftylab/laygo2/blob/master/laygo2/interface/gdspy.py"
click node_skill "https://github.com/niftylab/laygo2/blob/master/laygo2/interface/skill.py"
click node_bag "https://github.com/niftylab/laygo2/blob/master/laygo2/interface/bag.py"
click node_magic "https://github.com/niftylab/laygo2/blob/master/laygo2/interface/magic.py"
click node_plot "https://github.com/niftylab/laygo2/blob/master/laygo2/interface/mpl.py"

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_templates,node_route_templates,node_grids,node_place_grid,node_route_grid,node_physical,node_database toneBlue
class node_tech_config,node_tech_templates,node_tech_grids toneAmber
class node_yaml,node_gds,node_skill,node_bag,node_magic,node_plot toneMint
class node_cad_tool,node_yaml_files toneRose
class node_designer toneIndigo
```

## Components

### Design model

- [Layout templates](https://github.com/niftylab/laygo2/blob/master/laygo2/object/template/core.py): `laygo2/object/template/core.py`
- [Routing meshes](https://github.com/niftylab/laygo2/blob/master/laygo2/object/template/routing.py): `laygo2/object/template/routing.py`
- [Coordinate grids](https://github.com/niftylab/laygo2/blob/master/laygo2/object/grid/core.py): `laygo2/object/grid/core.py`
- [Placement grids](https://github.com/niftylab/laygo2/blob/master/laygo2/object/grid/placement.py): `laygo2/object/grid/placement.py`
- [Routing grids](https://github.com/niftylab/laygo2/blob/master/laygo2/object/grid/routing.py): `laygo2/object/grid/routing.py`
- [Layout objects](https://github.com/niftylab/laygo2/blob/master/laygo2/object/physical.py): `laygo2/object/physical.py`
- [Design database](https://github.com/niftylab/laygo2/blob/master/laygo2/object/database.py): `laygo2/object/database.py`

### Technology setup

- [Technology config](https://github.com/niftylab/laygo2/blob/master/laygo2_tech_quick_start/laygo2_tech.yaml): `laygo2_tech_quick_start/laygo2_tech.yaml`
- [Tech templates](https://github.com/niftylab/laygo2/blob/master/laygo2_tech_quick_start/laygo2_tech_templates.py): `laygo2_tech_quick_start/laygo2_tech_templates.py`
- [Tech grids](https://github.com/niftylab/laygo2/blob/master/laygo2_tech_quick_start/laygo2_tech_grids.py): `laygo2_tech_quick_start/laygo2_tech_grids.py`

### Interchange interfaces

- [YAML templates](https://github.com/niftylab/laygo2/blob/master/laygo2/interface/yaml.py): `laygo2/interface/yaml.py`
- [GDS export](https://github.com/niftylab/laygo2/blob/master/laygo2/interface/gdspy.py): `laygo2/interface/gdspy.py`
- [SKILL export](https://github.com/niftylab/laygo2/blob/master/laygo2/interface/skill.py): `laygo2/interface/skill.py`
- [BAG export](https://github.com/niftylab/laygo2/blob/master/laygo2/interface/bag.py): `laygo2/interface/bag.py`
- [Magic export](https://github.com/niftylab/laygo2/blob/master/laygo2/interface/magic.py): `laygo2/interface/magic.py`
- [Layout plotting](https://github.com/niftylab/laygo2/blob/master/laygo2/interface/mpl.py): `laygo2/interface/mpl.py`

### External tools

- **CAD tools**
- **YAML files**

### Other components

- **IC designer**

## Connections

- IC designer → Design database: creates design
- IC designer → Tech templates: selects technology
- Technology config → Tech templates: configures
- Tech templates → Layout templates: builds templates (evidence: `laygo2_tech_quick_start/laygo2_tech_templates.py`)
- Tech grids → Coordinate grids: builds grids (evidence: `laygo2_tech_quick_start/laygo2_tech_grids.py`)
- Tech grids → Design database: uses design database (evidence: `laygo2_tech_quick_start/laygo2_tech_grids.py`)
- Design database → Layout objects: stores objects (evidence: `laygo2/object/database.py`)
- Design database → Layout templates: instantiates from
- Design database → Placement grids: places on
- Design database → Routing grids: routes on
- Placement grids → Coordinate grids: extends (evidence: `laygo2/object/grid/placement.py`)
- Routing grids → Coordinate grids: extends (evidence: `laygo2/object/grid/routing.py`)
- Routing grids → Layout objects: creates wires (evidence: `laygo2/object/grid/routing.py`)
- Routing meshes → Layout objects: generates instances (evidence: `laygo2/object/template/routing.py`)
- IC designer → YAML templates: imports templates
- YAML templates → YAML files: reads or writes (evidence: `laygo2/interface/yaml.py`)
- Design database → GDS export: exports layout
- Design database → SKILL export: exports layout
- Design database → BAG export: exports layout
- Design database → Magic export: exports layout
- Design database → Layout plotting: plots layout
- GDS export → CAD tools: writes layout
- SKILL export → CAD tools: targets
- BAG export → CAD tools: targets
- Magic export → CAD tools: targets
