quantcore-circuits 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- quantcore_circuits/__init__.py +57 -0
- quantcore_circuits/analysis/__init__.py +12 -0
- quantcore_circuits/analysis/_metal.py +70 -0
- quantcore_circuits/analysis/amplifiers.py +263 -0
- quantcore_circuits/analysis/circuits.py +117 -0
- quantcore_circuits/analysis/epr.py +231 -0
- quantcore_circuits/analysis/epr_lumped.py +372 -0
- quantcore_circuits/analysis/extract.py +119 -0
- quantcore_circuits/analysis/lom.py +80 -0
- quantcore_circuits/analysis/results.py +549 -0
- quantcore_circuits/analysis/store.py +81 -0
- quantcore_circuits/analysis/synthesis.py +118 -0
- quantcore_circuits/analysis/transmon.py +126 -0
- quantcore_circuits/assembly/__init__.py +17 -0
- quantcore_circuits/assembly/builder.py +127 -0
- quantcore_circuits/assembly/drc.py +683 -0
- quantcore_circuits/assembly/last_good.py +137 -0
- quantcore_circuits/assembly/netlist.py +174 -0
- quantcore_circuits/assembly/plan.py +605 -0
- quantcore_circuits/assembly/sidecar.py +270 -0
- quantcore_circuits/autotrack.py +605 -0
- quantcore_circuits/cards.py +878 -0
- quantcore_circuits/circuit/__init__.py +14 -0
- quantcore_circuits/circuit/adapters.py +305 -0
- quantcore_circuits/circuit/bridges.py +353 -0
- quantcore_circuits/circuit/consensus.py +158 -0
- quantcore_circuits/circuit/derive.py +28 -0
- quantcore_circuits/circuit/draw.py +198 -0
- quantcore_circuits/circuit/fill.py +828 -0
- quantcore_circuits/circuit/hamiltonian.py +193 -0
- quantcore_circuits/circuit/kinetic.py +102 -0
- quantcore_circuits/circuit/schema.py +139 -0
- quantcore_circuits/cli.py +1085 -0
- quantcore_circuits/codesign.py +1038 -0
- quantcore_circuits/data/selftest_q1_r1.json +44 -0
- quantcore_circuits/design/__init__.py +44 -0
- quantcore_circuits/design/io.py +98 -0
- quantcore_circuits/design/pyscript.py +395 -0
- quantcore_circuits/design/schema.py +398 -0
- quantcore_circuits/designer.py +625 -0
- quantcore_circuits/guiflow.py +991 -0
- quantcore_circuits/kqc_files.py +208 -0
- quantcore_circuits/layouts/__init__.py +118 -0
- quantcore_circuits/layouts/catalog.py +520 -0
- quantcore_circuits/layouts/chips/__init__.py +0 -0
- quantcore_circuits/layouts/chips/design_chip.py +325 -0
- quantcore_circuits/layouts/chips/frame.py +235 -0
- quantcore_circuits/layouts/junctions/__init__.py +0 -0
- quantcore_circuits/layouts/junctions/jj_fingers.py +99 -0
- quantcore_circuits/layouts/junctions/legacy_junctions.py +237 -0
- quantcore_circuits/layouts/junctions/sim_gap.py +48 -0
- quantcore_circuits/layouts/junctions/trilayer.py +541 -0
- quantcore_circuits/layouts/metal/__init__.py +105 -0
- quantcore_circuits/layouts/metal/component.py +332 -0
- quantcore_circuits/layouts/metal/geometry.py +462 -0
- quantcore_circuits/layouts/others/__init__.py +0 -0
- quantcore_circuits/layouts/others/amplifiers.py +1139 -0
- quantcore_circuits/layouts/others/bond_pad.py +119 -0
- quantcore_circuits/layouts/others/connector_pads.py +190 -0
- quantcore_circuits/layouts/others/couplers.py +21 -0
- quantcore_circuits/layouts/others/cpw_segment.py +131 -0
- quantcore_circuits/layouts/others/cpwe.py +661 -0
- quantcore_circuits/layouts/others/keepout.py +66 -0
- quantcore_circuits/layouts/others/legacy_resonators.py +645 -0
- quantcore_circuits/layouts/others/markers.py +201 -0
- quantcore_circuits/layouts/others/qpdk_cells.py +263 -0
- quantcore_circuits/layouts/others/shapes.py +114 -0
- quantcore_circuits/layouts/others/spirals.py +140 -0
- quantcore_circuits/layouts/others/sqdmetal_cells.py +90 -0
- quantcore_circuits/layouts/others/test_pads.py +461 -0
- quantcore_circuits/layouts/ports.py +119 -0
- quantcore_circuits/layouts/qubits/__init__.py +0 -0
- quantcore_circuits/layouts/qubits/legacy_transmon.py +124 -0
- quantcore_circuits/layouts/qubits/qpdk_cells.py +374 -0
- quantcore_circuits/layouts/qubits/sqdmetal_cells.py +376 -0
- quantcore_circuits/layouts/qubits/trilayer_concentric.py +65 -0
- quantcore_circuits/layouts/qubits/xmon.py +375 -0
- quantcore_circuits/layouts/registry.py +418 -0
- quantcore_circuits/layouts/wafers/__init__.py +0 -0
- quantcore_circuits/layouts/wafers/fab_export.py +454 -0
- quantcore_circuits/layouts/wafers/legacy_wafer.py +111 -0
- quantcore_circuits/layouts/wafers/wafer.py +469 -0
- quantcore_circuits/live/__init__.py +6 -0
- quantcore_circuits/live/klayout.py +225 -0
- quantcore_circuits/live/klive.py +61 -0
- quantcore_circuits/live/snapshot.py +185 -0
- quantcore_circuits/live/watch.py +93 -0
- quantcore_circuits/lom/__init__.py +15 -0
- quantcore_circuits/lom/builder.py +932 -0
- quantcore_circuits/lom/calibration.py +82 -0
- quantcore_circuits/lom/estimates.py +235 -0
- quantcore_circuits/lom/fragment.py +421 -0
- quantcore_circuits/lom/kqc_models.py +734 -0
- quantcore_circuits/lom/metal_models.py +917 -0
- quantcore_circuits/lom/quantcore_models.py +784 -0
- quantcore_circuits/lom/simulate.py +636 -0
- quantcore_circuits/lom/synthesize.py +189 -0
- quantcore_circuits/loop.py +610 -0
- quantcore_circuits/optimise.py +423 -0
- quantcore_circuits/pdk/__init__.py +451 -0
- quantcore_circuits/plots.py +876 -0
- quantcore_circuits/plugins.py +69 -0
- quantcore_circuits/review/__init__.py +57 -0
- quantcore_circuits/review/server.py +251 -0
- quantcore_circuits/review/static/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- quantcore_circuits/review/static/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- quantcore_circuits/review/static/assets/index-CDHdrFyA.css +1 -0
- quantcore_circuits/review/static/assets/index-CSx05Og4.js +409 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-400-normal-HOLc17fK.woff +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-400-normal-obahsSVq.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-500-normal-BasfLYem.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-500-normal-CxZf_p3X.woff +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-600-normal-4D_pXhcN.woff +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-600-normal-CWCymEST.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-700-normal-CjBOestx.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-700-normal-DrXBdSj3.woff +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-ext-400-normal-BQZuk6qB.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-ext-400-normal-DQukG94-.woff +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-ext-500-normal-B0yAr1jD.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-ext-500-normal-BmqWE9Dz.woff +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-ext-600-normal-Bcila6Z-.woff +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-ext-600-normal-Dfes3d0z.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-ext-700-normal-BjwYoWNd.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-cyrillic-ext-700-normal-LO58E6JB.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-400-normal-B4URO6DV.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-greek-400-normal-q2sYcFCs.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-500-normal-BIZE56-Y.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-greek-500-normal-Xzm54t5V.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-600-normal-BZpKdvQh.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-600-normal-plRanbMR.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-greek-700-normal-BUv2fZ6O.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-700-normal-C3JjAnD8.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-greek-ext-400-normal-DGGRlc-M.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-greek-ext-400-normal-KugGGMne.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-ext-500-normal-2j5mBUwD.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-ext-500-normal-C4iEst2y.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-greek-ext-600-normal-B8X0CLgF.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-ext-600-normal-DRtmH8MT.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-greek-ext-700-normal-BoQ6DsYi.woff +0 -0
- quantcore_circuits/review/static/assets/inter-greek-ext-700-normal-qfdV9bQt.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-400-normal-C38fXH4l.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-400-normal-CyCys3Eg.woff +0 -0
- quantcore_circuits/review/static/assets/inter-latin-500-normal-BL9OpVg8.woff +0 -0
- quantcore_circuits/review/static/assets/inter-latin-500-normal-Cerq10X2.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-600-normal-CiBQ2DWP.woff +0 -0
- quantcore_circuits/review/static/assets/inter-latin-600-normal-LgqL8muc.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-700-normal-BLAVimhd.woff +0 -0
- quantcore_circuits/review/static/assets/inter-latin-700-normal-Yt3aPRUw.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-ext-400-normal-77YHD8bZ.woff +0 -0
- quantcore_circuits/review/static/assets/inter-latin-ext-400-normal-C1nco2VV.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-ext-500-normal-BxGbmqWO.woff +0 -0
- quantcore_circuits/review/static/assets/inter-latin-ext-500-normal-CV4jyFjo.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-ext-600-normal-CIVaiw4L.woff +0 -0
- quantcore_circuits/review/static/assets/inter-latin-ext-600-normal-D2bJ5OIk.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-ext-700-normal-Ca8adRJv.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-latin-ext-700-normal-TidjK2hL.woff +0 -0
- quantcore_circuits/review/static/assets/inter-vietnamese-400-normal-Bbgyi5SW.woff +0 -0
- quantcore_circuits/review/static/assets/inter-vietnamese-400-normal-DMkecbls.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-vietnamese-500-normal-DOriooB6.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-vietnamese-500-normal-mJboJaSs.woff +0 -0
- quantcore_circuits/review/static/assets/inter-vietnamese-600-normal-BuLX-rYi.woff +0 -0
- quantcore_circuits/review/static/assets/inter-vietnamese-600-normal-Cc8MFFhd.woff2 +0 -0
- quantcore_circuits/review/static/assets/inter-vietnamese-700-normal-BZaoP0fm.woff +0 -0
- quantcore_circuits/review/static/assets/inter-vietnamese-700-normal-DlLaEgI2.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-cyrillic-400-normal-ugxPyKxw.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-cyrillic-500-normal-DJqRU3vO.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-cyrillic-500-normal-DmUKJPL_.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-greek-400-normal-B9oWc5Lo.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-greek-500-normal-D7SFKleX.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-greek-500-normal-JpySY46c.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-latin-500-normal-CJOVTJB7.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-latin-ext-400-normal-fXTG6kC5.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-latin-ext-500-normal-Cut-4mMH.woff2 +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-latin-ext-500-normal-ckzbgY84.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-vietnamese-400-normal-CqNFfHCs.woff +0 -0
- quantcore_circuits/review/static/assets/jetbrains-mono-vietnamese-500-normal-DNRqzVM1.woff +0 -0
- quantcore_circuits/review/static/index.html +14 -0
- quantcore_circuits/review/static/logo-quantcore-black.png +0 -0
- quantcore_circuits/review/static/logo-quantcore-white.png +0 -0
- quantcore_circuits/review/static/sample/chip.png +0 -0
- quantcore_circuits/review/static/sample/chip_rev1.png +0 -0
- quantcore_circuits/review/static/sample/q1.png +0 -0
- quantcore_circuits/review/static/sample/q2.png +0 -0
- quantcore_circuits/review/static/sample-state.json +3747 -0
- quantcore_circuits/route/__init__.py +5 -0
- quantcore_circuits/route/router.py +694 -0
- quantcore_circuits/route/waveguide.py +187 -0
- quantcore_circuits/selftest.py +224 -0
- quantcore_circuits/sim_tools/__init__.py +6 -0
- quantcore_circuits/sim_tools/aedt_attach.py +66 -0
- quantcore_circuits/sim_tools/aedt_progress.py +224 -0
- quantcore_circuits/sim_tools/aedt_project.py +302 -0
- quantcore_circuits/sim_tools/aedt_scripts.py +397 -0
- quantcore_circuits/sim_tools/aedt_session.py +275 -0
- quantcore_circuits/sim_tools/ansys.py +90 -0
- quantcore_circuits/sim_tools/builder.py +1690 -0
- quantcore_circuits/sim_tools/export.py +470 -0
- quantcore_circuits/sim_tools/geometry_check.py +342 -0
- quantcore_circuits/sim_tools/hfss.py +583 -0
- quantcore_circuits/sim_tools/palace.py +197 -0
- quantcore_circuits/sim_tools/runner.py +179 -0
- quantcore_circuits/sim_tools/subset.py +364 -0
- quantcore_circuits/track.py +671 -0
- quantcore_circuits-0.0.1.dist-info/METADATA +204 -0
- quantcore_circuits-0.0.1.dist-info/RECORD +272 -0
- quantcore_circuits-0.0.1.dist-info/WHEEL +5 -0
- quantcore_circuits-0.0.1.dist-info/entry_points.txt +2 -0
- quantcore_circuits-0.0.1.dist-info/licenses/LICENSE +674 -0
- quantcore_circuits-0.0.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,605 @@
|
|
|
1
|
+
"""Design → build plan: resolve classes, parameters, snaps and routes outside of any PCell.
|
|
2
|
+
|
|
3
|
+
The plan is plain JSON-able data that :class:`~quantcore_circuits.layouts.chips.design_chip.DesignChip` replays.
|
|
4
|
+
Every element cell is first
|
|
5
|
+
built in a scratch layout with *exactly* the parameters the chip will use, so port positions measured here are the
|
|
6
|
+
ports of the final layout.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import json
|
|
12
|
+
import math
|
|
13
|
+
from dataclasses import asdict, dataclass, field
|
|
14
|
+
|
|
15
|
+
from kqcircuits.elements.element import Element
|
|
16
|
+
from kqcircuits.elements.waveguide_composite import WaveguideComposite
|
|
17
|
+
from kqcircuits.pya_resolver import pya
|
|
18
|
+
|
|
19
|
+
from quantcore_circuits.design.schema import CHIP, Design, FreeEnd, HangerEnd, split_port_ref
|
|
20
|
+
from quantcore_circuits.layouts.ports import Port, check_cell, direction_vector
|
|
21
|
+
from quantcore_circuits.layouts.registry import cell_ref, create_cell, default_params, element_cell_ports, resolve_cell
|
|
22
|
+
from quantcore_circuits.route.router import RouteEnd, RoutePlan, RoutingError, fix_length, plan_route
|
|
23
|
+
from quantcore_circuits.route.waveguide import waveguide_class
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class PlacementError(ValueError):
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# Element parameters a KQC Chip passes down to children through ``add_element`` (parameter inheritance).
|
|
31
|
+
_INHERITED = ("a", "b", "n", "r", "margin", "face_ids", "protect_opposite_face", "opposing_face_id_groups")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@dataclass
|
|
35
|
+
class PlacedInstance:
|
|
36
|
+
name: str
|
|
37
|
+
cell: str # canonical class path or "static:<path>"
|
|
38
|
+
params: dict
|
|
39
|
+
trans: pya.DCplxTrans
|
|
40
|
+
local_ports: dict[str, Port]
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def ports(self) -> dict[str, Port]:
|
|
44
|
+
return {n: p.transformed(self.trans) for n, p in self.local_ports.items()}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@dataclass
|
|
48
|
+
class FailedRoute:
|
|
49
|
+
"""A route that could not be built (``plan_design(keep_going=True)``): why, the path the design asks for, and the
|
|
50
|
+
route's last successful geometry (``last_good``: ``polyline``, ``length``, ... from an earlier build) if any."""
|
|
51
|
+
|
|
52
|
+
name: str
|
|
53
|
+
error: str
|
|
54
|
+
attempt: list = field(default_factory=list) # [start, user nodes..., end] as the design gives them (None: unknown end)
|
|
55
|
+
last_good: dict | None = None
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@dataclass
|
|
59
|
+
class BuildPlan:
|
|
60
|
+
design: Design
|
|
61
|
+
chip_params: dict
|
|
62
|
+
launchers: str | dict | None
|
|
63
|
+
chip_ports: dict[str, Port]
|
|
64
|
+
instances: dict[str, PlacedInstance] = field(default_factory=dict)
|
|
65
|
+
routes: dict[str, RoutePlan] = field(default_factory=dict)
|
|
66
|
+
frame: dict | None = None # PDK die frame (asdict of DieFrame) when drawn
|
|
67
|
+
device_id: str = ""
|
|
68
|
+
pad_edge: float | None = None # PDK pad rule: launcher indent from the die edge (DieFrame.pad_edge)
|
|
69
|
+
cheese: dict | None = None # PDK band cheese drawn in the build: {"pdk": name, "rule": asdict(CheeseRule)}
|
|
70
|
+
metal: list = field(default_factory=list) # extra ground (base_metal_addition polygons, chip µm): hanger gaps
|
|
71
|
+
failed: dict[str, FailedRoute] = field(default_factory=dict) # routes left out (keep_going builds only)
|
|
72
|
+
keep_going: bool = False
|
|
73
|
+
warnings: list = field(default_factory=list) # last_good.resolve: failed routes replaced by their last good ones
|
|
74
|
+
|
|
75
|
+
def port(self, ref: str) -> Port:
|
|
76
|
+
inst, port = split_port_ref(ref)
|
|
77
|
+
ports = self.chip_ports if inst == CHIP else self.instances[inst].ports
|
|
78
|
+
if port not in ports:
|
|
79
|
+
raise PlacementError(f"{ref!r}: no such port; available: {sorted(ports)}")
|
|
80
|
+
return ports[port]
|
|
81
|
+
|
|
82
|
+
def all_ports(self) -> dict[str, Port]:
|
|
83
|
+
out = {f"{CHIP}.{n}": p for n, p in self.chip_ports.items()}
|
|
84
|
+
for name, inst in self.instances.items():
|
|
85
|
+
out.update({f"{name}.{n}": p for n, p in inst.ports.items()})
|
|
86
|
+
return out
|
|
87
|
+
|
|
88
|
+
def to_json(self) -> str:
|
|
89
|
+
"""Serialise what ``DesignChip.build`` needs."""
|
|
90
|
+
data = {
|
|
91
|
+
"launchers": self.launchers,
|
|
92
|
+
"instances": {
|
|
93
|
+
n: {
|
|
94
|
+
"cell": i.cell,
|
|
95
|
+
"params": i.params,
|
|
96
|
+
"trans": i.trans.to_s(),
|
|
97
|
+
**(
|
|
98
|
+
{"static_ports": [p.as_dict() for p in i.local_ports.values()]}
|
|
99
|
+
if i.cell.startswith("static:")
|
|
100
|
+
else {}
|
|
101
|
+
),
|
|
102
|
+
}
|
|
103
|
+
for n, i in self.instances.items()
|
|
104
|
+
},
|
|
105
|
+
"routes": {
|
|
106
|
+
n: {"nodes": r.node_strings(), "params": r.params, **({"joins": r.joins} if r.joins else {})}
|
|
107
|
+
for n, r in self.routes.items()
|
|
108
|
+
},
|
|
109
|
+
}
|
|
110
|
+
if self.frame:
|
|
111
|
+
data["frame"], data["device_id"] = self.frame, self.device_id
|
|
112
|
+
if self.pad_edge is not None:
|
|
113
|
+
data["pad_edge"] = self.pad_edge
|
|
114
|
+
if self.cheese:
|
|
115
|
+
data["cheese"] = self.cheese
|
|
116
|
+
if self.metal:
|
|
117
|
+
data["metal"] = self.metal
|
|
118
|
+
return json.dumps(data, sort_keys=True, default=_json_default)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def _json_default(o):
|
|
122
|
+
if isinstance(o, (pya.DPoint, pya.DVector)):
|
|
123
|
+
return [o.x, o.y]
|
|
124
|
+
raise TypeError(f"not JSON serialisable: {type(o)}")
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def chip_parameters(design: Design) -> dict:
|
|
128
|
+
"""Parameters of the generated ``DesignChip`` (KQC Chip params + qcc defaults)."""
|
|
129
|
+
x0, y0, x1, y1 = design.chip.box
|
|
130
|
+
params = {"box": pya.DBox(x0, y0, x1, y1), "name_chip": design.name[:16]}
|
|
131
|
+
params.update(design.chip.params)
|
|
132
|
+
if isinstance(params.get("cheese"), dict): # a design-chosen cheese rule: the plan carries it (cheese_spec)
|
|
133
|
+
params["cheese"] = "pdk"
|
|
134
|
+
if die_frame(design) is not None:
|
|
135
|
+
params.setdefault("frames_enabled", []) # the PDK die frame replaces KQC's chip frame
|
|
136
|
+
return params
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def die_frame(design: Design):
|
|
140
|
+
"""The PDK :class:`~quantcore_circuits.pdk.DieFrame` drawn on this design's chip, or None."""
|
|
141
|
+
from quantcore_circuits.pdk import get_pdk # pylint: disable=import-outside-toplevel
|
|
142
|
+
|
|
143
|
+
if not design.chip.params.get("die_frame", True):
|
|
144
|
+
return None
|
|
145
|
+
return get_pdk(design.pdk).frame
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def pad_edge(design: Design) -> float:
|
|
149
|
+
"""PDK pad rule: distance of a pad's / launcher's outer etch edge from the die edge (µm). It applies with or
|
|
150
|
+
without the drawn frame, so a simulation build (frame off) keeps the pads where the real chip has them."""
|
|
151
|
+
from quantcore_circuits.pdk import get_pdk # pylint: disable=import-outside-toplevel
|
|
152
|
+
|
|
153
|
+
return get_pdk(design.pdk).frame.pad_edge
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def has_own_cheese(design: Design) -> bool:
|
|
157
|
+
"""The design carries its own ground cheese: KQC's whole-area grid on the chip or on a chip-sized cell."""
|
|
158
|
+
if design.chip.params.get("with_grid"):
|
|
159
|
+
return True
|
|
160
|
+
return any(bool((inst.params or {}).get("with_grid")) for inst in design.instances.values())
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def pdk_cheese(design: Design) -> bool:
|
|
164
|
+
"""Whether the build draws the PDK band cheese (design rule, 2026-11-03: the original design wins).
|
|
165
|
+
|
|
166
|
+
Chip parameter ``cheese``: ``"auto"`` (default) — the band unless the design has its own cheese
|
|
167
|
+
(:func:`has_own_cheese`); ``"pdk"`` — the band always; ``"original"`` (or ``False``) — never (the design's own
|
|
168
|
+
cheese, e.g. inside a static cell, or none); a dict — the original design's cheese *rule*, drawn instead of the
|
|
169
|
+
PDK band (:func:`cheese_spec`)."""
|
|
170
|
+
mode = design.chip.params.get("cheese", "auto")
|
|
171
|
+
if isinstance(mode, dict):
|
|
172
|
+
return True
|
|
173
|
+
if mode in (False, "original", "none", "off"):
|
|
174
|
+
return False
|
|
175
|
+
if mode in (True, "pdk", "on"):
|
|
176
|
+
return True
|
|
177
|
+
return not has_own_cheese(design)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def cheese_spec(design: Design) -> dict | None:
|
|
181
|
+
"""What the build draws as cheese: ``{"pdk", "rule": asdict(CheeseRule), "edge"}`` or None (:func:`pdk_cheese`).
|
|
182
|
+
|
|
183
|
+
``chip.params.cheese`` as a dict reproduces an original design's own cheese rule (the original wins): any
|
|
184
|
+
:class:`~quantcore_circuits.pdk.CheeseRule` field (``size``, ``gap``, ``rows``, ``clearance``) over the PDK's,
|
|
185
|
+
plus ``edge`` (µm): no holes within that distance of the die edge. A whole-area cheese like Quantum Metal's GDS
|
|
186
|
+
renderer (25 µm squares on a 100 µm pitch, 25 µm from all geometry, 200 µm from the edge) is
|
|
187
|
+
``{"size": 25, "gap": 75, "rows": 1000, "clearance": 25, "edge": 200}``."""
|
|
188
|
+
from quantcore_circuits.pdk import CheeseRule, get_pdk # pylint: disable=import-outside-toplevel
|
|
189
|
+
|
|
190
|
+
if not pdk_cheese(design):
|
|
191
|
+
return None
|
|
192
|
+
rule = asdict(get_pdk(design.pdk).cheese)
|
|
193
|
+
mode = design.chip.params.get("cheese")
|
|
194
|
+
edge = None
|
|
195
|
+
if isinstance(mode, dict):
|
|
196
|
+
unknown = set(mode) - set(rule) - {"edge"}
|
|
197
|
+
if unknown:
|
|
198
|
+
raise ValueError(f"chip cheese rule: unknown field(s) {sorted(unknown)}; use {sorted(rule)} + 'edge'")
|
|
199
|
+
rule.update({k: v for k, v in mode.items() if k != "edge"})
|
|
200
|
+
edge = mode.get("edge")
|
|
201
|
+
CheeseRule(**rule) # validates the field types
|
|
202
|
+
return {"pdk": design.pdk, "rule": rule, "edge": edge}
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
# PDK default junction (decision #36: every junction of the Quantcore PDK is the trilayer Quantcore junction): KQC /
|
|
206
|
+
# Metal junction defaults → the Quantcore cell; "Sim", "No Squid" and explicit choices are kept
|
|
207
|
+
_PDK_JUNCTION = {
|
|
208
|
+
"Manhattan": "Quantcore Squid",
|
|
209
|
+
"Manhattan Single Junction": "Quantcore Junction",
|
|
210
|
+
"QCD1": "Quantcore Squid",
|
|
211
|
+
"Metal": "Quantcore Junction",
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def pdk_junction_type(cls, own: dict) -> str | None:
|
|
216
|
+
"""The PDK trilayer junction a cell draws when the instance's ``own`` parameters leave ``junction_type`` unset and
|
|
217
|
+
the cell's default is a KQC / Metal junction (``"Manhattan"`` → ``"Quantcore Squid"``, ...), else None (the
|
|
218
|
+
default is kept, the instance sets it, the cell is a junction cell or has no ``junction_type``). The build
|
|
219
|
+
(:func:`element_params`) and the LOM / simulation junction (``lom.fragment.cell_params``) both use it."""
|
|
220
|
+
schema = cls.get_schema()
|
|
221
|
+
if "junction_type" not in schema or "junction_type" in own or getattr(cls, "qcc_category", "") == "junction":
|
|
222
|
+
return None
|
|
223
|
+
return _PDK_JUNCTION.get(schema["junction_type"].default)
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def default_junction_type(cell: str) -> str | None:
|
|
227
|
+
"""The junction a cell draws when a design leaves ``junction_type`` unset (the PDK trilayer for KQC / Metal
|
|
228
|
+
qubits), or None for cells without one."""
|
|
229
|
+
if cell.startswith("static:"):
|
|
230
|
+
return None
|
|
231
|
+
try:
|
|
232
|
+
cls = resolve_cell(cell)
|
|
233
|
+
except Exception: # noqa: BLE001
|
|
234
|
+
return None
|
|
235
|
+
schema = cls.get_schema()
|
|
236
|
+
if "junction_type" not in schema:
|
|
237
|
+
return None
|
|
238
|
+
default = schema["junction_type"].default
|
|
239
|
+
if getattr(cls, "qcc_category", "") == "junction":
|
|
240
|
+
return default
|
|
241
|
+
return _PDK_JUNCTION.get(default, default)
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def inherited_params(chip_params: dict) -> dict:
|
|
245
|
+
from quantcore_circuits.layouts.chips.design_chip import DesignChip # pylint: disable=import-outside-toplevel
|
|
246
|
+
|
|
247
|
+
base = default_params(DesignChip)
|
|
248
|
+
return {k: chip_params.get(k, base[k]) for k in _INHERITED if k in base}
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
def pcell_params(cls: type[Element], own: dict) -> dict:
|
|
252
|
+
"""PCell parameters for a design's instance parameters.
|
|
253
|
+
|
|
254
|
+
A wrapper cell (e.g. ``metal:<Class>``) whose user-facing parameters are not its PCell schema converts them with
|
|
255
|
+
a classmethod ``qcc_params(params) -> dict``; for other cells they are the same.
|
|
256
|
+
"""
|
|
257
|
+
hook = getattr(cls, "qcc_params", None)
|
|
258
|
+
return hook(dict(own)) if hook is not None else dict(own)
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def element_params(cls: type[Element], inherited: dict, own: dict) -> dict:
|
|
262
|
+
"""Full parameter set for a child element, matching KQC ``add_element`` inheritance."""
|
|
263
|
+
schema = cls.get_schema()
|
|
264
|
+
params = {k: v for k, v in inherited.items() if k in schema}
|
|
265
|
+
if "name_brand" in schema: # whole KQC chips used as cells draw a frame with a brand: Quantcore's (design rule)
|
|
266
|
+
params["name_brand"] = "QCT"
|
|
267
|
+
pdk_jt = pdk_junction_type(cls, own)
|
|
268
|
+
if pdk_jt is not None: # unset → the PDK trilayer junction
|
|
269
|
+
params["junction_type"] = pdk_jt
|
|
270
|
+
params.update(pcell_params(cls, own))
|
|
271
|
+
return params
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
def snap_trans(own: Port, target: Port, mirror: bool = False, gap: float = 0.0) -> pya.DCplxTrans:
|
|
275
|
+
"""Transform that puts ``own`` (local) onto ``target`` (absolute), facing each other."""
|
|
276
|
+
if own.dir is None or target.dir is None:
|
|
277
|
+
raise PlacementError(f"cannot snap {own.name!r} to {target.name!r}: both ports need a direction (corner)")
|
|
278
|
+
m = pya.DCplxTrans(1, 0, mirror, 0, 0)
|
|
279
|
+
d_own = m * own.dir
|
|
280
|
+
want = -target.dir
|
|
281
|
+
angle = math.degrees(math.atan2(want.y, want.x) - math.atan2(d_own.y, d_own.x)) % 360.0
|
|
282
|
+
if abs(angle - round(angle)) < 1e-9:
|
|
283
|
+
angle = float(round(angle)) % 360.0
|
|
284
|
+
rot = pya.DCplxTrans(1, angle, mirror, 0, 0)
|
|
285
|
+
disp = (target.pos + target.dir * gap) - rot * own.pos
|
|
286
|
+
return pya.DCplxTrans(1, angle, mirror, disp.x, disp.y)
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
def _etch_bbox(cell: pya.Cell) -> pya.DBox:
|
|
290
|
+
"""Local bounding box of a cell's etch (``base_metal_gap_wo_grid`` of every face), else of the whole cell."""
|
|
291
|
+
from kqcircuits.defaults import default_faces # pylint: disable=import-outside-toplevel
|
|
292
|
+
|
|
293
|
+
layout = cell.layout()
|
|
294
|
+
box = pya.DBox()
|
|
295
|
+
for face in default_faces.values():
|
|
296
|
+
info = face.get("base_metal_gap_wo_grid")
|
|
297
|
+
li = layout.find_layer(info) if info is not None else None
|
|
298
|
+
if li is not None:
|
|
299
|
+
box += cell.dbbox_per_layer(li)
|
|
300
|
+
return box if not box.empty() else cell.dbbox()
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
def edge_trans(name: str, trans: pya.DCplxTrans, local_box, chip_box, edge: str, gap: float) -> pya.DCplxTrans:
|
|
304
|
+
"""``trans`` slid perpendicular to die edge ``edge`` (n/s/e/w/auto) so the instance's etch ends ``gap`` µm from
|
|
305
|
+
it (PDK pad rule, :attr:`~quantcore_circuits.pdk.DieFrame.pad_edge`)."""
|
|
306
|
+
if local_box is None or local_box.empty():
|
|
307
|
+
raise PlacementError(f"{name}: 'edge' placement needs a cell with an etch (not a static cell)")
|
|
308
|
+
x0, y0, x1, y1 = chip_box
|
|
309
|
+
b = local_box.transformed(trans)
|
|
310
|
+
if edge == "auto":
|
|
311
|
+
c = trans.disp
|
|
312
|
+
dist = {"w": c.x - x0, "e": x1 - c.x, "s": c.y - y0, "n": y1 - c.y}
|
|
313
|
+
edge = min(dist, key=dist.get)
|
|
314
|
+
shift = {
|
|
315
|
+
"w": pya.DVector(x0 + gap - b.left, 0),
|
|
316
|
+
"e": pya.DVector(x1 - gap - b.right, 0),
|
|
317
|
+
"s": pya.DVector(0, y0 + gap - b.bottom),
|
|
318
|
+
"n": pya.DVector(0, y1 - gap - b.top),
|
|
319
|
+
}[edge]
|
|
320
|
+
return pya.DCplxTrans(shift) * trans
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
def _placement_order(design: Design) -> list[str]:
|
|
324
|
+
"""Topological order of instances by snap dependencies; raises on cycles."""
|
|
325
|
+
deps = {}
|
|
326
|
+
for name, inst in design.instances.items():
|
|
327
|
+
deps[name] = set()
|
|
328
|
+
if inst.place.is_snap:
|
|
329
|
+
target, _ = split_port_ref(inst.place.to)
|
|
330
|
+
if target != CHIP:
|
|
331
|
+
deps[name].add(target)
|
|
332
|
+
order, state = [], {}
|
|
333
|
+
|
|
334
|
+
def visit(n, stack):
|
|
335
|
+
if state.get(n) == "done":
|
|
336
|
+
return
|
|
337
|
+
if state.get(n) == "active":
|
|
338
|
+
cycle = stack[stack.index(n) :] + [n]
|
|
339
|
+
raise PlacementError("snap cycle: " + " -> ".join(cycle))
|
|
340
|
+
state[n] = "active"
|
|
341
|
+
for d in sorted(deps[n]):
|
|
342
|
+
visit(d, stack + [d])
|
|
343
|
+
state[n] = "done"
|
|
344
|
+
order.append(n)
|
|
345
|
+
|
|
346
|
+
for n in design.instances:
|
|
347
|
+
visit(n, [n])
|
|
348
|
+
return order
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
def _route_order(design: Design) -> list[str]:
|
|
352
|
+
"""Routes ordered so that hanger targets are planned before the routes hanging off them."""
|
|
353
|
+
deps = {n: {e.hanger for e in (r.from_, r.to) if isinstance(e, HangerEnd)} for n, r in design.routes.items()}
|
|
354
|
+
order, state = [], {}
|
|
355
|
+
|
|
356
|
+
def visit(n, stack):
|
|
357
|
+
if state.get(n) == "done":
|
|
358
|
+
return
|
|
359
|
+
if state.get(n) == "active":
|
|
360
|
+
raise RoutingError("hanger cycle: " + " -> ".join(stack[stack.index(n) :] + [n]))
|
|
361
|
+
state[n] = "active"
|
|
362
|
+
for d in sorted(deps[n]):
|
|
363
|
+
visit(d, stack + [d])
|
|
364
|
+
state[n] = "done"
|
|
365
|
+
order.append(n)
|
|
366
|
+
|
|
367
|
+
for n in design.routes:
|
|
368
|
+
visit(n, [n])
|
|
369
|
+
return order
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
def _route_end(plan: BuildPlan, end, a, b, r) -> RouteEnd:
|
|
373
|
+
if isinstance(end, FreeEnd):
|
|
374
|
+
return RouteEnd.from_free(end)
|
|
375
|
+
if isinstance(end, HangerEnd):
|
|
376
|
+
return _hanger_end(plan, end, a, b, r)
|
|
377
|
+
return RouteEnd.from_port(plan.port(end))
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
def _nearest_arclength(pts: list, near) -> float:
|
|
381
|
+
"""Arclength along polyline ``pts`` of its point nearest to ``near``."""
|
|
382
|
+
best, best_s, acc = None, 0.0, 0.0
|
|
383
|
+
for p, q in zip(pts[:-1], pts[1:]):
|
|
384
|
+
v = q - p
|
|
385
|
+
seg = v.length()
|
|
386
|
+
u = 0.0 if seg == 0 else max(0.0, min(1.0, ((near.x - p.x) * v.x + (near.y - p.y) * v.y) / (seg * seg)))
|
|
387
|
+
d = (p + v * u - near).length()
|
|
388
|
+
if best is None or d < best - 1e-9:
|
|
389
|
+
best, best_s = d, acc + u * seg
|
|
390
|
+
acc += seg
|
|
391
|
+
return best_s
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
def _hanger_end(plan: BuildPlan, h: HangerEnd, a: float, b: float, r: float) -> RouteEnd:
|
|
395
|
+
"""Coupler parallel to route ``h.hanger`` centred at arclength ``h.s`` along its node polyline."""
|
|
396
|
+
if h.hanger in plan.failed:
|
|
397
|
+
raise RoutingError(f"it hangs on route {h.hanger!r}, which failed: {plan.failed[h.hanger].error}")
|
|
398
|
+
target = plan.routes[h.hanger]
|
|
399
|
+
pts = target.polyline()
|
|
400
|
+
s_c = h.s if h.s is not None else _nearest_arclength(pts, pya.DPoint(*h.near))
|
|
401
|
+
acc = 0.0
|
|
402
|
+
for p, q in zip(pts[:-1], pts[1:]):
|
|
403
|
+
seg = (q - p).length()
|
|
404
|
+
if acc - 1e-9 <= s_c <= acc + seg + 1e-9:
|
|
405
|
+
if s_c - h.length / 2 < acc - 1e-6 or s_c + h.length / 2 > acc + seg + 1e-6:
|
|
406
|
+
raise RoutingError(
|
|
407
|
+
f"hanger on {h.hanger!r}: coupler [{s_c - h.length / 2:.1f}, {s_c + h.length / 2:.1f}] µm must lie "
|
|
408
|
+
f"on one straight segment ([{acc:.1f}, {acc + seg:.1f}] µm)"
|
|
409
|
+
)
|
|
410
|
+
t = (q - p) / seg
|
|
411
|
+
centre = p + t * (s_c - acc)
|
|
412
|
+
break
|
|
413
|
+
acc += seg
|
|
414
|
+
else:
|
|
415
|
+
raise RoutingError(f"hanger on {h.hanger!r}: s={s_c} µm is beyond the route length {acc:.1f} µm")
|
|
416
|
+
n = pya.DVector(-t.y, t.x) if h.side == "left" else pya.DVector(t.y, -t.x)
|
|
417
|
+
a_l, b_l = target.params["a"], target.params["b"]
|
|
418
|
+
b_l_in = b_l if h.line_gap is None else float(h.line_gap) # the facing gaps (narrowed: closer centre lines)
|
|
419
|
+
b_r_in = b if h.coupler_gap is None else float(h.coupler_gap)
|
|
420
|
+
d = a_l / 2 + b_l_in + h.ground_gap + b_r_in + a / 2
|
|
421
|
+
if h.coupler_gap is not None or h.line_gap is not None:
|
|
422
|
+
if not (0 < b_l_in <= b_l and 0 < b_r_in <= b):
|
|
423
|
+
raise RoutingError(f"hanger on {h.hanger!r}: coupler_gap / line_gap must be > 0 and at most the CPW gaps "
|
|
424
|
+
f"({b:g} / {b_l:g} µm)")
|
|
425
|
+
if b - b_r_in > b_l_in + h.ground_gap + 1e-9 or b_l - b_l_in > b_r_in + h.ground_gap + 1e-9:
|
|
426
|
+
raise RoutingError(f"hanger on {h.hanger!r}: gaps narrowed by more than the facing gap + ground strip; "
|
|
427
|
+
"raise ground_gap or narrow less")
|
|
428
|
+
# the ground strip between the narrowed gaps, over the coupler length: drawn as extra metal by the build
|
|
429
|
+
u1, u2 = a_l / 2 + b_l_in, d - a / 2 - b_r_in
|
|
430
|
+
ends = (centre - t * (h.length / 2), centre + t * (h.length / 2))
|
|
431
|
+
plan.metal.append([[round(q.x, 4), round(q.y, 4)] for q in
|
|
432
|
+
(ends[0] + n * u1, ends[1] + n * u1, ends[1] + n * u2, ends[0] + n * u2)])
|
|
433
|
+
c_minus = centre - t * (h.length / 2) + n * d
|
|
434
|
+
c_plus = centre + t * (h.length / 2) + n * d
|
|
435
|
+
first, last = (c_minus, c_plus) if h.direction == "forward" else (c_plus, c_minus)
|
|
436
|
+
term = 0.0 if h.end == "short" else h.open_gap
|
|
437
|
+
if not h.bend: # straight entry: the route runs into the coupler along its own axis
|
|
438
|
+
axis = (last - first) / (last - first).length()
|
|
439
|
+
return RouteEnd(last, None, a, b, term=term, approach=[first - axis * r, first])
|
|
440
|
+
return RouteEnd(last, None, a, b, term=term, approach=[first + n * r, first])
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
def launcher_spec(launchers) -> str | dict | None:
|
|
444
|
+
"""JSON form of ``Chip.launchers`` (a sample-holder name or a :class:`~quantcore_circuits.design.Launchers`)."""
|
|
445
|
+
return launchers.model_dump(mode="json") if hasattr(launchers, "model_dump") else launchers
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
def _launcher_ports(launchers, chip_params: dict, edge: float | None = None) -> dict[str, Port]:
|
|
449
|
+
"""Chip-level launcher ports, measured from a launcher-only DesignChip (``edge``: the PDK pad rule)."""
|
|
450
|
+
from quantcore_circuits.layouts.chips.design_chip import DesignChip # pylint: disable=import-outside-toplevel
|
|
451
|
+
|
|
452
|
+
layout = pya.Layout()
|
|
453
|
+
params = {k: v for k, v in chip_params.items() if k in ("box", "a", "b", "r", "face_ids")}
|
|
454
|
+
spec = {"launchers": launcher_spec(launchers), "instances": {}, "routes": {}}
|
|
455
|
+
if edge is not None:
|
|
456
|
+
spec["pad_edge"] = edge
|
|
457
|
+
plan = json.dumps(spec)
|
|
458
|
+
cell = check_cell(DesignChip.create(layout, plan=plan, frames_enabled=[], **params), "launchers")
|
|
459
|
+
from kqcircuits.defaults import default_layers # pylint: disable=import-outside-toplevel
|
|
460
|
+
from kqcircuits.elements.element import get_refpoints # pylint: disable=import-outside-toplevel
|
|
461
|
+
|
|
462
|
+
refp = dict(get_refpoints(layout.layer(default_layers["refpoints"]), cell, pya.DTrans(), 0))
|
|
463
|
+
# launcher refpoints are "<name>_port" / "<name>_port_corner" (inserted with inst_name)
|
|
464
|
+
ports = {}
|
|
465
|
+
for key, pos in refp.items():
|
|
466
|
+
if key.endswith("_port") and f"{key}_corner" in refp:
|
|
467
|
+
name = key[: -len("_port")]
|
|
468
|
+
v = refp[f"{key}_corner"] - pos
|
|
469
|
+
ports[name] = Port(name, pos, v / v.length(), chip_params.get("a"), chip_params.get("b"))
|
|
470
|
+
return ports
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
def plan_design(
|
|
474
|
+
design: Design, scratch: pya.Layout | None = None, keep_going: bool = False, last_good: dict | None = None
|
|
475
|
+
) -> BuildPlan:
|
|
476
|
+
"""Resolve a design into a :class:`BuildPlan`. Raises on any placement or routing problem.
|
|
477
|
+
|
|
478
|
+
``keep_going`` (the plugin's builds): a route that cannot be built does not stop the rest. It is left out of
|
|
479
|
+
``plan.routes`` and listed in ``plan.failed`` with the reason, the path the design asks for and, from ``last_good``
|
|
480
|
+
(``{route: stored geometry}``, see :mod:`quantcore_circuits.assembly.last_good`), the route's last good geometry.
|
|
481
|
+
A route hanging on a failed route fails with its own reason. Placement problems still raise.
|
|
482
|
+
"""
|
|
483
|
+
from quantcore_circuits.layouts.chips.design_chip import ensure_registered # pylint: disable=import-outside-toplevel
|
|
484
|
+
|
|
485
|
+
ensure_registered()
|
|
486
|
+
scratch = scratch or pya.Layout()
|
|
487
|
+
chip_params = chip_parameters(design)
|
|
488
|
+
inherited = inherited_params(chip_params)
|
|
489
|
+
edge = pad_edge(design)
|
|
490
|
+
chip_ports = _launcher_ports(design.chip.launchers, chip_params, edge) if design.chip.launchers else {}
|
|
491
|
+
plan = BuildPlan(design, chip_params, launcher_spec(design.chip.launchers), chip_ports, pad_edge=edge)
|
|
492
|
+
frame = die_frame(design)
|
|
493
|
+
if frame is not None:
|
|
494
|
+
plan.frame = asdict(frame)
|
|
495
|
+
plan.device_id = str(design.chip.params.get("name_chip", design.name[:16]))
|
|
496
|
+
plan.cheese = cheese_spec(design)
|
|
497
|
+
|
|
498
|
+
# 1. element cells and local ports
|
|
499
|
+
local = {}
|
|
500
|
+
etch_boxes = {} # local etch bounding boxes of the instances placed at a die edge (place.edge)
|
|
501
|
+
for name, inst in design.instances.items():
|
|
502
|
+
if inst.cell.startswith("static:"):
|
|
503
|
+
ports = {
|
|
504
|
+
p.name: Port(p.name, pya.DPoint(*p.at), direction_vector(p.dir), p.a, p.b) for p in inst.ports or []
|
|
505
|
+
}
|
|
506
|
+
local[name] = (inst.cell, {}, ports)
|
|
507
|
+
continue
|
|
508
|
+
cls = resolve_cell(inst.cell)
|
|
509
|
+
params = element_params(cls, inherited, inst.params)
|
|
510
|
+
cell = create_cell(scratch, cls, what=name, **params)
|
|
511
|
+
local[name] = (cell_ref(cls), params, element_cell_ports(cls, cell, params))
|
|
512
|
+
if inst.place.edge:
|
|
513
|
+
etch_boxes[name] = _etch_bbox(cell)
|
|
514
|
+
|
|
515
|
+
# 2. placements in dependency order
|
|
516
|
+
for name in _placement_order(design):
|
|
517
|
+
inst = design.instances[name]
|
|
518
|
+
cell, params, ports = local[name]
|
|
519
|
+
if inst.place.is_snap:
|
|
520
|
+
own_name = inst.place.snap.split(".", 1)[1] if "." in inst.place.snap else inst.place.snap
|
|
521
|
+
if own_name not in ports:
|
|
522
|
+
raise PlacementError(f"{name}: no port {own_name!r}; available: {sorted(ports)}")
|
|
523
|
+
target = plan.port(inst.place.to)
|
|
524
|
+
trans = snap_trans(ports[own_name], target, inst.place.mirror, inst.place.gap)
|
|
525
|
+
else:
|
|
526
|
+
x, y = inst.place.at
|
|
527
|
+
trans = pya.DCplxTrans(1, inst.place.rot, inst.place.mirror, x, y)
|
|
528
|
+
if inst.place.edge:
|
|
529
|
+
trans = edge_trans(name, trans, etch_boxes.get(name), design.chip.box, inst.place.edge, edge)
|
|
530
|
+
plan.instances[name] = PlacedInstance(name, cell, params, trans, ports)
|
|
531
|
+
|
|
532
|
+
# 3. routes, in dependency order (hanger targets first)
|
|
533
|
+
route_defaults = {"a": inherited.get("a", 10), "b": inherited.get("b", 6), "r": inherited.get("r", 100)}
|
|
534
|
+
plan.keep_going = keep_going
|
|
535
|
+
for name in _route_order(design):
|
|
536
|
+
route = design.routes[name]
|
|
537
|
+
try:
|
|
538
|
+
plan.routes[name] = _plan_one_route(plan, scratch, name, route, inherited, route_defaults)
|
|
539
|
+
except Exception as e: # noqa: BLE001 (KQC raises its own errors, e.g. "Straight segment cannot fit")
|
|
540
|
+
if not keep_going:
|
|
541
|
+
raise
|
|
542
|
+
plan.failed[name] = FailedRoute(
|
|
543
|
+
name, _error_text(e, name), _attempt_path(plan, route), (last_good or {}).get(name)
|
|
544
|
+
)
|
|
545
|
+
return plan
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
def _error_text(e: Exception, name: str) -> str:
|
|
549
|
+
"""The reason a route failed, as one line that starts with the route's name."""
|
|
550
|
+
text = " ".join(str(e).split()) or type(e).__name__
|
|
551
|
+
if not isinstance(e, (RoutingError, PlacementError, ValueError)):
|
|
552
|
+
text = f"{type(e).__name__}: {text}"
|
|
553
|
+
return text if text.startswith(f"route {name}") else f"route {name}: {text}"
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
def _attempt_path(plan: BuildPlan, route) -> list:
|
|
557
|
+
"""[start, the design's nodes..., end] of a route (an end that cannot be resolved is None)."""
|
|
558
|
+
|
|
559
|
+
def at(end):
|
|
560
|
+
try:
|
|
561
|
+
if isinstance(end, FreeEnd):
|
|
562
|
+
return pya.DPoint(*end.at)
|
|
563
|
+
if isinstance(end, HangerEnd):
|
|
564
|
+
return pya.DPoint(*end.near) if end.near is not None else None
|
|
565
|
+
return plan.port(end).pos
|
|
566
|
+
except Exception: # noqa: BLE001
|
|
567
|
+
return None
|
|
568
|
+
|
|
569
|
+
return [at(route.from_)] + [pya.DPoint(*w.at) for w in route.waypoints()] + [at(route.to)]
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
def _plan_one_route(plan: BuildPlan, scratch, name: str, route, inherited: dict, route_defaults: dict) -> RoutePlan:
|
|
573
|
+
start = _route_end(plan, route.from_, None, None, None)
|
|
574
|
+
a_r = route.a if route.a is not None else (start.a if start.a is not None else route_defaults["a"])
|
|
575
|
+
b_r = route.b if route.b is not None else (start.b if start.b is not None else route_defaults["b"])
|
|
576
|
+
r_r = route.r if route.r is not None else route_defaults["r"]
|
|
577
|
+
end = _route_end(plan, route.to, a_r, b_r, r_r)
|
|
578
|
+
rplan = plan_route(name, route, start, end, route_defaults)
|
|
579
|
+
rplan.params = {**{k: v for k, v in inherited.items() if k not in rplan.params}, **rplan.params}
|
|
580
|
+
|
|
581
|
+
def measure(p):
|
|
582
|
+
cls = waveguide_class(p.nodes) # per-corner radii → WaveguideCompositeCorners
|
|
583
|
+
cell = create_cell(scratch, cls, what=f"route {name}", nodes=p.nodes, **p.params)
|
|
584
|
+
return cell.length()
|
|
585
|
+
|
|
586
|
+
if rplan.target_length is not None:
|
|
587
|
+
rplan = fix_length(rplan, measure, route.meander_segment, route.meanders, direction=route.meander_direction)
|
|
588
|
+
else:
|
|
589
|
+
rplan.length = measure(rplan)
|
|
590
|
+
rplan.joins = _joins(plan, route)
|
|
591
|
+
return rplan
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
def _joins(plan: BuildPlan, route) -> list:
|
|
595
|
+
"""The route's ends at a placed cell's port: ``[{"inst", "node": 0 | -1}]`` (first / last node)."""
|
|
596
|
+
out = []
|
|
597
|
+
for end, node in ((route.from_, 0), (route.to, -1)):
|
|
598
|
+
if isinstance(end, str):
|
|
599
|
+
inst, _ = split_port_ref(end)
|
|
600
|
+
if inst != CHIP and inst in plan.instances:
|
|
601
|
+
out.append({"inst": inst, "node": node})
|
|
602
|
+
return out
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
__all__ = ["BuildPlan", "FailedRoute", "PlacedInstance", "PlacementError", "RoutingError", "plan_design", "snap_trans"]
|