GDSII and OASIS Layout Toolkit · layouttk

Read, write, and verify hierarchical GDSII and OASIS using a Python library, Rust crate, or headless CLI. Select layer/datatype pairs during decoding and clip windows directly from a file.

English manual · 简体中文 · layouttk Python package on PyPI · Source on GitHub

Explore SKY130, ASAP7, IHP SG13G2, Caravel and SiEPIC openEBL silicon photonics. Compare layouttk with gdspy, gdstk, and KLayout or map units, layers and cell hierarchies for existing scripts. layouttk vs gdspy, gdstk & KLayout (FAQ) · GDSII and OASIS layout gallery · gdspy, gdstk and KLayout migration guide

Run the Python examples and compare your results with KLayout screenshots. Place cell arrays, rasterize waveguides, clip windows or edit layout coordinates with NumPy and PyTorch. Illustrated Python workflows

Stable release 0.5.0 · Python wheels, CLI and source downloads · crates.io

GDSII and OASIS file processing

GDSII files commonly use .gds or .gdsii. OASIS files use .oas or .oasis. Run layouttk inventory to find the top cell, layer pairs, and database units before processing a file.

Task Entry point
Inspect a GDS or OASIS file layouttk inventory
Inspect GDSII record offsets and units layouttk gds index, layouttk gds units
Extract layers from GDSII or OASIS layouttk extract --layer …
Convert OASIS to GDSII Preflight with layouttk check --to gds --json, then use layouttk convert. Conversion and verification example
Compare stored records and placed geometry layouttk verify
Clip windows and optionally retain hierarchy layouttk clip --keep-hierarchy, Layout.clip_file(..., keep_hierarchy=True)
Build die arrays, alignment marks and wafer grids Python layouttk.shapes, layouttk.templates
Combine or subtract placed layers layouttk boolean
Find or edit cells and layers layouttk query, layouttk edit
Write PNG, SVG or offline HTML layouttk raster, layouttk view

Already have a layout? Start by extracting a layer and opening the result in KLayout. The guide shows which filename, top cell, and layer to replace. Follow the extraction steps

The offline bundle includes layer extraction, photonics clipping, and delivery verification. Run layouttk/assets/batch.jsonl, then follow layouttk/references/automation.md to check which window retains a child reference. The Python reference includes a runnable compact mask array. Download the offline examples

Standalone archives include English and Simplified Chinese guides and an Agent Skill. Run layouttk guide --lang en for the built-in guide. Add --help after a command to see its example, units and output. Agents using internal models can request one command with layouttk describe --json query bounds.

Install

python -m pip install layouttk
cargo install layouttk --locked

For offline installation, download the wheel for your platform and run python -m pip install --no-index --no-deps PATH_TO_WHEEL.whl with CPython 3.11 or newer. Core layout operations require no third-party Python packages.

Unpack the standalone CLI on Linux x86_64, Apple Silicon macOS, or Windows x64 and run it without a Python or Rust toolchain. The static Linux x86_64 baseline needs no system glibc or AVX/AVX2. It was tested on Linux 3.2.0-4. The project Homebrew tap installs the same CLI on macOS arm64 and Linux x86_64.

brew tap zwh42/layouttk https://github.com/zwh42/layouttk
brew install zwh42/layouttk/layouttk

Create both formats on a 1 nm grid

The rectangle measures 1 by 0.5 micrometres and starts at (2, 3) micrometres. Open either output in KLayout to check the dimensions.

from layouttk import Layer, Layout, Region

layout = Layout("MASK", dbu_nm=1)
metal = Layer(7, 0)
pad = layout.add_cell("PAD")
pad.add_region(Region.box((0, 0), (1000, 500)), layer=metal)
layout.add_cell("TOP").add_reference(pad, (2000, 3000))

for filename in ("pad.gds", "pad.oas"):
    layout.write(filename)
    restored = Layout.read(filename)
    expected = Region.box((2000, 3000), (3000, 3500))
    assert not (restored.cell("TOP").region(metal) ^ expected)

Extract, verify and clip

layouttk inventory pad.oas
layouttk extract pad.oas metal.oas --top TOP --layer 7/0
layouttk check metal.oas --to gds --json
layouttk convert metal.oas metal.gds
layouttk verify pad.gds metal.gds
layouttk clip pad.oas roi.oas --top TOP --layer 7/0 --window 2100,3100,2600,3400

Clipping produces flat geometry by default. Add --keep-hierarchy to preserve subcells and compact regular sub-arrays strictly inside the window. In the example above, enlarge the window to 1900,2900,3100,3600 and add the flag to retain the reference to PAD in WIN_1.

CLI reference · Python API · vs gdspy / gdstk / KLayout · Silicon photonics · AI documentation index · Full AI context (llms-full.txt)

Assemble a mask in Python

Use layouttk.shapes to construct regions such as disks and rings, and layouttk.templates to place compact die arrays, alignment marks and verniers. The worked example reads back both GDSII and OASIS and checks cell dependencies, bounds and area. Hierarchical mask workflow

Check a delivery with a JSONL batch

Use the pad.oas file from the quick start. Save these three lines as job.jsonl and run the batch in the same directory.

{"id":"scan","args":["inventory","pad.oas"]}
{"id":"extract","args":["extract","pad.oas","batch-metal.oas","--top","TOP","--layer","7/0"]}
{"id":"verify","args":["verify","pad.oas","batch-metal.oas"]}
layouttk batch job.jsonl > results.jsonl

Expect ok, ok, and equal in results.jsonl, with a request ID and source line on each row. A verification difference produces different and a batch exit code of 1. Use --keep-going to continue with later requests. For a single command, add --format json to get a versioned report. CLI batch guide

In Python, Layer(7, 0) + Layer(8, 0) creates a LayerSet for Layout.read(..., layers=...). Use cell.region(layer) to get placed filled geometry and + to take the geometric union of regions. Python API

Generate OASIS and run agents on public layouts

Build a four-instance OASIS array from an inverter in the ASU/Arm ASAP7 predictive 7 nm library. On a SiEPIC silicon-photonics submission, use Pi to render a 1210 × 820 PNG or OpenCode to write one bounding rectangle per placed shape, from 108 shapes on layer 1/0 to the new layer 900/0. The examples include source files, commands, and expected results.

English examples and KLayout checks · Public test fixtures and licenses · KLayout Python and Ruby API mapping

Write OASIS from a NumPy array

Convert the Mona Lisa JPEG to grayscale with Pillow and use NumPy to select pixels at 128 or higher. The script writes them to mona-lisa.oas, verifies the OASIS file pixel by pixel, and exports a binary PNG. The screenshot shows mona-lisa.oas open in KLayout. The offline download includes the source image, script and outputs. Install layouttk[image] before running it offline.

Source image OASIS open in KLayout
Mona Lisa by Leonardo da Vinci KLayout with mona-lisa.oas open, displaying layer 67/20 in cell TOP

See the Python example on GitHub · Download the OASIS file · Download the offline examples · Public-domain image source

layouttk 0.5.0 uses the MIT License.

搜索文章

输入关键词,搜索标题、分类、标签和正文。

Esc 关闭 ⌘ / Ctrl K 搜索