qcc_kplugin.pcells¶
Live PCells (opt-in, Settings): the Quantcore PDK cells as a KLayout library, so KLayout’s own Instance tool and
its PCell parameter dialog place and edit them, while design.json stays the source of truth.
The plugin still does not import quantcore_circuits or KQCircuits inside KLayout (KLayout’s Python is a MinGW build
without pydantic, and the KQC Salt package it may load is another KQC version than the one qcc builds with).
Each PCell here is a light declaration: its parameters come from one qcc components --source quantcore --schemas
call, and its geometry is copied from what ``qcc`` built:
after every rebuild, each placed component’s built cell is cached under
(cell, parameters)and the static instance is swapped for a library PCell instance with the same parameters (same transform, sameidproperty), so the geometry in the view is exactly the build’s;a parameter set not built yet (a new value in the Instance tool or the PCell dialog) is drawn from the nearest cached geometry of that cell at once, and a background
qcc components CELL --oasfetches the real one (--designgives it the chip’s inherited parameters); the library is refreshed when it lands.
Edits flow back like every other edit: a library PCell instance without id (placed with the Instance tool) becomes
a design instance, a changed parameter becomes the instance’s params, both through SESSION.commit (Undo
works), and the rebuild replaces the preview with the built geometry.
Attributes¶
Classes¶
Flat copies of built component cells, by |
|
The opt-in state: schemas loading in the background, the registered library, the provider. |
|
Geometry for the declarations: the cache, plus background |
Functions¶
|
The library name of a design.json |
|
|
|
Geometry depends on the chip (inherited |
|
A PCell declaration for Quantcore |
|
Copy the (flat) cached |
|
Nothing of this cell is cached yet: a small open square until its geometry arrives. |
|
Every PCell parameter: the defaults with |
|
The PCell name of an instance (in |
|
The library cell for a design instance, or None when it cannot be a live PCell: not a Quantcore PDK cell, or |
|
After a rebuild: cache each component's built cell, then swap the static instance for a library PCell |
|
The |
|
A canonical JSON value: tuples as lists, integral floats as ints (10.0 and 10 are the same parameter). |
|
The design.json |
|
|
|
|
|
Called by the autorun macro: register the library when Settings has live PCells on. |
|
Quantcore library PCells in |
Module Contents¶
- class qcc_kplugin.pcells.GeometryCache¶
Flat copies of built component cells, by
params_key(), in a private layout.- clear() None¶
- get(key: str)¶
- load(key: str, path) bool¶
Cache the geometry
qcc components CELL --oaswrote (top cellqcc_component).
- nearest(cell: str)¶
- put(key: str, src) None¶
Cache
src(a cell of any layout, in its local frame) underkey, flattened.
- cells: dict[str, int]¶
- context = ''¶
- latest: dict[str, str]¶
- layout¶
- class qcc_kplugin.pcells.Live¶
The opt-in state: schemas loading in the background, the registered library, the provider.
- active() bool¶
- after_build(session, chip) None¶
The view shows a fresh build: its components become live PCells (geometry = the build’s).
- enabled() bool¶
- start(wait: bool = False) None¶
Load the schemas (one
qcccall, ~1 s, in the background) and register the library.
- stop() None¶
- sync(session, chip) None¶
Instance tool placements and PCell dialog edits → design.json (one commit).
- tick() None¶
- error = ''¶
- lib = None¶
- loading: tuple[subprocess.Popen, pathlib.Path] | None = None¶
- property ready: bool¶
- timer = None¶
- class qcc_kplugin.pcells.Provider(qcc: str = 'qcc', design=None, env=None, outdir=None)¶
Geometry for the declarations: the cache, plus background
qccfetches of parameter sets not built yet.- busy() bool¶
- poll() bool¶
Advance the background fetch; True when new geometry was cached (refresh the library).
- produce(cell: str, values: dict, layout, target) None¶
- request(cell: str, own: dict) None¶
- stop() None¶
- cache¶
- declarations: list = []¶
- design = None¶
- env = None¶
- failed: dict[str, str]¶
- fallback: set[str]¶
- outdir¶
- produced = 0¶
- qcc = 'qcc'¶
- queue: dict[str, tuple[str, dict]]¶
- running: tuple[str, subprocess.Popen, pathlib.Path] | None = None¶
- schemas: dict¶
- qcc_kplugin.pcells.base_cell(ref: str) str¶
The library name of a design.json
cell(Xmonorquantcore_circuits.layouts....Xmon).
- qcc_kplugin.pcells.coerce(value, row: dict)¶
valueas KLayout’s dialog hands it back (list items are strings) → the type of the schemarow.
- qcc_kplugin.pcells.context_key(design: dict, path=None) str¶
Geometry depends on the chip (inherited
a/b, PDK): a new context empties the geometry cache.
- qcc_kplugin.pcells.declaration(cell: str, info: dict, provider: Provider)¶
A PCell declaration for Quantcore
cell(schema rows ofqcc components --schemas).
- qcc_kplugin.pcells.draw(src, layout, cell) None¶
Copy the (flat) cached
srcinto a PCell’scelloflayout, layer by layer (same layer infos as the built OAS, so the view gets no new layers).
- qcc_kplugin.pcells.draw_marker(layout, cell, size: float = 100.0) None¶
Nothing of this cell is cached yet: a small open square until its geometry arrives.
- qcc_kplugin.pcells.full_params(schema: list[dict], own: dict) dict¶
Every PCell parameter: the defaults with
ownon top (whatadd_pcell_varianttakes).
- qcc_kplugin.pcells.library_cell_name(inst, layout) str | None¶
The PCell name of an instance (in
layout) of the Quantcore library (None for anything else).
- qcc_kplugin.pcells.liveable(entry: dict, schemas: dict) str | None¶
The library cell for a design instance, or None when it cannot be a live PCell: not a Quantcore PDK cell, or
paramsoutside its editable schema (shapes, layers), which the PCell could not carry.
- qcc_kplugin.pcells.liven(chip, design: dict, lib, provider: Provider) list[str]¶
After a rebuild: cache each component’s built cell, then swap the static instance for a library PCell instance with the same parameters (transform and properties such as
idstay). Returns the instance names.
- qcc_kplugin.pcells.make_library(schemas: dict, provider: Provider)¶
The
Quantcorelibrary with one PCell per schema entry (not registered yet).
- qcc_kplugin.pcells.norm(value)¶
A canonical JSON value: tuples as lists, integral floats as ints (10.0 and 10 are the same parameter).
- qcc_kplugin.pcells.own_params(schema: list[dict], values: dict) dict¶
The design.json
paramsfor PCellvalues: coerced, and only those that differ from the defaults.
- qcc_kplugin.pcells.params_key(cell: str, own: dict) str¶
- qcc_kplugin.pcells.safe_refresh(lib) None¶
lib.refresh()(re-produce every variant, so new geometry replaces a preview), with KLayout’s Instance tool switched off meanwhile: KLayout 0.30.3 crashes when a library is refreshed while that tool shows a preview of one of its PCells (tested). The tool is switched on again, so the user stays in it.
- qcc_kplugin.pcells.startup() None¶
Called by the autorun macro: register the library when Settings has live PCells on.
- qcc_kplugin.pcells.sync(design: dict, chip, schemas: dict) tuple[dict, list[str]]¶
Quantcore library PCells in
chip→design: an instance withoutid(placed with KLayout’s Instance tool) becomes a new design instance (and gets itsid); a changed parameter becomes the instance’sparams(keys outside the PCell schema are kept). Moves, rotations and deletes are synced by the session as before.
- qcc_kplugin.pcells.CFG_LIVE = 'qcc-kplugin-live-pcells'¶
- qcc_kplugin.pcells.LIB_NAME = 'Quantcore'¶
- qcc_kplugin.pcells.LIVE¶