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.
Files changed (272) hide show
  1. quantcore_circuits/__init__.py +57 -0
  2. quantcore_circuits/analysis/__init__.py +12 -0
  3. quantcore_circuits/analysis/_metal.py +70 -0
  4. quantcore_circuits/analysis/amplifiers.py +263 -0
  5. quantcore_circuits/analysis/circuits.py +117 -0
  6. quantcore_circuits/analysis/epr.py +231 -0
  7. quantcore_circuits/analysis/epr_lumped.py +372 -0
  8. quantcore_circuits/analysis/extract.py +119 -0
  9. quantcore_circuits/analysis/lom.py +80 -0
  10. quantcore_circuits/analysis/results.py +549 -0
  11. quantcore_circuits/analysis/store.py +81 -0
  12. quantcore_circuits/analysis/synthesis.py +118 -0
  13. quantcore_circuits/analysis/transmon.py +126 -0
  14. quantcore_circuits/assembly/__init__.py +17 -0
  15. quantcore_circuits/assembly/builder.py +127 -0
  16. quantcore_circuits/assembly/drc.py +683 -0
  17. quantcore_circuits/assembly/last_good.py +137 -0
  18. quantcore_circuits/assembly/netlist.py +174 -0
  19. quantcore_circuits/assembly/plan.py +605 -0
  20. quantcore_circuits/assembly/sidecar.py +270 -0
  21. quantcore_circuits/autotrack.py +605 -0
  22. quantcore_circuits/cards.py +878 -0
  23. quantcore_circuits/circuit/__init__.py +14 -0
  24. quantcore_circuits/circuit/adapters.py +305 -0
  25. quantcore_circuits/circuit/bridges.py +353 -0
  26. quantcore_circuits/circuit/consensus.py +158 -0
  27. quantcore_circuits/circuit/derive.py +28 -0
  28. quantcore_circuits/circuit/draw.py +198 -0
  29. quantcore_circuits/circuit/fill.py +828 -0
  30. quantcore_circuits/circuit/hamiltonian.py +193 -0
  31. quantcore_circuits/circuit/kinetic.py +102 -0
  32. quantcore_circuits/circuit/schema.py +139 -0
  33. quantcore_circuits/cli.py +1085 -0
  34. quantcore_circuits/codesign.py +1038 -0
  35. quantcore_circuits/data/selftest_q1_r1.json +44 -0
  36. quantcore_circuits/design/__init__.py +44 -0
  37. quantcore_circuits/design/io.py +98 -0
  38. quantcore_circuits/design/pyscript.py +395 -0
  39. quantcore_circuits/design/schema.py +398 -0
  40. quantcore_circuits/designer.py +625 -0
  41. quantcore_circuits/guiflow.py +991 -0
  42. quantcore_circuits/kqc_files.py +208 -0
  43. quantcore_circuits/layouts/__init__.py +118 -0
  44. quantcore_circuits/layouts/catalog.py +520 -0
  45. quantcore_circuits/layouts/chips/__init__.py +0 -0
  46. quantcore_circuits/layouts/chips/design_chip.py +325 -0
  47. quantcore_circuits/layouts/chips/frame.py +235 -0
  48. quantcore_circuits/layouts/junctions/__init__.py +0 -0
  49. quantcore_circuits/layouts/junctions/jj_fingers.py +99 -0
  50. quantcore_circuits/layouts/junctions/legacy_junctions.py +237 -0
  51. quantcore_circuits/layouts/junctions/sim_gap.py +48 -0
  52. quantcore_circuits/layouts/junctions/trilayer.py +541 -0
  53. quantcore_circuits/layouts/metal/__init__.py +105 -0
  54. quantcore_circuits/layouts/metal/component.py +332 -0
  55. quantcore_circuits/layouts/metal/geometry.py +462 -0
  56. quantcore_circuits/layouts/others/__init__.py +0 -0
  57. quantcore_circuits/layouts/others/amplifiers.py +1139 -0
  58. quantcore_circuits/layouts/others/bond_pad.py +119 -0
  59. quantcore_circuits/layouts/others/connector_pads.py +190 -0
  60. quantcore_circuits/layouts/others/couplers.py +21 -0
  61. quantcore_circuits/layouts/others/cpw_segment.py +131 -0
  62. quantcore_circuits/layouts/others/cpwe.py +661 -0
  63. quantcore_circuits/layouts/others/keepout.py +66 -0
  64. quantcore_circuits/layouts/others/legacy_resonators.py +645 -0
  65. quantcore_circuits/layouts/others/markers.py +201 -0
  66. quantcore_circuits/layouts/others/qpdk_cells.py +263 -0
  67. quantcore_circuits/layouts/others/shapes.py +114 -0
  68. quantcore_circuits/layouts/others/spirals.py +140 -0
  69. quantcore_circuits/layouts/others/sqdmetal_cells.py +90 -0
  70. quantcore_circuits/layouts/others/test_pads.py +461 -0
  71. quantcore_circuits/layouts/ports.py +119 -0
  72. quantcore_circuits/layouts/qubits/__init__.py +0 -0
  73. quantcore_circuits/layouts/qubits/legacy_transmon.py +124 -0
  74. quantcore_circuits/layouts/qubits/qpdk_cells.py +374 -0
  75. quantcore_circuits/layouts/qubits/sqdmetal_cells.py +376 -0
  76. quantcore_circuits/layouts/qubits/trilayer_concentric.py +65 -0
  77. quantcore_circuits/layouts/qubits/xmon.py +375 -0
  78. quantcore_circuits/layouts/registry.py +418 -0
  79. quantcore_circuits/layouts/wafers/__init__.py +0 -0
  80. quantcore_circuits/layouts/wafers/fab_export.py +454 -0
  81. quantcore_circuits/layouts/wafers/legacy_wafer.py +111 -0
  82. quantcore_circuits/layouts/wafers/wafer.py +469 -0
  83. quantcore_circuits/live/__init__.py +6 -0
  84. quantcore_circuits/live/klayout.py +225 -0
  85. quantcore_circuits/live/klive.py +61 -0
  86. quantcore_circuits/live/snapshot.py +185 -0
  87. quantcore_circuits/live/watch.py +93 -0
  88. quantcore_circuits/lom/__init__.py +15 -0
  89. quantcore_circuits/lom/builder.py +932 -0
  90. quantcore_circuits/lom/calibration.py +82 -0
  91. quantcore_circuits/lom/estimates.py +235 -0
  92. quantcore_circuits/lom/fragment.py +421 -0
  93. quantcore_circuits/lom/kqc_models.py +734 -0
  94. quantcore_circuits/lom/metal_models.py +917 -0
  95. quantcore_circuits/lom/quantcore_models.py +784 -0
  96. quantcore_circuits/lom/simulate.py +636 -0
  97. quantcore_circuits/lom/synthesize.py +189 -0
  98. quantcore_circuits/loop.py +610 -0
  99. quantcore_circuits/optimise.py +423 -0
  100. quantcore_circuits/pdk/__init__.py +451 -0
  101. quantcore_circuits/plots.py +876 -0
  102. quantcore_circuits/plugins.py +69 -0
  103. quantcore_circuits/review/__init__.py +57 -0
  104. quantcore_circuits/review/server.py +251 -0
  105. quantcore_circuits/review/static/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  106. quantcore_circuits/review/static/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  107. quantcore_circuits/review/static/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  108. quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  109. quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  110. quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  111. quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  112. quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  113. quantcore_circuits/review/static/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  114. quantcore_circuits/review/static/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  115. quantcore_circuits/review/static/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  116. quantcore_circuits/review/static/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  117. quantcore_circuits/review/static/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  118. quantcore_circuits/review/static/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  119. quantcore_circuits/review/static/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  120. quantcore_circuits/review/static/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  121. quantcore_circuits/review/static/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  122. quantcore_circuits/review/static/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  123. quantcore_circuits/review/static/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  124. quantcore_circuits/review/static/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  125. quantcore_circuits/review/static/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  126. quantcore_circuits/review/static/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  127. quantcore_circuits/review/static/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  128. quantcore_circuits/review/static/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  129. quantcore_circuits/review/static/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  130. quantcore_circuits/review/static/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  131. quantcore_circuits/review/static/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  132. quantcore_circuits/review/static/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  133. quantcore_circuits/review/static/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  134. quantcore_circuits/review/static/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  135. quantcore_circuits/review/static/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  136. quantcore_circuits/review/static/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  137. quantcore_circuits/review/static/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  138. quantcore_circuits/review/static/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  139. quantcore_circuits/review/static/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  140. quantcore_circuits/review/static/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  141. quantcore_circuits/review/static/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  142. quantcore_circuits/review/static/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  143. quantcore_circuits/review/static/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  144. quantcore_circuits/review/static/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  145. quantcore_circuits/review/static/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  146. quantcore_circuits/review/static/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  147. quantcore_circuits/review/static/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  148. quantcore_circuits/review/static/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  149. quantcore_circuits/review/static/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  150. quantcore_circuits/review/static/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  151. quantcore_circuits/review/static/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  152. quantcore_circuits/review/static/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  153. quantcore_circuits/review/static/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  154. quantcore_circuits/review/static/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  155. quantcore_circuits/review/static/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  156. quantcore_circuits/review/static/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  157. quantcore_circuits/review/static/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  158. quantcore_circuits/review/static/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  159. quantcore_circuits/review/static/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  160. quantcore_circuits/review/static/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  161. quantcore_circuits/review/static/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  162. quantcore_circuits/review/static/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  163. quantcore_circuits/review/static/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  164. quantcore_circuits/review/static/assets/index-CDHdrFyA.css +1 -0
  165. quantcore_circuits/review/static/assets/index-CSx05Og4.js +409 -0
  166. quantcore_circuits/review/static/assets/inter-cyrillic-400-normal-HOLc17fK.woff +0 -0
  167. quantcore_circuits/review/static/assets/inter-cyrillic-400-normal-obahsSVq.woff2 +0 -0
  168. quantcore_circuits/review/static/assets/inter-cyrillic-500-normal-BasfLYem.woff2 +0 -0
  169. quantcore_circuits/review/static/assets/inter-cyrillic-500-normal-CxZf_p3X.woff +0 -0
  170. quantcore_circuits/review/static/assets/inter-cyrillic-600-normal-4D_pXhcN.woff +0 -0
  171. quantcore_circuits/review/static/assets/inter-cyrillic-600-normal-CWCymEST.woff2 +0 -0
  172. quantcore_circuits/review/static/assets/inter-cyrillic-700-normal-CjBOestx.woff2 +0 -0
  173. quantcore_circuits/review/static/assets/inter-cyrillic-700-normal-DrXBdSj3.woff +0 -0
  174. quantcore_circuits/review/static/assets/inter-cyrillic-ext-400-normal-BQZuk6qB.woff2 +0 -0
  175. quantcore_circuits/review/static/assets/inter-cyrillic-ext-400-normal-DQukG94-.woff +0 -0
  176. quantcore_circuits/review/static/assets/inter-cyrillic-ext-500-normal-B0yAr1jD.woff2 +0 -0
  177. quantcore_circuits/review/static/assets/inter-cyrillic-ext-500-normal-BmqWE9Dz.woff +0 -0
  178. quantcore_circuits/review/static/assets/inter-cyrillic-ext-600-normal-Bcila6Z-.woff +0 -0
  179. quantcore_circuits/review/static/assets/inter-cyrillic-ext-600-normal-Dfes3d0z.woff2 +0 -0
  180. quantcore_circuits/review/static/assets/inter-cyrillic-ext-700-normal-BjwYoWNd.woff2 +0 -0
  181. quantcore_circuits/review/static/assets/inter-cyrillic-ext-700-normal-LO58E6JB.woff +0 -0
  182. quantcore_circuits/review/static/assets/inter-greek-400-normal-B4URO6DV.woff2 +0 -0
  183. quantcore_circuits/review/static/assets/inter-greek-400-normal-q2sYcFCs.woff +0 -0
  184. quantcore_circuits/review/static/assets/inter-greek-500-normal-BIZE56-Y.woff2 +0 -0
  185. quantcore_circuits/review/static/assets/inter-greek-500-normal-Xzm54t5V.woff +0 -0
  186. quantcore_circuits/review/static/assets/inter-greek-600-normal-BZpKdvQh.woff +0 -0
  187. quantcore_circuits/review/static/assets/inter-greek-600-normal-plRanbMR.woff2 +0 -0
  188. quantcore_circuits/review/static/assets/inter-greek-700-normal-BUv2fZ6O.woff +0 -0
  189. quantcore_circuits/review/static/assets/inter-greek-700-normal-C3JjAnD8.woff2 +0 -0
  190. quantcore_circuits/review/static/assets/inter-greek-ext-400-normal-DGGRlc-M.woff2 +0 -0
  191. quantcore_circuits/review/static/assets/inter-greek-ext-400-normal-KugGGMne.woff +0 -0
  192. quantcore_circuits/review/static/assets/inter-greek-ext-500-normal-2j5mBUwD.woff +0 -0
  193. quantcore_circuits/review/static/assets/inter-greek-ext-500-normal-C4iEst2y.woff2 +0 -0
  194. quantcore_circuits/review/static/assets/inter-greek-ext-600-normal-B8X0CLgF.woff +0 -0
  195. quantcore_circuits/review/static/assets/inter-greek-ext-600-normal-DRtmH8MT.woff2 +0 -0
  196. quantcore_circuits/review/static/assets/inter-greek-ext-700-normal-BoQ6DsYi.woff +0 -0
  197. quantcore_circuits/review/static/assets/inter-greek-ext-700-normal-qfdV9bQt.woff2 +0 -0
  198. quantcore_circuits/review/static/assets/inter-latin-400-normal-C38fXH4l.woff2 +0 -0
  199. quantcore_circuits/review/static/assets/inter-latin-400-normal-CyCys3Eg.woff +0 -0
  200. quantcore_circuits/review/static/assets/inter-latin-500-normal-BL9OpVg8.woff +0 -0
  201. quantcore_circuits/review/static/assets/inter-latin-500-normal-Cerq10X2.woff2 +0 -0
  202. quantcore_circuits/review/static/assets/inter-latin-600-normal-CiBQ2DWP.woff +0 -0
  203. quantcore_circuits/review/static/assets/inter-latin-600-normal-LgqL8muc.woff2 +0 -0
  204. quantcore_circuits/review/static/assets/inter-latin-700-normal-BLAVimhd.woff +0 -0
  205. quantcore_circuits/review/static/assets/inter-latin-700-normal-Yt3aPRUw.woff2 +0 -0
  206. quantcore_circuits/review/static/assets/inter-latin-ext-400-normal-77YHD8bZ.woff +0 -0
  207. quantcore_circuits/review/static/assets/inter-latin-ext-400-normal-C1nco2VV.woff2 +0 -0
  208. quantcore_circuits/review/static/assets/inter-latin-ext-500-normal-BxGbmqWO.woff +0 -0
  209. quantcore_circuits/review/static/assets/inter-latin-ext-500-normal-CV4jyFjo.woff2 +0 -0
  210. quantcore_circuits/review/static/assets/inter-latin-ext-600-normal-CIVaiw4L.woff +0 -0
  211. quantcore_circuits/review/static/assets/inter-latin-ext-600-normal-D2bJ5OIk.woff2 +0 -0
  212. quantcore_circuits/review/static/assets/inter-latin-ext-700-normal-Ca8adRJv.woff2 +0 -0
  213. quantcore_circuits/review/static/assets/inter-latin-ext-700-normal-TidjK2hL.woff +0 -0
  214. quantcore_circuits/review/static/assets/inter-vietnamese-400-normal-Bbgyi5SW.woff +0 -0
  215. quantcore_circuits/review/static/assets/inter-vietnamese-400-normal-DMkecbls.woff2 +0 -0
  216. quantcore_circuits/review/static/assets/inter-vietnamese-500-normal-DOriooB6.woff2 +0 -0
  217. quantcore_circuits/review/static/assets/inter-vietnamese-500-normal-mJboJaSs.woff +0 -0
  218. quantcore_circuits/review/static/assets/inter-vietnamese-600-normal-BuLX-rYi.woff +0 -0
  219. quantcore_circuits/review/static/assets/inter-vietnamese-600-normal-Cc8MFFhd.woff2 +0 -0
  220. quantcore_circuits/review/static/assets/inter-vietnamese-700-normal-BZaoP0fm.woff +0 -0
  221. quantcore_circuits/review/static/assets/inter-vietnamese-700-normal-DlLaEgI2.woff2 +0 -0
  222. quantcore_circuits/review/static/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
  223. quantcore_circuits/review/static/assets/jetbrains-mono-cyrillic-400-normal-ugxPyKxw.woff +0 -0
  224. quantcore_circuits/review/static/assets/jetbrains-mono-cyrillic-500-normal-DJqRU3vO.woff +0 -0
  225. quantcore_circuits/review/static/assets/jetbrains-mono-cyrillic-500-normal-DmUKJPL_.woff2 +0 -0
  226. quantcore_circuits/review/static/assets/jetbrains-mono-greek-400-normal-B9oWc5Lo.woff +0 -0
  227. quantcore_circuits/review/static/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
  228. quantcore_circuits/review/static/assets/jetbrains-mono-greek-500-normal-D7SFKleX.woff +0 -0
  229. quantcore_circuits/review/static/assets/jetbrains-mono-greek-500-normal-JpySY46c.woff2 +0 -0
  230. quantcore_circuits/review/static/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
  231. quantcore_circuits/review/static/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
  232. quantcore_circuits/review/static/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
  233. quantcore_circuits/review/static/assets/jetbrains-mono-latin-500-normal-CJOVTJB7.woff +0 -0
  234. quantcore_circuits/review/static/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
  235. quantcore_circuits/review/static/assets/jetbrains-mono-latin-ext-400-normal-fXTG6kC5.woff +0 -0
  236. quantcore_circuits/review/static/assets/jetbrains-mono-latin-ext-500-normal-Cut-4mMH.woff2 +0 -0
  237. quantcore_circuits/review/static/assets/jetbrains-mono-latin-ext-500-normal-ckzbgY84.woff +0 -0
  238. quantcore_circuits/review/static/assets/jetbrains-mono-vietnamese-400-normal-CqNFfHCs.woff +0 -0
  239. quantcore_circuits/review/static/assets/jetbrains-mono-vietnamese-500-normal-DNRqzVM1.woff +0 -0
  240. quantcore_circuits/review/static/index.html +14 -0
  241. quantcore_circuits/review/static/logo-quantcore-black.png +0 -0
  242. quantcore_circuits/review/static/logo-quantcore-white.png +0 -0
  243. quantcore_circuits/review/static/sample/chip.png +0 -0
  244. quantcore_circuits/review/static/sample/chip_rev1.png +0 -0
  245. quantcore_circuits/review/static/sample/q1.png +0 -0
  246. quantcore_circuits/review/static/sample/q2.png +0 -0
  247. quantcore_circuits/review/static/sample-state.json +3747 -0
  248. quantcore_circuits/route/__init__.py +5 -0
  249. quantcore_circuits/route/router.py +694 -0
  250. quantcore_circuits/route/waveguide.py +187 -0
  251. quantcore_circuits/selftest.py +224 -0
  252. quantcore_circuits/sim_tools/__init__.py +6 -0
  253. quantcore_circuits/sim_tools/aedt_attach.py +66 -0
  254. quantcore_circuits/sim_tools/aedt_progress.py +224 -0
  255. quantcore_circuits/sim_tools/aedt_project.py +302 -0
  256. quantcore_circuits/sim_tools/aedt_scripts.py +397 -0
  257. quantcore_circuits/sim_tools/aedt_session.py +275 -0
  258. quantcore_circuits/sim_tools/ansys.py +90 -0
  259. quantcore_circuits/sim_tools/builder.py +1690 -0
  260. quantcore_circuits/sim_tools/export.py +470 -0
  261. quantcore_circuits/sim_tools/geometry_check.py +342 -0
  262. quantcore_circuits/sim_tools/hfss.py +583 -0
  263. quantcore_circuits/sim_tools/palace.py +197 -0
  264. quantcore_circuits/sim_tools/runner.py +179 -0
  265. quantcore_circuits/sim_tools/subset.py +364 -0
  266. quantcore_circuits/track.py +671 -0
  267. quantcore_circuits-0.0.1.dist-info/METADATA +204 -0
  268. quantcore_circuits-0.0.1.dist-info/RECORD +272 -0
  269. quantcore_circuits-0.0.1.dist-info/WHEEL +5 -0
  270. quantcore_circuits-0.0.1.dist-info/entry_points.txt +2 -0
  271. quantcore_circuits-0.0.1.dist-info/licenses/LICENSE +674 -0
  272. quantcore_circuits-0.0.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,683 @@
1
+ """Connectivity DRC: every pin, endpoint and handle connected to something, nothing outside the chip, no crossings.
2
+
3
+ ======================== ======== ====================================================================================
4
+ rule severity check
5
+ ======================== ======== ====================================================================================
6
+ ``dangling_port`` warning a component port with no route or snap on it (e.g. an unused claw)
7
+ ``no_lom`` warning a component with ports but no LOM model (its ports stay bare nodes in the circuit)
8
+ ``outside_chip`` error a component box or route vertex outside the chip box
9
+ ``overlap`` warning two component boxes overlap (snapped pairs excepted)
10
+ ``crossing`` error two route centre lines cross on the same chip face (a CPW crossing needs an
11
+ airbridge)
12
+ ``open``/``short`` error declared vs extracted connectivity (KQC netlist, see :mod:`.netlist`)
13
+ ``open_conductor`` error a route and the component port it ends on are not one piece of metal (etch between
14
+ them on the centre line, e.g. a pin whose gap runs past the pin)
15
+ ``route_failed`` error a route could not be built (keep-going build): it is not in the layout, with the
16
+ reason
17
+ ``route_overlap`` error two routes' *built* centre conductors overlap on the same face (meanders included)
18
+ ``route_clearance`` warning two routes' built gap etch touches (no ground strip between the two CPWs)
19
+ ``route_self_overlap`` error a route's built centre conductor runs over itself (nodes looping back across an
20
+ earlier straight, meander turns landing on another part of the same route)
21
+ ``route_over_component`` error a route's built conductor or gap overlaps the etch of a component that is not one of
22
+ its ends (the route runs across it)
23
+ ``airbridge_short`` error a route's airbridge pad lands on another route's conductor or gap (shorts it to
24
+ ground)
25
+ ``frame_margin`` warning a component (not a pad) reaches into the die margin of the PDK frame
26
+ ``frame_keepout`` warning a component or route on a frame marker area or the device ID
27
+ ``pad_edge`` design PDK pad rule: a bond pad / launcher (or ``TaperedPad`` ring) whose outer etch edge
28
+ is not ``frame.pad_edge`` (100 µm) from the nearest die edge (fix: ``place.edge``)
29
+ ``pdk_rn`` design PDK margin: a junction's R_n (from the instance's L_J) outside the junction window
30
+ ``pdk_fq`` design PDK margin: a qubit's f_q target outside the PDK qubit band (4–8 GHz)
31
+ ``pdk_claw`` design PDK margin: a ``metal:TransmonCross`` claw long enough to reach the side arms (fix:
32
+ a longer ``cross_length``)
33
+ ======================== ======== ====================================================================================
34
+
35
+ The ``pad_edge`` and ``pdk_*`` rows are **design warnings** (severity ``"design"``, 2026-11-03): the design
36
+ system builds any values; it flags where a design leaves the PDK margins and never blocks the build. A report with
37
+ only design warnings still reads "DRC clean" (with their count) and is ``ok``.
38
+
39
+ ``check(..., netlist=False)`` skips the KQC netlist extraction; that fast variant runs on every build and is written
40
+ into the KLayout sidecar so the plugin can mark the issues in place.
41
+ """
42
+
43
+ from __future__ import annotations
44
+
45
+ from dataclasses import asdict, dataclass, field
46
+
47
+ from quantcore_circuits import track as _track
48
+
49
+
50
+ @dataclass
51
+ class DrcIssue:
52
+ severity: str # "error" | "warning" | "design" (PDK design warning: flagged, never enforced)
53
+ rule: str
54
+ message: str
55
+ where: list[tuple[float, float]] = field(default_factory=list)
56
+ objects: list[str] = field(default_factory=list)
57
+
58
+
59
+ @dataclass
60
+ class DrcReport:
61
+ issues: list[DrcIssue]
62
+
63
+ @property
64
+ def errors(self) -> list[DrcIssue]:
65
+ return [i for i in self.issues if i.severity == "error"]
66
+
67
+ @property
68
+ def warnings(self) -> list[DrcIssue]:
69
+ return [i for i in self.issues if i.severity == "warning"]
70
+
71
+ @property
72
+ def design(self) -> list[DrcIssue]:
73
+ """PDK design warnings (pad edge, junction R_n window, f_q band, claw length): flagged, never enforced."""
74
+ return [i for i in self.issues if i.severity == "design"]
75
+
76
+ @property
77
+ def ok(self) -> bool:
78
+ return not self.errors
79
+
80
+ def to_json(self) -> list[dict]:
81
+ return [asdict(i) for i in self.issues]
82
+
83
+ def __str__(self) -> str:
84
+ lines = [f"{i.severity:7s} {i.rule:13s} {i.message}" for i in self.issues]
85
+ if len(self.design) == len(self.issues):
86
+ head = "DRC clean" + (f" ({len(self.design)} PDK design warning(s))" if self.design else "")
87
+ return "\n".join([head, *lines])
88
+ return "\n".join(lines)
89
+
90
+
91
+ def _segments_cross(p, q, r, s) -> tuple[float, float] | None:
92
+ """Proper intersection point of segments pq and rs (touching at shared endpoints does not count)."""
93
+
94
+ def sub(a, b):
95
+ return (a[0] - b[0], a[1] - b[1])
96
+
97
+ def cross(a, b):
98
+ return a[0] * b[1] - a[1] * b[0]
99
+
100
+ d1, d2 = sub(q, p), sub(s, r)
101
+ den = cross(d1, d2)
102
+ if abs(den) < 1e-12:
103
+ return None
104
+ t = cross(sub(r, p), d2) / den
105
+ u = cross(sub(r, p), d1) / den
106
+ eps = 1e-6
107
+ if eps < t < 1 - eps and eps < u < 1 - eps:
108
+ return (p[0] + t * d1[0], p[1] + t * d1[1])
109
+ return None
110
+
111
+
112
+ def check(source, netlist: bool = True, keep_going: bool = False) -> DrcReport:
113
+ """DRC of a design or build result. ``keep_going`` builds a design file with the routes that fail left out, and the
114
+ report names them (``route_failed``); the default raises on a route that cannot be built."""
115
+ report = _check(source, netlist, keep_going)
116
+ _track.emit("drc", report=report, design=source.design if hasattr(source, "design") and hasattr(source, "plan") else None)
117
+ return report
118
+
119
+
120
+ def _check(source, netlist: bool = True, keep_going: bool = False) -> DrcReport:
121
+ """DRC of a design (path/dict/Design) or a :class:`~quantcore_circuits.assembly.BuildResult`."""
122
+ from quantcore_circuits.assembly import build # pylint: disable=import-outside-toplevel
123
+ from quantcore_circuits.lom.fragment import lom_model # pylint: disable=import-outside-toplevel
124
+
125
+ result = source if hasattr(source, "plan") and hasattr(source, "cell") else build(source, keep_going=keep_going)
126
+ design, plan = result.design, result.plan
127
+ issues: list[DrcIssue] = []
128
+ for name, f in plan.failed.items(): # never drop a route silently: a failed one is an error of its own
129
+ where = [(p.x, p.y) for p in f.attempt if p is not None][:1]
130
+ kept = " (its last good route is kept for the LOM)" if f.last_good else ""
131
+ issues.append(DrcIssue("error", "route_failed", f"{f.error}; it is not in the layout{kept}", where, [name]))
132
+ ports = plan.all_ports()
133
+
134
+ used = set()
135
+ for route in design.routes.values():
136
+ for end in (route.from_, route.to):
137
+ if isinstance(end, str):
138
+ used.add(end)
139
+ for c in design.couplings.values(): # galvanic joins of overlapping ports
140
+ if c.type == "wire":
141
+ used |= set(c.between)
142
+ snapped = set()
143
+ for name, inst in design.instances.items():
144
+ p = inst.place
145
+ if p.snap and p.to:
146
+ own = p.snap if "." in p.snap else f"{name}.{p.snap}"
147
+ used |= {own, p.to}
148
+ snapped.add(frozenset({name, p.to.split(".", 1)[0]}))
149
+ for ref, port in sorted(ports.items()):
150
+ inst = ref.split(".", 1)[0]
151
+ if inst in design.instances and ref not in used:
152
+ issues.append(
153
+ DrcIssue(
154
+ "warning",
155
+ "dangling_port",
156
+ f"{ref} is not connected (no route or snap)",
157
+ [(port.pos.x, port.pos.y)],
158
+ [ref],
159
+ )
160
+ )
161
+ for name, inst in design.instances.items():
162
+ placed = plan.instances.get(name)
163
+ if placed is not None and not placed.local_ports:
164
+ continue # no ports: nothing to map into the circuit (test pads, ground perforations, markers)
165
+ if not inst.cell.startswith("static:") and lom_model(inst.cell) is None:
166
+ issues.append(DrcIssue("warning", "no_lom", f"{name} ({inst.cell}) has no LOM model", [], [name]))
167
+
168
+ x0, y0, x1, y1 = design.chip.box
169
+ from quantcore_circuits.assembly.sidecar import sidecar_dict # pylint: disable=import-outside-toplevel
170
+
171
+ side = sidecar_dict(result, overlays=False)
172
+ boxes = {n: i["bbox"] for n, i in side["instances"].items() if i.get("bbox")}
173
+ for name, b in boxes.items():
174
+ if b[0] < x0 - 1e-6 or b[1] < y0 - 1e-6 or b[2] > x1 + 1e-6 or b[3] > y1 + 1e-6:
175
+ issues.append(
176
+ DrcIssue(
177
+ "error",
178
+ "outside_chip",
179
+ f"{name} extends outside the chip box",
180
+ [((b[0] + b[2]) / 2, (b[1] + b[3]) / 2)],
181
+ [name],
182
+ )
183
+ )
184
+ issues += _frame_issues(design, boxes, side["routes"], device_id_block(result))
185
+ issues += pdk_margin_issues(design, boxes)
186
+ issues += _conductor_opens(result)
187
+ issues += _route_overlaps(result)
188
+ names = sorted(boxes)
189
+ for i, a in enumerate(names):
190
+ for b in names[i + 1 :]:
191
+ A, B = boxes[a], boxes[b]
192
+ if A[0] < B[2] and B[0] < A[2] and A[1] < B[3] and B[1] < A[3] and frozenset({a, b}) not in snapped:
193
+ c = ((max(A[0], B[0]) + min(A[2], B[2])) / 2, (max(A[1], B[1]) + min(A[3], B[3])) / 2)
194
+ issues.append(DrcIssue("warning", "overlap", f"{a} and {b} overlap", [c], [a, b]))
195
+ polys = {n: [tuple(p) for p in r["polyline"]] for n, r in side["routes"].items()}
196
+ for name, pts in polys.items():
197
+ out = [p for p in pts if not (x0 <= p[0] <= x1 and y0 <= p[1] <= y1)]
198
+ if out:
199
+ issues.append(DrcIssue("error", "outside_chip", f"route {name} leaves the chip box", out[:1], [name]))
200
+ rnames = sorted(polys)
201
+ faces = {n: _segment_faces(design, n, side["routes"][n]) for n in rnames}
202
+ for i, a in enumerate(rnames):
203
+ for b in rnames[i + 1 :]:
204
+ hit = None
205
+ for k, (p, q) in enumerate(zip(polys[a], polys[a][1:])):
206
+ for m, (r, s) in enumerate(zip(polys[b], polys[b][1:])):
207
+ if faces[a][k] != faces[b][m]:
208
+ continue # one line passes over the other on the other chip face (flip chip)
209
+ hit = _segments_cross(p, q, r, s)
210
+ if hit:
211
+ break
212
+ if hit:
213
+ break
214
+ if hit:
215
+ issues.append(
216
+ DrcIssue(
217
+ "error", "crossing", f"routes {a} and {b} cross (needs an airbridge crossing)", [hit], [a, b]
218
+ )
219
+ )
220
+ if netlist:
221
+ from quantcore_circuits.assembly.netlist import check_netlist # pylint: disable=import-outside-toplevel
222
+
223
+ for n in check_netlist(result).issues:
224
+ issues.append(DrcIssue("error", n.kind, str(n), n.where, list(n.ports)))
225
+ return DrcReport(issues)
226
+
227
+
228
+ def _edge_component(cell: str) -> bool:
229
+ """Pads and launchers may reach the die edge (their ground cut-out runs to the dicing line)."""
230
+ if cell.startswith("static:"):
231
+ return False
232
+ from quantcore_circuits.layouts.registry import resolve_cell # pylint: disable=import-outside-toplevel
233
+
234
+ try:
235
+ cls = resolve_cell(cell)
236
+ except Exception: # noqa: BLE001
237
+ return False
238
+ category = getattr(cls, "qcc_category", "")
239
+ return category in ("launcher", "termination") or "Launch" in cls.__name__ or cls.__name__.endswith("Pad")
240
+
241
+
242
+ # Cells outside the ``launcher`` category that are still bond pads for the PDK pad rule. ``TaperedPad``
243
+ # (2026-11-18): drawn as a wire-bond / probe ring at the die edge (chip_06's 24 rings), so its etch window follows
244
+ # ``frame.pad_edge`` too; one used as a probe pad inside the die gets a ``pad_edge`` design warning (never blocking).
245
+ _BOND_PAD_CELLS = ("Launcher", "LauncherDC", "TaperedPad")
246
+
247
+
248
+ def _bond_pad(cell: str) -> bool:
249
+ """Bond pads and launchers (the cells the PDK pad rule puts at the die edge): the ``launcher`` category and
250
+ :data:`_BOND_PAD_CELLS`."""
251
+ if cell.startswith("static:"):
252
+ return False
253
+ from quantcore_circuits.layouts.registry import resolve_cell # pylint: disable=import-outside-toplevel
254
+
255
+ try:
256
+ cls = resolve_cell(cell)
257
+ except Exception: # noqa: BLE001
258
+ return False
259
+ return getattr(cls, "qcc_category", "") == "launcher" or cls.__name__ in _BOND_PAD_CELLS
260
+
261
+
262
+ _UNITS = {"um": 1.0, "nm": 1e-3, "mm": 1e3}
263
+
264
+
265
+ def _metal_um(value, default: float) -> float:
266
+ """A ``metal:`` length option in µm ("150um", "0.2mm"; a bare number is µm, as the ``metal:`` wrapper reads
267
+ it — see ``layouts/metal/component.py``)."""
268
+ if value is None or value == "":
269
+ return default
270
+ if isinstance(value, (int, float)):
271
+ return float(value)
272
+ text = str(value).strip().replace(" ", "")
273
+ for unit, scale in _UNITS.items():
274
+ if text.endswith(unit):
275
+ try:
276
+ return float(text[: -len(unit)]) * scale
277
+ except ValueError:
278
+ return default
279
+ try:
280
+ return float(text)
281
+ except ValueError:
282
+ return default
283
+
284
+
285
+ def _junction_rn_kohm(inst, proc) -> list[float]:
286
+ """Device R_n (kΩ) of each junction element of an instance, from its ``junction.Lj_nH`` (a list: one value per
287
+ junction element). As in :func:`~quantcore_circuits.circuit.bridges.junction_from_fingers` and
288
+ ``size_junction``, the PDK window applies to the device: a SQUID's L_J is its parallel total, so its R_n is the
289
+ parallel R_n of the two junctions (two 90 kΩ junctions = a 45 kΩ SQUID, inside 40–50 kΩ)."""
290
+ from quantcore_circuits.circuit.bridges import rn_from_lj # pylint: disable=import-outside-toplevel
291
+
292
+ j = inst.junction
293
+ if j is None or j.Lj_nH is None:
294
+ return []
295
+ values = j.Lj_nH if isinstance(j.Lj_nH, list) else [j.Lj_nH]
296
+ return [rn_from_lj(float(lj), proc.gap_meV) / 1e3 for lj in values if lj and float(lj) > 0]
297
+
298
+
299
+ def pdk_margin_issues(design, boxes: dict) -> list[DrcIssue]:
300
+ """PDK design warnings (flagged, never enforced): pad edge distance, junction R_n window, f_q band, TransmonCross
301
+ claw vs arm length."""
302
+ from quantcore_circuits.pdk import get_pdk # pylint: disable=import-outside-toplevel
303
+
304
+ pdk = get_pdk(design.pdk)
305
+ out = []
306
+ x0, y0, x1, y1 = design.chip.box
307
+ edge = pdk.frame.pad_edge
308
+ for name, inst in design.instances.items():
309
+ b = boxes.get(name)
310
+ if b is None or not _bond_pad(inst.cell):
311
+ continue
312
+ gap = min(b[0] - x0, b[1] - y0, x1 - b[2], y1 - b[3])
313
+ if abs(gap - edge) > 1.0:
314
+ out.append(
315
+ DrcIssue(
316
+ "design",
317
+ "pad_edge",
318
+ f"{name}: outer edge {gap:.0f} µm from the die edge; the Quantcore PDK puts pads {edge:g} µm from "
319
+ "it — place it with edge='auto'",
320
+ [((b[0] + b[2]) / 2, (b[1] + b[3]) / 2)],
321
+ [name],
322
+ )
323
+ )
324
+ proc = pdk.junction
325
+ lo, hi = proc.rn_target_kohm
326
+ for name, inst in design.instances.items():
327
+ bad = [rn for rn in _junction_rn_kohm(inst, proc) if not lo <= rn <= hi]
328
+ if bad:
329
+ out.append(
330
+ DrcIssue(
331
+ "design",
332
+ "pdk_rn",
333
+ f"{name}: junction R_n {', '.join(f'{rn:.1f}' for rn in bad)} kΩ is outside the PDK window "
334
+ f"{lo:g}–{hi:g} kΩ (L_J {inst.junction.Lj_nH} nH)",
335
+ [],
336
+ [name],
337
+ )
338
+ )
339
+ f_lo, f_hi = proc.f_q_range_GHz
340
+ for name, target in design.targets.items():
341
+ f = target.get("f_q_GHz")
342
+ if f is not None and not f_lo <= float(f) <= f_hi:
343
+ out.append(
344
+ DrcIssue(
345
+ "design",
346
+ "pdk_fq",
347
+ f"{name}: f_q target {f:g} GHz is outside the PDK band {f_lo:g}–{f_hi:g} GHz",
348
+ [],
349
+ [name],
350
+ )
351
+ )
352
+ for name, inst in design.instances.items():
353
+ if inst.cell not in ("metal:TransmonCross", "metal:TransmonCrossFL"):
354
+ continue
355
+ from quantcore_circuits.layouts.metal import flat_options # pylint: disable=import-outside-toplevel
356
+
357
+ p = flat_options(inst.params)
358
+ arm = _metal_um(p.get("cross_length"), 200.0)
359
+ width = _metal_um(p.get("cross_width"), 20.0)
360
+ for pad, opts in (p.get("connection_pads") or {}).items():
361
+ opts = opts or {}
362
+ if str(opts.get("connector_type", "0")) != "0":
363
+ continue # gap-type connector: no claw arms
364
+ claw = _metal_um(opts.get("claw_length"), 30.0)
365
+ spacing = _metal_um(opts.get("ground_spacing_back") or opts.get("ground_spacing"), 5.0)
366
+ reach = arm + spacing - width / 2 # claw arms longer than this run into the side arms' gap
367
+ if claw >= reach:
368
+ out.append(
369
+ DrcIssue(
370
+ "design",
371
+ "pdk_claw",
372
+ f"{name}: claw {pad!r} (claw_length {claw:g} µm) reaches the side arms of the cross "
373
+ f"(cross_length {arm:g} µm); make cross_length ≥ {claw - spacing + width / 2 + 10:.0f} µm",
374
+ [],
375
+ [name],
376
+ )
377
+ )
378
+ return out
379
+
380
+
381
+ def _segment_faces(design, name: str, built: dict) -> list[str]:
382
+ """Chip face of each segment of a route's built polyline: the route's ``face_id`` (default ``1t1``), switched by
383
+ every waypoint whose ``params.face_id`` names another face, from that waypoint on (KQC ``WaveguideComposite``)."""
384
+ route = design.routes.get(name)
385
+ poly = built.get("polyline") or []
386
+ face = str((route.params or {}).get("face_id", "1t1")) if route is not None else "1t1"
387
+ faces = [face] * max(len(poly) - 1, 0)
388
+ if route is None:
389
+ return faces
390
+ for node, index in zip(route.nodes, built.get("waypoint_index") or []):
391
+ params = getattr(node, "params", None) or {}
392
+ if "face_id" in params:
393
+ for k in range(index, len(faces)):
394
+ faces[k] = str(params["face_id"])
395
+ return faces
396
+
397
+
398
+ def _route_overlaps(result) -> list[DrcIssue]:
399
+ """Built-geometry check between routes (the ``crossing`` rule sees only sharp node polylines, not meanders).
400
+
401
+ Per face, each route's centre conductor (``*_waveguide_path``) and gap etch (``*_base_metal_gap_wo_grid``) as
402
+ built. Pairs that share a port, or where one hangs off the other, legitimately meet and are skipped.
403
+ """
404
+ from kqcircuits.defaults import default_layers # pylint: disable=import-outside-toplevel
405
+ from kqcircuits.pya_resolver import pya # pylint: disable=import-outside-toplevel
406
+
407
+ from quantcore_circuits.design.schema import HangerEnd # pylint: disable=import-outside-toplevel
408
+
409
+ design, layout = result.design, result.layout
410
+ faces = sorted({k.split("_", 1)[0] for k in default_layers if k.endswith("_waveguide_path")})
411
+ layers = {
412
+ f: (
413
+ layout.layer(default_layers[f"{f}_waveguide_path"]),
414
+ layout.layer(default_layers[f"{f}_base_metal_gap_wo_grid"]),
415
+ )
416
+ for f in faces
417
+ if f"{f}_base_metal_gap_wo_grid" in default_layers
418
+ }
419
+ pad_layers = {
420
+ f: layout.layer(default_layers[f"{f}_airbridge_pads"])
421
+ for f in layers
422
+ if f"{f}_airbridge_pads" in default_layers
423
+ }
424
+ built: dict[str, dict[str, tuple]] = {}
425
+ pads: dict[str, dict[str, object]] = {}
426
+ for inst in result.cell.each_inst():
427
+ name = inst.property("id")
428
+ if name not in design.routes:
429
+ continue
430
+ cell = layout.cell(inst.cell_index)
431
+ for f, (path_l, gap_l) in layers.items():
432
+ path = pya.Region(cell.begin_shapes_rec(path_l)).transformed(inst.cplx_trans).merged()
433
+ gap = pya.Region(cell.begin_shapes_rec(gap_l)).transformed(inst.cplx_trans).merged()
434
+ if not path.is_empty() or not gap.is_empty():
435
+ built.setdefault(name, {})[f] = (path, gap)
436
+ if f in pad_layers:
437
+ pad = pya.Region(cell.begin_shapes_rec(pad_layers[f])).transformed(inst.cplx_trans).merged()
438
+ if not pad.is_empty():
439
+ pads.setdefault(name, {})[f] = pad
440
+ ends, hosts = {}, {}
441
+ for name, route in design.routes.items():
442
+ ends[name] = {e.split(".", 1)[0] for e in (route.from_, route.to) if isinstance(e, str)}
443
+ hosts[name] = {e.hanger for e in (route.from_, route.to) if isinstance(e, HangerEnd)}
444
+ out = []
445
+ names = sorted(built)
446
+ for a, by_face in sorted(pads.items()): # airbridges of route a landing on another route b
447
+ for b in names:
448
+ if b == a or ends[a] & ends[b]:
449
+ continue
450
+ for f, pad in by_face.items():
451
+ if f not in built[b]:
452
+ continue
453
+ path_b, gap_b = built[b][f]
454
+ hit = pad & (path_b + gap_b)
455
+ if not hit.is_empty():
456
+ c = hit.bbox().center().to_dtype(layout.dbu)
457
+ out.append(
458
+ DrcIssue(
459
+ "error",
460
+ "airbridge_short",
461
+ f"an airbridge pad of route {a} lands on route {b} ({f})",
462
+ [(c.x, c.y)],
463
+ [a, b],
464
+ )
465
+ )
466
+ break
467
+ for i, a in enumerate(names):
468
+ for b in names[i + 1 :]:
469
+ if ends[a] & ends[b] or b in hosts[a] or a in hosts[b]:
470
+ continue
471
+ for f in set(built[a]) & set(built[b]):
472
+ (pa, ga), (pb, gb) = built[a][f], built[b][f]
473
+ hit = pa & pb
474
+ if not hit.is_empty():
475
+ c = hit.bbox().center().to_dtype(layout.dbu)
476
+ out.append(
477
+ DrcIssue("error", "route_overlap", f"routes {a} and {b} overlap ({f})", [(c.x, c.y)], [a, b])
478
+ )
479
+ break
480
+ touch = ga.interacting(gb)
481
+ if not touch.is_empty():
482
+ c = (
483
+ (ga & gb).bbox().center().to_dtype(layout.dbu)
484
+ if not (ga & gb).is_empty()
485
+ else touch.bbox().center().to_dtype(layout.dbu)
486
+ )
487
+ out.append(
488
+ DrcIssue(
489
+ "warning",
490
+ "route_clearance",
491
+ f"routes {a} and {b} have no ground between their gaps ({f})",
492
+ [(c.x, c.y)],
493
+ [a, b],
494
+ )
495
+ )
496
+ break
497
+ out += _route_self_overlaps(result, layers)
498
+ out += _routes_over_components(result, layers, built, ends)
499
+ return out
500
+
501
+
502
+ def _route_width_um(result, name: str) -> float:
503
+ """The narrowest centre conductor ``a`` (µm) of a built route: its own ``a`` and any node's taper ``a``."""
504
+ widths = [float(result.plan.routes[name].params.get("a", 10.0))] if name in result.plan.routes else [10.0]
505
+ for node in getattr(result.design.routes[name], "nodes", None) or []:
506
+ if getattr(node, "a", None):
507
+ widths.append(float(node.a))
508
+ return min(widths)
509
+
510
+
511
+ def _route_self_overlaps(result, layers: dict) -> list[DrcIssue]:
512
+ """``route_self_overlap``: a route whose built centre conductor runs over itself: its nodes loop back across an
513
+ earlier straight, or a meander's turns land on another part of the same route. The pieces of a route
514
+ (straights, arcs, meander turns) meet edge to edge; where two of them share area, that area is the route lying on
515
+ itself when it is at least half a conductor width squared (two crossing parts share a full a², a bend tighter than
516
+ a/2 folds its inner edge over by less than (a/2)², which is not flagged). Taper pieces are left out: KQC draws a
517
+ taper's centre-line shape over the straight that follows it."""
518
+ from kqcircuits.pya_resolver import pya # pylint: disable=import-outside-toplevel
519
+
520
+ design, layout = result.design, result.layout
521
+ dbu2 = layout.dbu * layout.dbu
522
+ out = []
523
+ for inst in result.cell.each_inst():
524
+ name = inst.property("id")
525
+ if name not in design.routes:
526
+ continue
527
+ least = _route_width_um(result, name) ** 2 / 2
528
+ for f, (path_l, _gap_l) in layers.items():
529
+ pieces = pya.Region()
530
+ it = layout.cell(inst.cell_index).begin_shapes_rec(path_l)
531
+ while not it.at_end():
532
+ shape = it.shape()
533
+ if (shape.is_polygon() or shape.is_path() or shape.is_box()) and "taper" not in it.cell().name.lower():
534
+ pieces.insert(shape.polygon.transformed(it.trans()))
535
+ it.next()
536
+ if pieces.count() < 2:
537
+ continue
538
+ twice = pieces.merged(False, 2) # covered by two pieces or more (wrap count ≥ 2)
539
+ hits = [poly for poly in twice.each() if poly.area() * dbu2 >= least]
540
+ if hits:
541
+ area = sum(poly.area() for poly in hits) * dbu2
542
+ c = hits[0].transformed(inst.cplx_trans).bbox().center().to_dtype(layout.dbu)
543
+ out.append(DrcIssue("error", "route_self_overlap",
544
+ f"route {name} runs over itself ({area:.0f} µm² of its centre conductor lie on "
545
+ f"another part of it, {len(hits)} place(s), {f}): move its nodes or meander",
546
+ [(c.x, c.y)], [name]))
547
+ break
548
+ return out
549
+
550
+
551
+ def _routes_over_components(result, layers: dict, built: dict, ends: dict) -> list[DrcIssue]:
552
+ """``route_over_component``: a route's conductor or gap overlaps the etch (gaps, pocket) of a component that is not
553
+ one of its ends: the route runs across that component (cuts into its pocket, shorts its island or pads)."""
554
+ from kqcircuits.pya_resolver import pya # pylint: disable=import-outside-toplevel
555
+
556
+ design, layout = result.design, result.layout
557
+ dbu2 = layout.dbu * layout.dbu
558
+ comps = [(i.property("id"), i) for i in result.cell.each_inst() if i.property("id") in design.instances]
559
+ etch: dict = {}
560
+ out = []
561
+ for name in sorted(built):
562
+ for f, (path, gap) in built[name].items():
563
+ geo = path + gap
564
+ box = geo.bbox()
565
+ hit_any = False
566
+ for cname, inst in comps:
567
+ if cname in ends.get(name, ()) or not inst.bbox().overlaps(box):
568
+ continue
569
+ key = (cname, f)
570
+ if key not in etch:
571
+ etch[key] = pya.Region(layout.cell(inst.cell_index).begin_shapes_rec(layers[f][1])).transformed(
572
+ inst.cplx_trans).merged()
573
+ hit = geo & etch[key]
574
+ if hit.area() * dbu2 > 0.01:
575
+ c = hit.bbox().center().to_dtype(layout.dbu)
576
+ out.append(DrcIssue("error", "route_over_component",
577
+ f"route {name} runs over {cname} ({design.instances[cname].cell}, {f}), "
578
+ "which is not one of its ends", [(c.x, c.y)], [name, cname]))
579
+ hit_any = True
580
+ if hit_any:
581
+ break
582
+ return out
583
+
584
+
585
+ def _conductor_opens(result, step: float = 1.0) -> list[DrcIssue]:
586
+ """Galvanic continuity where a route meets a component port (negative mask: metal = not etched).
587
+
588
+ The point ``step`` µm inside the component and the point ``step`` µm along the route, both on the port's centre
589
+ line, must lie in the same metal polygon. KQC's netlist extraction joins port *texts*, so it cannot see etch that
590
+ separates two touching ports. Ports without a direction (junction ends), chip launchers and points that are not
591
+ metal inside the component (nothing to judge) are skipped.
592
+ """
593
+ from kqcircuits.pya_resolver import pya # pylint: disable=import-outside-toplevel
594
+
595
+ design, layout = result.design, result.layout
596
+ dbu = layout.dbu
597
+ gap = pya.Region(result.cell.begin_shapes_rec(layout.layer(pya.LayerInfo(130, 1)))) # 1t1_base_metal_gap_wo_grid
598
+ ports = result.plan.all_ports()
599
+ out = []
600
+ for rname, route in design.routes.items():
601
+ if rname in result.plan.failed:
602
+ continue
603
+ for end in (route.from_, route.to):
604
+ if not isinstance(end, str) or end.split(".", 1)[0] == "chip":
605
+ continue
606
+ p = ports.get(end)
607
+ if p is None or p.dir is None:
608
+ continue
609
+ half = (p.a or 10.0) / 2 + (p.b or 6.0) + 5 * step
610
+ window = pya.DBox(p.pos.x - half, p.pos.y - half, p.pos.x + half, p.pos.y + half).to_itype(dbu)
611
+ metal = (pya.Region(window) - (gap & pya.Region(window))).merged()
612
+
613
+ def polygon_at(pt, metal=metal):
614
+ ip = pt.to_itype(dbu)
615
+ return next((i for i, poly in enumerate(metal.each()) if poly.inside(ip)), None)
616
+
617
+ inside, along = polygon_at(p.pos - p.dir * step), polygon_at(p.pos + p.dir * step)
618
+ if inside is not None and along != inside:
619
+ out.append(
620
+ DrcIssue(
621
+ "error",
622
+ "open_conductor",
623
+ f"route {rname} is galvanically open at {end} (etch between the port and the route)",
624
+ [(p.pos.x, p.pos.y)],
625
+ [end, rname],
626
+ )
627
+ )
628
+ return out
629
+
630
+
631
+ def device_id_block(result):
632
+ """Where the chip put its device ID (``qcc_device_id_p1/p2`` refpoints, µm), or None (no frame / older build)."""
633
+ from kqcircuits.pya_resolver import pya # pylint: disable=import-outside-toplevel
634
+
635
+ refp = getattr(result, "refpoints", None) or {}
636
+ if "qcc_device_id_none" in refp:
637
+ return False # the chip has no device ID (optional, no room): nothing to keep free
638
+ p1, p2 = refp.get("qcc_device_id_p1"), refp.get("qcc_device_id_p2")
639
+ return pya.DBox(p1, p2) if p1 is not None and p2 is not None else None
640
+
641
+
642
+ def _frame_issues(design, boxes: dict, routes: dict, device_id=None) -> list[DrcIssue]:
643
+ """PDK die frame: components inside the design area, clear of the marker areas and the device-ID block."""
644
+ from kqcircuits.pya_resolver import pya # pylint: disable=import-outside-toplevel
645
+
646
+ from quantcore_circuits.assembly.plan import die_frame # pylint: disable=import-outside-toplevel
647
+ from quantcore_circuits.layouts.chips.frame import design_area, keepouts # pylint: disable=C0415
648
+
649
+ frame = die_frame(design)
650
+ if frame is None:
651
+ return []
652
+ chip = pya.DBox(*design.chip.box)
653
+ area, reserved = design_area(chip, frame), keepouts(chip, frame, device_id)
654
+ out = []
655
+ for name, b in boxes.items():
656
+ box = pya.DBox(*b)
657
+ edge_ok = _edge_component(design.instances[name].cell) if name in design.instances else False
658
+ if not edge_ok and (not area.contains(box.p1) or not area.contains(box.p2)):
659
+ out.append(
660
+ DrcIssue(
661
+ "warning",
662
+ "frame_margin",
663
+ f"{name} reaches into the {frame.margin:g} µm die margin (dicing markers)",
664
+ [(box.center().x, box.center().y)],
665
+ [name],
666
+ )
667
+ )
668
+ for key, k in reserved.items():
669
+ if box.overlaps(k):
670
+ out.append(
671
+ DrcIssue(
672
+ "warning", "frame_keepout", f"{name} overlaps the {key}", [(k.center().x, k.center().y)], [name]
673
+ )
674
+ )
675
+ for name, r in routes.items():
676
+ pts = [pya.DPoint(*p) for p in r["polyline"]]
677
+ for key, k in reserved.items():
678
+ hit = next((p for p in pts if k.contains(p)), None)
679
+ if hit is not None:
680
+ out.append(
681
+ DrcIssue("warning", "frame_keepout", f"route {name} crosses the {key}", [(hit.x, hit.y)], [name])
682
+ )
683
+ return out