semiconductor-photomask-design-skill
Use Python and gdstk to parametrically generate manufacturable GDSII photomask layouts and perform post-export verification. It manages dimensions, layer numbers, labels, alignment marks, arrays, and keep-out zones as manufacturing data, making it suitable for semiconductor and micro/nanofabrication teams to rapidly iterate mask designs, run parameter sweeps, and perform pre-tapeout checks, reducing layout-reading and geometry errors.
git clone https://github.com/Elder-Driver/semiconductor-photomask-design-skill.gitBefore / After Comparison
1 组Manually write gdstk scripts; dimensions and layer numbers are scattered; labels are replaced by comments; alignment marks and arrays rely on visual inspection; GDS is not read back after export, making it easy to miss keep-out conflicts and unit precision errors.
Use parameterized source files and a read-back verification workflow; layer numbers, labels, alignment marks, arrays, and keep-out regions are automatically generated and checked; devices are omitted only on conflict; GDS boundaries, cells, and repeat counts are traceable.
name: designing-python-photomasks description: Use when creating, modifying, or checking Python-generated GDSII photomasks with gdstk, including geometric features, physical labels, alignment marks, parameter sweeps, arrays, keepouts, and sample-bound validation.
Designing Python Photomasks
Overview
Create a parameterized Python source of truth, export GDSII, and verify the serialized file rather than trusting an in-memory preview. Treat all dimensions, layer assignments, label geometry, alignment features, and placement rules as fabrication data.
Workflow
- Inspect existing Python and reference GDS files when present. Read actual layers, polygons, references, and bounds; do not infer geometry from display color or screenshots alone.
- Establish a compact design contract: user unit and precision, sample envelope, layer/datatype map, polarity, diameter versus radius, per-side clearances, label convention, alignment-mark geometry, and array rules. Ask only about missing choices that materially change fabrication; otherwise expose assumptions as named parameters.
- Build reusable cells for devices, labels, and marks. Place them with references in a top cell. Keep fabrication layers explicit on every polygon.
- Use parameter lists as the source of design variants. Derive human-readable labels from those parameters and keep a Markdown table of design IDs, dimensions, repeat counts, and later performance.
- Place alignment marks at explicit coordinates. Compute conflicts from placed device bounding boxes and keepout boxes, then omit only conflicting references. Prefer integer-micrometre centers when instrument coordinates require them.
- Write GDS, read it back with
gdstk.read_gds, and verify units, precision, layers, cell/reference counts, critical bounds, labels, mark origins, per-design repeats, and the full sample envelope. Also inspect the result in KLayout before fabrication.
Geometry Rules That Prevent Common Errors
- “Clearance on every side” changes a diameter by twice the clearance.
- Use
gdstk.ellipse(..., inner_radius=...)for a true annulus. Use Boolean subtraction only when the inner and outer shapes are not concentric circles. gdstk.textreturns physical polygons; it is not a viewer annotation. Put labels on the process layer that should print.- GDS stores curves as polygons. Visible segment boundaries or fracture lines in a viewer are not automatically physical gaps; verify polygon continuity and Boolean union when continuity matters.
- For a lead that must touch a ring, overlap the intended region explicitly. A merely coincident-looking preview is not sufficient.
- Reuse cells with references; do not flatten the fabrication GDS merely to make an SVG viewer happy. Flatten only a separate preview when necessary.
References and Starter
- Read references/gdstk-geometry.md when drawing primitives, labels, connected shapes, rings, or alignment marks.
- Read references/arrays-alignment-validation.md when sweeping dimensions, filling a sample, placing marks, or validating an exported GDS.
- For a new mask, copy and adapt assets/gdstk_photomask_starter.py. It demonstrates two-layer devices, physical labels, a split-layer alignment mark, keepout-based omission, export, and readback checks.
Deliverables
Return the parameterized Python source, generated GDS, any useful layer/overlay preview, a design/performance table for parameter sweeps, and verification evidence. State what was checked automatically and what still requires KLayout or fabrication review.
--- README.md ---
Semiconductor Photomask Design Skill
A reusable Codex skill for designing semiconductor and microfabrication photomasks with Python and gdstk. It helps turn a geometry and process-layer specification into parameterized, inspectable GDSII layout rather than a one-off drawing.
Use it for devices with circles, annuli, rectangles, leads, physical text labels, alignment marks, parameter sweeps, repeated arrays, keepouts, and sample-bound checks.
What it covers
- Explicit GDSII units, layers, datatypes, and cell hierarchy
- Disks, rings, Boolean geometry, connected leads, and split-layer alignment marks
- Physical GDS polygon labels such as
30-1 - Parameterized design variants and repeat-count tracking
- Alignment-mark placement with integer coordinates and minimal device removal
- GDS export followed by readback validation of geometry, layers, labels, marks, references, and sample bounds
The included starter script produces a two-layer example GDS and validates it after serialization:
python3 -m pip install -r requirements.txt
python3 assets/gdstk_photomask_starter.py --output output/starter_mask.gds
Use as a Codex skill
Clone this repository into either a project-local .agents/skills/ directory or your Codex skills directory, then invoke it by name:
Use $designing-python-photomasks to create a parameterized GDS mask for a two-layer semiconductor device array.
The skill entry point is SKILL.md. It routes to focused references for primitives and labels, or arrays, alignment marks, and GDS validation.
Fabrication boundary
This skill creates and validates layout data. It does not determine resist polarity, mask-writer fracture settings, foundry minimum feature rules, process overlay accuracy, or electrical performance. Review the exported GDS in KLayout and run the applicable foundry/process DRC before fabrication.
License
MIT. See LICENSE.
User Reviews (0)
Write a Review
No reviews yet
Statistics
User Rating
Rate this Skill