gdstk backend: close API gaps so the tutorials run - #104
Open
carloscl03 wants to merge 4 commits into
Open
Conversation
Running the tutorial notebooks under GLAYOUT_BACKEND=gdstk fails almost immediately: 4 of 14 pass. Two reasons, one on each side. The notebooks import Component, rectangle, boolean and cell straight from gdsfactory instead of glayout.backend, so they bypass the backend selection entirely. Under the default backend both names resolve to the same class and nobody notices; under gdstk, gdsfactory's add_ref() gets a gdstk Component and rejects it. Symbols glayout.backend does not re-export (text_freetype, array) are left on gdsfactory. The gdstk ComponentReference/Component are also missing pieces of the gdsfactory surface that glayout's own cells and the tutorials use: movex/movey took a bare delta; move() already accepted destination= ref.name read-only, but cells label placements (ref.name = "pfet_2") ref.x / ref.y had xmin/xmax/ymin/ymax but not the centre accessors write_gds required a filename and ignored gdsdir= Component.show absent ref.name stores the label on the reference rather than renaming the target cell, which would rename every other placement of it too. Tutorial notebooks under gdstk: 4/14 -> 10/14. The three BJT tutorials still fail (Component indexing, add_ref(columns=)) and are untouched here. Notebooks under the default gdsfactory backend are unaffected: the imports resolve to the same objects.
Every vertex of a gdstk-generated layout lands off-grid on gf180. The DRC
reports it on all of them -- 1301 violations on the LIF cell used to check
this, split across contact_OFFGRID x348, via1_OFFGRID x276,
metal1_OFFGRID x252, metal2_OFFGRID x132 and comp_OFFGRID x60.
snap_to_grid() took a bare `nm: int = 1` default. gdsfactory's version reads
the pitch from the active PDK instead:
nm = int(get_grid_size() * 1000 * grid_factor)
which is 5 nm on gf180. Rounding a 5 nm process to 1 nm produces values like
10.246 where the process wants 10.245, and every one of them is a violation.
Two pieces were missing. Pdk.activate() was a no-op, so nothing recorded
which PDK was active; and grid_size kept the class default of 0.001 because
gdsfactory used to fill it in from its own PDK database on activate. The
real pitch is already in gds_write_settings.precision (5e-9 m on both gf180
and sky130), so activate() now derives grid_size from it and registers the
PDK for snap_to_grid to read. `nm=` still overrides when a caller wants a
specific pitch.
After: 0 of 1228 vertices off-grid, same as the gdsfactory backend, and the
1301 OFFGRID violations are gone. snap_to_2xgrid(10.2463) returns 10.25 on
both backends now. DRC on diff_pair, current_mirror_nfet and
transmission_gate under gdsfactory is unchanged.
move(destination=) traducia respecto al centro del bbox en vez de (0,0), que es el default de gdsfactory. c_route coloca sus rectangulos de extension con move(destination=...) seguido de movex relativos, asi que la ruta se desplazaba medio rectangulo: la neurona LIF salia 32.4 um de ancho en vez de 29.9 y con 54 violaciones M2.2a de mas. get_ports_list devolvia el orden del dict; gdsfactory ordena clockwise (oeste, norte, este, sur). Las celdas buscan puertos por subcadena, asi que el orden cambia que puerto se enruta. Con ambos, neurona.ipynb da 1168.6 um2 y 31 violaciones en los dos backends, identico a gdsfactory.
capmet apuntaba a CAP_MK (117,5), que es solo un marcador. El MIM real es FuseTop (75,0), que estaba en el archivo pero comentado. Sin dielectrico, el via_array que deberia contactar la placa superior contactaba la inferior: 187 via2 uniendo met2 con met3. Extraido con magic, el cap salia como un unico nodo flotante. Ahora salen dos placas con capacitancia entre ellas. sky130 ya apuntaba a capm, asi que gf180 era el caso desviado. Ademas CAP_MK tiene que envolver al FuseTop (regla MIM.7), asi que mimcap() dibuja el marcador cuando el pdk mapea capmet_mk.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Running the tutorial notebooks under
GLAYOUT_BACKEND=gdstkfails almostimmediately — 4 of 14 pass. Two causes, one on each side.
The notebooks bypass the backend selection
Under the default backend this resolves to the same class as
glayout.backend.Component, so nobody notices. Under gdstk, gdsfactory'sadd_ref()receives a gdstkComponentand rejects it:Redirected
Component,rectangle,rectangular_ring,booleanandcelltoglayout.backend. Symbols it does not re-export(
text_freetype,array) stay on gdsfactory. Imports only — no cellcontent touched.
The gdstk backend is missing parts of the surface
Each of these is used by glayout's own cells or by the tutorials:
movex/moveydestination=too, likemove()already hadref.nameref.name = "pfet_2")ref.x/ref.yxmin/xmaxwrite_gdsfilenamerequired, nogdsdirComponent.showref.namestores the label on the reference rather than renaming thetarget cell — renaming the cell would rename every other placement of it.
Result
The three BJT tutorials still fail on
Componentindexing andadd_ref(columns=); those need more than a signature and are left alone.Notebooks under the default gdsfactory backend are unaffected — the
redirected imports resolve to the same objects.
Worth noting for #100:
glayout_opamp.ipynbandGLayout_Cells.ipynb,which currently time out at 180 s under gdsfactory, complete in 89 s and
53 s under gdstk.