prep-ic 0.2.0__tar.gz → 0.2.1__tar.gz

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 (57) hide show
  1. {prep_ic-0.2.0 → prep_ic-0.2.1}/CITATION.cff +1 -1
  2. {prep_ic-0.2.0 → prep_ic-0.2.1}/PKG-INFO +7 -4
  3. {prep_ic-0.2.0 → prep_ic-0.2.1}/README.md +6 -3
  4. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/__init__.py +1 -1
  5. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/cli.py +16 -5
  6. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/data/pdks/ihp-sg13cmos5l.json +14 -0
  7. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/data/pdks/ihp-sg13g2.json +14 -0
  8. prep_ic-0.2.1/src/prep_ic/formats/files.py +71 -0
  9. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/formats/librelane.py +87 -13
  10. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/formats/pinlist.py +13 -4
  11. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/formats/svg.py +2 -2
  12. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/model/constants.py +1 -1
  13. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/model/layout.py +13 -8
  14. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/model/parse.py +9 -8
  15. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/model/pdk.py +31 -11
  16. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic.egg-info/PKG-INFO +7 -4
  17. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic.egg-info/SOURCES.txt +1 -0
  18. {prep_ic-0.2.0 → prep_ic-0.2.1}/tests/test_chip.py +11 -0
  19. {prep_ic-0.2.0 → prep_ic-0.2.1}/tests/test_formats.py +39 -0
  20. {prep_ic-0.2.0 → prep_ic-0.2.1}/tests/test_pdk.py +121 -0
  21. {prep_ic-0.2.0 → prep_ic-0.2.1}/tests/test_pdk_lef.py +2 -2
  22. {prep_ic-0.2.0 → prep_ic-0.2.1}/LICENSE +0 -0
  23. {prep_ic-0.2.0 → prep_ic-0.2.1}/LICENSES/Apache-2.0.txt +0 -0
  24. {prep_ic-0.2.0 → prep_ic-0.2.1}/MANIFEST.in +0 -0
  25. {prep_ic-0.2.0 → prep_ic-0.2.1}/REUSE.toml +0 -0
  26. {prep_ic-0.2.0 → prep_ic-0.2.1}/pyproject.toml +0 -0
  27. {prep_ic-0.2.0 → prep_ic-0.2.1}/setup.cfg +0 -0
  28. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/__main__.py +0 -0
  29. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/data/packages.json +0 -0
  30. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/data/pdks/gf180mcud.json +0 -0
  31. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/data/pdks/sky130a.json +0 -0
  32. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/formats/__init__.py +0 -0
  33. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/formats/lef.py +0 -0
  34. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/formats/project_file.py +0 -0
  35. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/gui/__init__.py +0 -0
  36. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/gui/about_dialog.py +0 -0
  37. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/gui/app.py +0 -0
  38. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/gui/assets/prep_ic_logo.svg +0 -0
  39. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/gui/chip_view.py +0 -0
  40. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/gui/macro_panel.py +0 -0
  41. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/gui/main_window.py +0 -0
  42. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/gui/qt.py +0 -0
  43. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/gui/scene.py +0 -0
  44. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/gui/widgets.py +0 -0
  45. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/model/__init__.py +0 -0
  46. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/model/chip.py +0 -0
  47. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/model/floorplan.py +0 -0
  48. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/model/project.py +0 -0
  49. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic/style.py +0 -0
  50. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic.egg-info/dependency_links.txt +0 -0
  51. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic.egg-info/entry_points.txt +0 -0
  52. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic.egg-info/requires.txt +0 -0
  53. {prep_ic-0.2.0 → prep_ic-0.2.1}/src/prep_ic.egg-info/top_level.txt +0 -0
  54. {prep_ic-0.2.0 → prep_ic-0.2.1}/tests/test_floorplan.py +0 -0
  55. {prep_ic-0.2.0 → prep_ic-0.2.1}/tests/test_gui.py +0 -0
  56. {prep_ic-0.2.0 → prep_ic-0.2.1}/tests/test_model.py +0 -0
  57. {prep_ic-0.2.0 → prep_ic-0.2.1}/tests/test_qt_essentials.py +0 -0
@@ -8,7 +8,7 @@ authors:
8
8
  given-names: Simon
9
9
  orcid: https://orcid.org/0009-0001-5994-5477
10
10
  title: "GitHub Repository of PREP-IC: Pinout, Ring and Early floorplan Planner for ICs"
11
- date-released: 2026-11-13
11
+ date-released: 2026-11-14
12
12
  url: https://github.com/iic-jku/prep-ic
13
13
  license: Apache-2.0
14
14
  identifiers:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: prep-ic
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: PREP-IC (Pinout, Ring and Early floorplan Planner for ICs): plan IC pad ring pinouts with live die sizing, RF/GSG pad groups and exports.
5
5
  Author-email: Maximilian Golser <maximilian.golser@jku.at>, Simon Dorrer <simon.dorrer@jku.at>
6
6
  License-Expression: Apache-2.0
@@ -101,6 +101,7 @@ The code is split into a pure-Python, Qt-free model and exporters (`prep_ic.mode
101
101
  ├─ 📁 src/prep_ic/ the package (pip-installable)
102
102
  │ ├─ 📁 data/ PDK profiles (pdks/*.json) and the package library (packages.json)
103
103
  │ ├─ 📁 formats/ project files and exports, no Qt
104
+ │ │ ├─ files.py writes the files of an export all or none
104
105
  │ │ ├─ lef.py minimal LEF reader: macro size and pins
105
106
  │ │ ├─ librelane.py pad ring config, pad_cfg.tcl, chip_top.sv, macros.yaml, bondplan PINOUT
106
107
  │ │ ├─ pinlist.py pin list as CSV or tab-separated text
@@ -227,7 +228,7 @@ One line per entry. Each side lists its pads as seen on the die: top and bottom
227
228
  | `LO [gsgsg]` | differential: GND, LO_P, GND, LO_N, GND |
228
229
  | `NAME [in\|out\|tri\|io\|analog\|vdd\|vss\|iovdd\|iovss\|none]` | IO function, selects the IO cell (default guessed from name and type) |
229
230
  | `NAME [16mA]` | drive strength of output, tristate and bidirectional cells |
230
- | `NAME [schmitt]`, `NAME [noesd]` | another IO cell of the same function, where the PDK has one: a Schmitt trigger input, an analog pad without ESD clamp |
231
+ | `NAME [schmitt]`, `NAME [noesd]`, `NAME [rfpad]` | another IO cell of the same function, where the PDK has one: a Schmitt trigger input, an analog pad without ESD clamp, the RF pad of the IHP chip templates |
231
232
  | `NAME [lock]` | locked pad: it can no longer be dragged and *Optimize Pad Order* leaves it in place |
232
233
  | `=== NAME` | power split: cuts the IO ring here and starts power domain `NAME` |
233
234
 
@@ -341,7 +342,7 @@ The GUI tests run offscreen and are skipped when Qt is not installed.
341
342
  | `prep-ic export chip.json --librelane DIR` | write the LibreLane files into `DIR` (needs a PDK in the project) |
342
343
  | `prep-ic check chip.json` | list the findings of the project |
343
344
 
344
- The `export` options combine, e.g. `prep-ic export chip.json --csv pins.csv --svg ring.svg`. Each written LibreLane file is printed, and all findings go to stderr. Exit code 0 from `export` says only that the files were written, so gate a script on `check`: it prints one finding per line or `no findings`, and exits 0 when clean, 1 with findings and 2 when the check did not run. A finding is a layout warning, an entry of the project file that could not be read, a macro LEF that is gone, a marked pin no longer in the LEF, or what `prep.analyse` reports: unknown tags and options, bad power domain names, crossings, long analog flylines, pins without a pad, split differential pairs, sensitive pads next to noisy ones, macro and supply checks. Both commands run without Qt. From a source checkout without installing, use `python -m prep_ic` with `src` on the Python path in place of `prep-ic`.
345
+ The `export` options combine, e.g. `prep-ic export chip.json --csv pins.csv --svg ring.svg`. Each written LibreLane file is printed, and all findings go to stderr. `export` builds every output before it writes the first and writes all files or none, so a failure leaves the files as they were. Exit code 0 from `export` says only that the files were written, so gate a script on `check`: it prints one finding per line or `no findings`, and exits 0 when clean, 1 with findings and 2 when the check did not run. A finding is a layout warning, an entry of the project file that could not be read, a macro LEF that is gone, a marked pin no longer in the LEF, or what `prep.analyse` reports: unknown tags and options, bad power domain names, crossings, long analog flylines, pins without a pad, split differential pairs, sensitive pads next to noisy ones, macro and supply checks. Both commands run without Qt. From a source checkout without installing, use `python -m prep_ic` with `src` on the Python path in place of `prep-ic`.
345
346
 
346
347
 
347
348
  ## Supported PDKs and Packages
@@ -370,7 +371,7 @@ The IO function of a pad selects its cell (`<lib>` is `sg13g2` or `sg13cmos5l`,
370
371
  | `[out]` | `<lib>_IOPadOut<drive>mA` | `gpiov2_pad` | `bi_24t` |
371
372
  | `[tri]` | `<lib>_IOPadTriOut<drive>mA` | `gpiov2_pad` | `bi_24t` |
372
373
  | `[io]` | `<lib>_IOPadInOut<drive>mA` | `gpiov2_pad` | `bi_24t` |
373
- | `[analog]` | `<lib>_IOPadAnalog` | `analog_esd_pad`, with `[noesd]` `analog_noesd_pad` | `asig_5p0` |
374
+ | `[analog]` | `<lib>_IOPadAnalog`, with `[rfpad]` `<lib>_ip__rfpad_70x70` | `analog_esd_pad`, with `[noesd]` `analog_noesd_pad` | `asig_5p0` |
374
375
  | `[vdd]`, `[vss]` | `<lib>_IOPadVdd`, `<lib>_IOPadVss` | `vccd_lvc_clamped_pad`, `vssd_lvc_clamped_pad` | `dvdd`, `dvss` |
375
376
  | `[iovdd]`, `[iovss]` | `<lib>_IOPadIOVdd`, `<lib>_IOPadIOVss` | `vddio_hvc_clamped_pad`, `vssio_hvc_clamped_pad` | `dvdd`, `dvss` |
376
377
  | `[none]` | no IO cell | no IO cell | no IO cell |
@@ -378,6 +379,8 @@ The IO function of a pad selects its cell (`<lib>` is `sg13g2` or `sg13cmos5l`,
378
379
 
379
380
  The control pins of the sky130A and gf180mcuD cells are tied per function in `chip_top.sv`, so the core ports are the same as for IHP.
380
381
 
382
+ On IHP, `[rfpad]` picks the RF pad of the chip templates instead of `IOPadAnalog`, for an `[analog]` pad or the signal pad of a group (`RF [gsg] [rfpad]`): `ip/sg13g2_ip__rfpad_70x70` of [ihp-sg13g2-ams-chip-template](https://github.com/iic-jku/ihp-sg13g2-ams-chip-template) and `ip/sg13cmos5l_ip__rfpad_70x70` of [ihp-sg13cmos5l-ams-chip-template](https://github.com/iic-jku/ihp-sg13cmos5l-ams-chip-template). It is one 80 × 250 µm cell with its own bond pad, ESD and shield, and no series resistor, so the core is wired to `padbare` instead of `padres`. Its bond pad sits where the bondpads of the other cells go, and `pad_cfg.tcl` moves the cell outward by the bondpad depth, checks that its supplies are on nets, places its top-level terminal and gives it no bondpad. `padring_config.yaml` names the four views to add to your `config.yaml`, in `PAD_LEFS`, `PAD_VERILOG_MODELS`, `EXTRA_GDS` and every corner of `LIB`. The README of the IP has the details.
383
+
381
384
  On sky130A, PREP-IC adds two 20 µm connect cells in front of the first IO supply pad. They tie `VCCHIB` to `VCCD`, `VSWITCH` and `VDDA` to `VDDIO`, and `VSSA` to `VSSIO`, and that side grows by 40 µm. On gf180mcuD, the `dvdd` and `dvss` pads short their two supply rings, so the IO supply and the core supply are one net (`VDD`, `VSS`).
382
385
 
383
386
  [`examples/`](https://github.com/iic-jku/prep-ic/tree/main/examples) has one project per wafer.space gf180mcuD slot (`wafer_space_slot_*.json`) with the die of the slot, its pad order and positions, and the supply pads locked. Name your signals and save it under a new name. Three slots put an analog pad next to a digital one, which `prep-ic check` reports as `Sensitive pad next to noisy pad`.
@@ -71,6 +71,7 @@ The code is split into a pure-Python, Qt-free model and exporters (`prep_ic.mode
71
71
  ├─ 📁 src/prep_ic/ the package (pip-installable)
72
72
  │ ├─ 📁 data/ PDK profiles (pdks/*.json) and the package library (packages.json)
73
73
  │ ├─ 📁 formats/ project files and exports, no Qt
74
+ │ │ ├─ files.py writes the files of an export all or none
74
75
  │ │ ├─ lef.py minimal LEF reader: macro size and pins
75
76
  │ │ ├─ librelane.py pad ring config, pad_cfg.tcl, chip_top.sv, macros.yaml, bondplan PINOUT
76
77
  │ │ ├─ pinlist.py pin list as CSV or tab-separated text
@@ -197,7 +198,7 @@ One line per entry. Each side lists its pads as seen on the die: top and bottom
197
198
  | `LO [gsgsg]` | differential: GND, LO_P, GND, LO_N, GND |
198
199
  | `NAME [in\|out\|tri\|io\|analog\|vdd\|vss\|iovdd\|iovss\|none]` | IO function, selects the IO cell (default guessed from name and type) |
199
200
  | `NAME [16mA]` | drive strength of output, tristate and bidirectional cells |
200
- | `NAME [schmitt]`, `NAME [noesd]` | another IO cell of the same function, where the PDK has one: a Schmitt trigger input, an analog pad without ESD clamp |
201
+ | `NAME [schmitt]`, `NAME [noesd]`, `NAME [rfpad]` | another IO cell of the same function, where the PDK has one: a Schmitt trigger input, an analog pad without ESD clamp, the RF pad of the IHP chip templates |
201
202
  | `NAME [lock]` | locked pad: it can no longer be dragged and *Optimize Pad Order* leaves it in place |
202
203
  | `=== NAME` | power split: cuts the IO ring here and starts power domain `NAME` |
203
204
 
@@ -311,7 +312,7 @@ The GUI tests run offscreen and are skipped when Qt is not installed.
311
312
  | `prep-ic export chip.json --librelane DIR` | write the LibreLane files into `DIR` (needs a PDK in the project) |
312
313
  | `prep-ic check chip.json` | list the findings of the project |
313
314
 
314
- The `export` options combine, e.g. `prep-ic export chip.json --csv pins.csv --svg ring.svg`. Each written LibreLane file is printed, and all findings go to stderr. Exit code 0 from `export` says only that the files were written, so gate a script on `check`: it prints one finding per line or `no findings`, and exits 0 when clean, 1 with findings and 2 when the check did not run. A finding is a layout warning, an entry of the project file that could not be read, a macro LEF that is gone, a marked pin no longer in the LEF, or what `prep.analyse` reports: unknown tags and options, bad power domain names, crossings, long analog flylines, pins without a pad, split differential pairs, sensitive pads next to noisy ones, macro and supply checks. Both commands run without Qt. From a source checkout without installing, use `python -m prep_ic` with `src` on the Python path in place of `prep-ic`.
315
+ The `export` options combine, e.g. `prep-ic export chip.json --csv pins.csv --svg ring.svg`. Each written LibreLane file is printed, and all findings go to stderr. `export` builds every output before it writes the first and writes all files or none, so a failure leaves the files as they were. Exit code 0 from `export` says only that the files were written, so gate a script on `check`: it prints one finding per line or `no findings`, and exits 0 when clean, 1 with findings and 2 when the check did not run. A finding is a layout warning, an entry of the project file that could not be read, a macro LEF that is gone, a marked pin no longer in the LEF, or what `prep.analyse` reports: unknown tags and options, bad power domain names, crossings, long analog flylines, pins without a pad, split differential pairs, sensitive pads next to noisy ones, macro and supply checks. Both commands run without Qt. From a source checkout without installing, use `python -m prep_ic` with `src` on the Python path in place of `prep-ic`.
315
316
 
316
317
 
317
318
  ## Supported PDKs and Packages
@@ -340,7 +341,7 @@ The IO function of a pad selects its cell (`<lib>` is `sg13g2` or `sg13cmos5l`,
340
341
  | `[out]` | `<lib>_IOPadOut<drive>mA` | `gpiov2_pad` | `bi_24t` |
341
342
  | `[tri]` | `<lib>_IOPadTriOut<drive>mA` | `gpiov2_pad` | `bi_24t` |
342
343
  | `[io]` | `<lib>_IOPadInOut<drive>mA` | `gpiov2_pad` | `bi_24t` |
343
- | `[analog]` | `<lib>_IOPadAnalog` | `analog_esd_pad`, with `[noesd]` `analog_noesd_pad` | `asig_5p0` |
344
+ | `[analog]` | `<lib>_IOPadAnalog`, with `[rfpad]` `<lib>_ip__rfpad_70x70` | `analog_esd_pad`, with `[noesd]` `analog_noesd_pad` | `asig_5p0` |
344
345
  | `[vdd]`, `[vss]` | `<lib>_IOPadVdd`, `<lib>_IOPadVss` | `vccd_lvc_clamped_pad`, `vssd_lvc_clamped_pad` | `dvdd`, `dvss` |
345
346
  | `[iovdd]`, `[iovss]` | `<lib>_IOPadIOVdd`, `<lib>_IOPadIOVss` | `vddio_hvc_clamped_pad`, `vssio_hvc_clamped_pad` | `dvdd`, `dvss` |
346
347
  | `[none]` | no IO cell | no IO cell | no IO cell |
@@ -348,6 +349,8 @@ The IO function of a pad selects its cell (`<lib>` is `sg13g2` or `sg13cmos5l`,
348
349
 
349
350
  The control pins of the sky130A and gf180mcuD cells are tied per function in `chip_top.sv`, so the core ports are the same as for IHP.
350
351
 
352
+ On IHP, `[rfpad]` picks the RF pad of the chip templates instead of `IOPadAnalog`, for an `[analog]` pad or the signal pad of a group (`RF [gsg] [rfpad]`): `ip/sg13g2_ip__rfpad_70x70` of [ihp-sg13g2-ams-chip-template](https://github.com/iic-jku/ihp-sg13g2-ams-chip-template) and `ip/sg13cmos5l_ip__rfpad_70x70` of [ihp-sg13cmos5l-ams-chip-template](https://github.com/iic-jku/ihp-sg13cmos5l-ams-chip-template). It is one 80 × 250 µm cell with its own bond pad, ESD and shield, and no series resistor, so the core is wired to `padbare` instead of `padres`. Its bond pad sits where the bondpads of the other cells go, and `pad_cfg.tcl` moves the cell outward by the bondpad depth, checks that its supplies are on nets, places its top-level terminal and gives it no bondpad. `padring_config.yaml` names the four views to add to your `config.yaml`, in `PAD_LEFS`, `PAD_VERILOG_MODELS`, `EXTRA_GDS` and every corner of `LIB`. The README of the IP has the details.
353
+
351
354
  On sky130A, PREP-IC adds two 20 µm connect cells in front of the first IO supply pad. They tie `VCCHIB` to `VCCD`, `VSWITCH` and `VDDA` to `VDDIO`, and `VSSA` to `VSSIO`, and that side grows by 40 µm. On gf180mcuD, the `dvdd` and `dvss` pads short their two supply rings, so the IO supply and the core supply are one net (`VDD`, `VSS`).
352
355
 
353
356
  [`examples/`](https://github.com/iic-jku/prep-ic/tree/main/examples) has one project per wafer.space gf180mcuD slot (`wafer_space_slot_*.json`) with the die of the slot, its pad order and positions, and the supply pads locked. Name your signals and save it under a new name. Three slots put an analog pad next to a digital one, which `prep-ic check` reports as `Sensitive pad next to noisy pad`.
@@ -22,7 +22,7 @@ Scripting API (no Qt needed)::
22
22
  """
23
23
 
24
24
  # defined before the imports: submodules import them
25
- __version__ = "0.2.0"
25
+ __version__ = "0.2.1"
26
26
  APP_NAME = "PREP-IC"
27
27
 
28
28
  from .formats.lef import read_lef
@@ -9,8 +9,11 @@
9
9
 
10
10
  import argparse
11
11
  import sys
12
+ from pathlib import Path
12
13
 
13
- from . import APP_NAME, __version__, export_csv, export_librelane, export_svg, findings, load
14
+ from . import APP_NAME, __version__, findings, librelane_files, load, to_svg
15
+ from .formats.files import text_bytes, write_all
16
+ from .formats.pinlist import csv_bytes
14
17
 
15
18
 
16
19
  def _print(text):
@@ -42,13 +45,21 @@ def _export(argv):
42
45
  ap.error("nothing to export, give --csv, --svg and/or --librelane")
43
46
  try:
44
47
  project = load(args.project)
48
+ layout = project.layout()
49
+ files, dirs, ll = {}, [], [] # every output is built before the first is written: all or none
45
50
  if args.csv:
46
- export_csv(project, args.csv)
51
+ files[Path(args.csv)] = csv_bytes(layout)
47
52
  if args.svg:
48
- export_svg(project, args.svg)
53
+ files[Path(args.svg)] = text_bytes(to_svg(layout))
49
54
  if args.librelane:
50
- for path in export_librelane(project, args.librelane, source=args.project):
51
- _inform(f"wrote {path}")
55
+ d = Path(args.librelane)
56
+ texts = librelane_files(project, args.project, out_dir=d)
57
+ ll = [d / name for name in texts]
58
+ files.update({d / name: text_bytes(text) for name, text in texts.items()})
59
+ dirs.append(d)
60
+ write_all(files, make_dirs=dirs)
61
+ for path in ll:
62
+ _inform(f"wrote {path}")
52
63
  except (OSError, ValueError) as e:
53
64
  print(f"error: {e}", file=sys.stderr)
54
65
  return 1
@@ -79,6 +79,20 @@
79
79
  "pins": {
80
80
  "pad": "pad",
81
81
  "analog": "padres"
82
+ },
83
+ "variants": {
84
+ "rfpad": {
85
+ "master": "sg13cmos5l_ip__rfpad_70x70",
86
+ "pins": {
87
+ "pad": "pad",
88
+ "analog": "padbare"
89
+ },
90
+ "own_bondpad": true,
91
+ "ip": {
92
+ "dir": "ip/sg13cmos5l_ip__rfpad_70x70",
93
+ "source": "https://github.com/iic-jku/ihp-sg13cmos5l-ams-chip-template"
94
+ }
95
+ }
82
96
  }
83
97
  },
84
98
  "vdd": {
@@ -79,6 +79,20 @@
79
79
  "pins": {
80
80
  "pad": "pad",
81
81
  "analog": "padres"
82
+ },
83
+ "variants": {
84
+ "rfpad": {
85
+ "master": "sg13g2_ip__rfpad_70x70",
86
+ "pins": {
87
+ "pad": "pad",
88
+ "analog": "padbare"
89
+ },
90
+ "own_bondpad": true,
91
+ "ip": {
92
+ "dir": "ip/sg13g2_ip__rfpad_70x70",
93
+ "source": "https://github.com/iic-jku/ihp-sg13g2-ams-chip-template"
94
+ }
95
+ }
82
96
  }
83
97
  },
84
98
  "vdd": {
@@ -0,0 +1,71 @@
1
+ # SPDX-FileCopyrightText: 2026 Maximilian Golser and Simon Dorrer
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ """Write a set of output files together: all of them or none."""
4
+
5
+ import errno
6
+ import os
7
+ from pathlib import Path
8
+
9
+
10
+ def text_bytes(text):
11
+ """The bytes a text-mode write gives, with the platform's line ends."""
12
+ return text.replace("\n", os.linesep).encode("utf-8")
13
+
14
+
15
+ def _remove(path):
16
+ try:
17
+ path.unlink()
18
+ except OSError:
19
+ pass
20
+
21
+
22
+ def write_all(files, make_dirs=()):
23
+ """Write ``{path: bytes}``, creating the folders in ``make_dirs`` first.
24
+
25
+ Every file is written to a temporary name beside its target, the old targets are moved aside, the new files
26
+ renamed into place, and only then the old ones deleted. A failure at any step puts the old files back and
27
+ removes the folders this call created, so the outputs are either all new or all as they were.
28
+ Returns the paths. Raises ``OSError`` for the first file or folder that could not be written.
29
+ """
30
+ created, staged, moved, placed = [], [], [], []
31
+ try:
32
+ for d in map(Path, make_dirs):
33
+ if not d.exists():
34
+ d.mkdir(parents=True)
35
+ created.append(d)
36
+ for path, data in files.items():
37
+ path = Path(path)
38
+ if path.is_dir():
39
+ raise IsADirectoryError(errno.EISDIR, os.strerror(errno.EISDIR), str(path))
40
+ tmp = path.with_name(path.name + ".prep-ic-tmp")
41
+ staged.append((tmp, path))
42
+ tmp.write_bytes(data)
43
+ for _, path in staged:
44
+ if path.exists():
45
+ old = path.with_name(path.name + ".prep-ic-old")
46
+ os.replace(path, old)
47
+ moved.append((old, path))
48
+ for tmp, path in staged:
49
+ os.replace(tmp, path)
50
+ placed.append(path)
51
+ except OSError:
52
+ had_old = {path for _, path in moved}
53
+ for path in placed:
54
+ if path not in had_old:
55
+ _remove(path)
56
+ for old, path in moved:
57
+ try:
58
+ os.replace(old, path)
59
+ except OSError:
60
+ pass
61
+ for tmp, _ in staged:
62
+ _remove(tmp)
63
+ for d in reversed(created):
64
+ try:
65
+ d.rmdir()
66
+ except OSError:
67
+ pass
68
+ raise
69
+ for old, _ in moved:
70
+ _remove(old)
71
+ return [path for _, path in staged]
@@ -19,6 +19,7 @@ from pathlib import Path
19
19
  from .. import __version__
20
20
  from ..model.constants import POWER_FUNCTIONS, SIDE_NAMES
21
21
  from ..model.pdk import get_package, get_pdk
22
+ from .files import text_bytes, write_all
22
23
 
23
24
  SIGNAL_FUNCTIONS = ("in", "out", "tri", "inout", "analog")
24
25
  # LibreLane pad rows: side → (list name, row name, lists bottom→top for vertical rows)
@@ -155,6 +156,19 @@ def config_yaml(layout, source=""):
155
156
  if skip: # a comment: a key here would replace the user's own list (logos, ID cells)
156
157
  out += ["# LibreLane's disconnected pin check has to skip these IO cells. Add them to",
157
158
  "# IGNORE_DISCONNECTED_MODULES in your config.yaml:"] + [f"# - {m}" for m in skip] + [""]
159
+ ips = {}
160
+ for p in layout.pins:
161
+ spec = pdk.spec(p.function, p.variant) if p.cell else {}
162
+ if "ip" in spec:
163
+ ips[spec["master"]] = spec["ip"]
164
+ for master, ip in sorted(ips.items()):
165
+ views = ip["dir"] + "/final"
166
+ out += [f"# {master} is no cell of the PDK: it is {ip['dir']} of {ip['source']}.",
167
+ "# pad_cfg.tcl places it. Add its views to config.yaml as the IP's README says, next to the IO library's:",
168
+ f"# - PAD_LEFS: {views}/lef/{master}.lef",
169
+ f"# - PAD_VERILOG_MODELS: {views}/vh/{master}.vh",
170
+ f"# - EXTRA_GDS: {views}/gds/{master}.gds",
171
+ f"# - LIB: {views}/lib/{master}.lib in every corner, not EXTRA_LIBS, where Yosys loses its power ports", ""]
158
172
  for n in names.notes:
159
173
  out.append(f"# Note: {n}")
160
174
  return "\n".join(out).rstrip() + "\n"
@@ -168,7 +182,8 @@ def pad_cfg_tcl(layout, source=""):
168
182
  Hh = layout.die_height
169
183
 
170
184
  def low(p): # lower/left edge of the IO cell along its row, die coordinates (origin lower-left)
171
- return (p.x if p.side in "TB" else p.y) - pdk.bondpad_shift(p.function) - pdk.width_of(p.function) / 2
185
+ return ((p.x if p.side in "TB" else p.y) - pdk.bondpad_shift(p.function, p.variant)
186
+ - pdk.width_of(p.function, p.variant) / 2)
172
187
 
173
188
  def gap_low(sp):
174
189
  if sp.side in "TB":
@@ -178,6 +193,10 @@ def pad_cfg_tcl(layout, source=""):
178
193
  pads = [(ROWS[s][1], names.inst[p.no], low(p)) for s in ROW_ORDER for p in _row_pins(layout, s)]
179
194
  pads += [(ROWS[rc.side][1], rc.name, _ring_low(layout, rc)) for rc in layout.ring_cells]
180
195
  gaps = [(ROWS[sp.side][1], gap_low(sp), sp.domain) for sp in layout.splits]
196
+ # cells that carry their own bond pad: row, instance, pad pin, supply pins
197
+ own = [(ROWS[s][1], names.inst[p.no], pdk.spec(p.function, p.variant)["pins"]["pad"],
198
+ [q for f in ("iovdd", "iovss", "vdd", "vss") for q in pdk.power_pins_of(p.function, p.variant).get(f, [])])
199
+ for s in ROW_ORDER for p in _row_pins(layout, s) if pdk.outward_of(p.function, p.variant)]
181
200
  out = _header("#", layout, pdk, source)
182
201
  out += [
183
202
  "#",
@@ -211,7 +230,13 @@ def pad_cfg_tcl(layout, source=""):
211
230
  f"# power splits: row, lower/left edge of the gap in µm, domain after the split ({pdk.split_gap or 0:g} µm gap)",
212
231
  "set prp_gaps {"]
213
232
  out += [f" {{{row} {pos:g} {dom}}}" for row, pos, dom in gaps]
214
- out += ["}", "",
233
+ out += ["}", ""]
234
+ if own:
235
+ out += [f"# cells with their own bond pad, {pdk.bondpad_h:g} µm further out than the row: row, instance, pad pin, supply pins",
236
+ "set prp_own_bondpad {"]
237
+ out += [f" {{{row} {inst} {pin} {{{' '.join(supplies)}}}}}" for row, inst, pin, supplies in own]
238
+ out += ["}", ""]
239
+ out += [
215
240
  "foreach pad $prp_pads {",
216
241
  " lassign $pad row inst_name pos",
217
242
  ' if { [set inst [$block findInst $inst_name]] == "NULL" } {',
@@ -244,13 +269,58 @@ def pad_cfg_tcl(layout, source=""):
244
269
  " odb::dbInst_destroy [$block findInst $name]",
245
270
  "}",
246
271
  ""]),
272
+ *([] if not own else [
273
+ "# A cell with its own bond pad is drawn for the place of the bondpads, its rails sit that much further in.",
274
+ "# place_pad leaves it FIRM in the row, so it is moved outward before connect_by_abutment.",
275
+ "set dbu [$block getDefUnits]",
276
+ "set die [$block getDieArea]",
277
+ f"set near [expr {{round(($::env(PAD_EDGE_SPACING) - {pdk.bondpad_h:g}) * $dbu)}}]",
278
+ "foreach pad $prp_own_bondpad {",
279
+ " lassign $pad row inst_name pin supplies",
280
+ " set inst [$block findInst $inst_name]",
281
+ " set box [$inst getBBox]",
282
+ " lassign [$inst getLocation] lx ly",
283
+ " set dx 0",
284
+ " set dy 0",
285
+ " switch -- $row {",
286
+ " IO_SOUTH { set dy [expr {$near - [$box yMin]}] }",
287
+ " IO_NORTH { set dy [expr {[$die yMax] - $near - [$box yMax]}] }",
288
+ " IO_WEST { set dx [expr {$near - [$box xMin]}] }",
289
+ " IO_EAST { set dx [expr {[$die xMax] - $near - [$box xMax]}] }",
290
+ " }",
291
+ " set moved [expr {abs($dx + $dy) / double($dbu)}]",
292
+ f" if {{ abs($moved - {pdk.bondpad_h:g}) > 0.001 }} {{",
293
+ f' puts stderr "\\[ERROR\\] $inst_name would move $moved µm outward, not {pdk.bondpad_h:g} µm: no cell for this ring."',
294
+ " exit 1",
295
+ " }",
296
+ " set status [$inst getPlacementStatus]",
297
+ " $inst setPlacementStatus PLACED",
298
+ " $inst setLocation [expr {$lx + $dx}] [expr {$ly + $dy}]",
299
+ " $inst setPlacementStatus $status",
300
+ "}",
301
+ ""]),
247
302
  'puts "\\[INFO\\] Connecting ring signals…"',
248
303
  "connect_by_abutment",
249
304
  "",
305
+ *([] if not own else [
306
+ "# An open IO supply ring shows in neither DRC, LVS nor timing",
307
+ "foreach pad $prp_own_bondpad {",
308
+ " lassign $pad row inst_name pin supplies",
309
+ " set inst [$block findInst $inst_name]",
310
+ " foreach pin_name $supplies {",
311
+ " set iterm [$inst findITerm $pin_name]",
312
+ ' if { $iterm eq "NULL" || $iterm eq "" || [$iterm getNet] eq "NULL" || [$iterm getNet] eq "" } {',
313
+ ' puts stderr "\\[ERROR\\] $inst_name/$pin_name is on no net."',
314
+ " exit 1",
315
+ " }",
316
+ " }",
317
+ "}",
318
+ ""]),
250
319
  *([] if pdk.bondpad_inset is not None else [
251
320
  "if { [info exists ::env(PAD_BONDPAD_NAME)] } {",
252
321
  " foreach pad $prp_pads {",
253
322
  " lassign $pad row inst_name pos",
323
+ *([] if not own else [" if { [lsearch -exact -index 1 $prp_own_bondpad $inst_name] >= 0 } { continue }"]),
254
324
  " set master_name [[[$block findInst $inst_name] getMaster] getName]",
255
325
  " dict for {master_regex offset} $::env(PAD_BONDPAD_OFFSETS) {",
256
326
  " if {[regexp $master_regex $master_name]} {",
@@ -260,9 +330,17 @@ def pad_cfg_tcl(layout, source=""):
260
330
  " }",
261
331
  "}",
262
332
  ""]),
333
+ *([] if not own else [
334
+ "# place_bondpad creates the top-level terminal of the other pads",
335
+ "foreach pad $prp_own_bondpad {",
336
+ " lassign $pad row inst_name pin supplies",
337
+ " place_io_terminals $inst_name/$pin",
338
+ "}",
339
+ ""]),
263
340
  "if { [info exists ::env(PAD_PLACE_IO_TERMINALS)] } {",
264
341
  " foreach pad $prp_pads {",
265
342
  " lassign $pad row inst_name pos",
343
+ *([] if not own else [" if { [lsearch -exact -index 1 $prp_own_bondpad $inst_name] >= 0 } { continue }"]),
266
344
  " set master_name [[[$block findInst $inst_name] getMaster] getName]",
267
345
  " foreach master_pin $::env(PAD_PLACE_IO_TERMINALS) {",
268
346
  " lassign [split $master_pin /] check_master pin_name",
@@ -352,7 +430,8 @@ def chip_top_sv(layout, source="", module="chip_top", core_module="chip_core"):
352
430
  if not p.cell:
353
431
  continue
354
432
  master, pins = pdk.cell(p.function, p.drive, p.variant)
355
- pp = pdk.power_pins_of(p.function)
433
+ pp = pdk.power_pins_of(p.function, p.variant)
434
+ spec = pdk.spec(p.function, p.variant)
356
435
  power = [f".{pin}({layout.rail(f, p.domain)})" for f in ("iovdd", "iovss", "vdd", "vss") for pin in pp.get(f, [])]
357
436
  conns = []
358
437
  if p.no in names.port:
@@ -362,9 +441,9 @@ def chip_top_sv(layout, source="", module="chip_top", core_module="chip_core"):
362
441
  if on_pad(base, role):
363
442
  continue
364
443
  net = f"{base}_PAD{idx}" if role == "pad" else f"{base}_{NET_SUFFIX[role]}{idx}"
365
- invert = "~" if role in pdk.cells[p.function].get("active_low", ()) else ""
444
+ invert = "~" if role in spec.get("active_low", ()) else ""
366
445
  conns.append(f".{pin}({invert}{net})")
367
- tie_conns, tie_wires = _tied_pins(pdk.cells[p.function], names.inst[p.no])
446
+ tie_conns, tie_wires = _tied_pins(spec, names.inst[p.no])
368
447
  conns += tie_conns
369
448
  out += [f" wire {w};" for w in tie_wires]
370
449
  dom = f", domain {p.domain}" if p.domain else ""
@@ -562,12 +641,7 @@ def librelane_files(project, source="", out_dir=None):
562
641
 
563
642
 
564
643
  def export_librelane(project, directory, source=""):
565
- """Write the generated files into ``directory``; returns the written paths."""
644
+ """Write the generated files into ``directory``, all or none; returns the written paths."""
566
645
  d = Path(directory)
567
- d.mkdir(parents=True, exist_ok=True)
568
- paths = []
569
- for name, text in librelane_files(project, source, out_dir=d).items():
570
- path = d / name
571
- path.write_text(text, encoding="utf-8")
572
- paths.append(path)
573
- return paths
646
+ texts = librelane_files(project, source, out_dir=d) # raises before any file without a PDK
647
+ return write_all({d / name: text_bytes(text) for name, text in texts.items()}, make_dirs=[d])
@@ -3,6 +3,9 @@
3
3
  """Pin list as rows, tab-separated text or CSV."""
4
4
 
5
5
  import csv
6
+ import io
7
+
8
+ from .files import write_all
6
9
 
7
10
  from ..model.constants import FUNCTION_NAMES, SIDE_NAMES, TYPE_NAMES
8
11
 
@@ -21,9 +24,15 @@ def to_tsv(layout):
21
24
  return "\n".join("\t".join(map(str, r)) for r in [HEADER] + rows(layout))
22
25
 
23
26
 
27
+ def csv_bytes(layout):
28
+ """The pin list as CSV, UTF-8 with BOM for Excel."""
29
+ f = io.StringIO(newline="")
30
+ w = csv.writer(f)
31
+ w.writerow(HEADER)
32
+ w.writerows(rows(layout))
33
+ return f.getvalue().encode("utf-8-sig")
34
+
35
+
24
36
  def export_csv(project, path):
25
37
  """Write the pin list of a :class:`Project` as CSV (UTF-8 with BOM for Excel)."""
26
- with open(path, "w", newline="", encoding="utf-8-sig") as f:
27
- w = csv.writer(f)
28
- w.writerow(HEADER)
29
- w.writerows(rows(project.layout()))
38
+ write_all({path: csv_bytes(project.layout())})
@@ -61,5 +61,5 @@ def to_svg(layout, pal=EXPORT_PALETTE, title="PREP-IC"):
61
61
 
62
62
  def export_svg(project, path, title="PREP-IC"):
63
63
  """Write the drawing of a :class:`Project` as SVG."""
64
- with open(path, "w", encoding="utf-8") as f:
65
- f.write(to_svg(project.layout(), title=title))
64
+ from .files import text_bytes, write_all
65
+ write_all({path: text_bytes(to_svg(project.layout(), title=title))})
@@ -29,7 +29,7 @@ FUNCTION_NAMES = {"in": "Input", "out": "Output", "tri": "Tristate output", "ino
29
29
  "iovss": "IO ground", "none": "No IO cell"}
30
30
  FUNCTION_TAGS = {"in": "in", "out": "out", "tri": "tri", "io": "inout", "inout": "inout", "analog": "analog",
31
31
  "vdd": "vdd", "vss": "vss", "iovdd": "iovdd", "iovss": "iovss", "none": "none"}
32
- VARIANT_TAGS = ("schmitt", "noesd") # a tag that picks another IO cell of the same function, if the PDK has one
32
+ VARIANT_TAGS = ("schmitt", "noesd", "rfpad") # a tag that picks another IO cell of the same function, if the PDK has one
33
33
  POWER_FUNCTIONS = ("vdd", "vss", "iovdd", "iovss")
34
34
  # Rail names of the IO ring; with power domains they get a "_<domain>" suffix
35
35
  RAILS = {"vdd": "VDD", "vss": "VSS", "iovdd": "IOVDD", "iovss": "IOVSS"}
@@ -238,7 +238,7 @@ def build_layout(project, selected=None):
238
238
  a, b = E - b, E - a
239
239
  p["a"], p["b"] = a, b
240
240
  if pdk: # IO cell on the grid, as centred in the slot as the grid allows
241
- cw = pdk.width_of(p["function"])
241
+ cw = pdk.width_of(p["function"], p["variant"])
242
242
  p["c"] = a + _snap((b - a - cw) / 2, pdk.site) + cw / 2
243
243
  else:
244
244
  p["c"] = (a + b) / 2
@@ -289,7 +289,7 @@ def build_layout(project, selected=None):
289
289
  c = pdk.cell(p["function"], p["drive"], p["variant"])
290
290
  if c:
291
291
  p["cell"] = c[0]
292
- p["w"], p["h"] = pdk.bondpad_of(p["function"])[:2]
292
+ p["w"], p["h"] = pdk.bondpad_of(p["function"], p["variant"])[:2]
293
293
  if p["variant"] and p["variant"] not in pdk.cells[p["function"]].get("variants", {}):
294
294
  warnings.append(f"Variant {p['variant']} ignored for pin {p['no']} {p['name']} ({p['function']})")
295
295
  if p["drive"] and not pdk.drives(p["function"]):
@@ -310,12 +310,12 @@ def build_layout(project, selected=None):
310
310
  """Die edge to the outer edge of the bond pad."""
311
311
  if not pdk:
312
312
  return H * 0.05
313
- own = pdk.bondpad_of(p["function"])[2]
313
+ own = pdk.bondpad_of(p["function"], p["variant"])[2]
314
314
  return pdk.edge_spacing - p["h"] if own is None else pdk.edge_spacing + own
315
315
 
316
316
  def pad_rect(p):
317
317
  w, h, s, ins = p["w"], p["h"], p["side"], inset(p)
318
- shift = pdk.bondpad_shift(p["function"]) if pdk else 0.0
318
+ shift = pdk.bondpad_shift(p["function"], p["variant"]) if pdk else 0.0
319
319
  c = p["c"] + (shift if s in "TB" else -shift) # the left and right sides run with y downward here
320
320
  if s == "T":
321
321
  return Ctb + c - w / 2, ins, w, h
@@ -373,13 +373,17 @@ def build_layout(project, selected=None):
373
373
  for p in pins:
374
374
  if p["cell"]:
375
375
  c = p["c"]
376
- cw = pdk.width_of(p["function"])
377
- x, y, w, h = cell_rect(p["side"], c - cw / 2, c + cw / 2, d0)
376
+ cw = pdk.width_of(p["function"], p["variant"])
377
+ x, y, w, h = cell_rect(p["side"], c - cw / 2, c + cw / 2, d0 - pdk.outward_of(p["function"], p["variant"]))
378
378
  add(dict(k="rect", x=x, y=y, w=w, h=h, style="iocell", tag=f"{p['side']}:{p['line']}"))
379
379
 
380
380
  for rc in ring_cells:
381
381
  x, y, w, h = cell_rect(rc.side, rc.a, rc.b, d0)
382
382
  add(dict(k="rect", x=x, y=y, w=w, h=h, style="iocell", tag=""))
383
+ across, along = (w, h) if rc.side in "TB" else (h, w) # the name runs along the depth of the narrow cell
384
+ size = min(across * 0.7, along * 0.9 / (0.62 * max(1, len(rc.name))))
385
+ add(dict(k="text", x=x + w / 2, y=y + h / 2, text=rc.name, size=size, angle=90 if rc.side in "TB" else 0,
386
+ anchor="center", color="muted", bold=False, tag=""))
383
387
 
384
388
  # Power splits: gap in the IO ring and the name of the domain that follows
385
389
  for sp in splits:
@@ -469,8 +473,9 @@ def build_layout(project, selected=None):
469
473
  if pdk:
470
474
  narrow = {}
471
475
  for p in pins:
472
- if p["cell"] and p["pitch"] < pdk.width_of(p["function"]) - 1e-9:
473
- narrow.setdefault(pdk.width_of(p["function"]), []).append(str(p["no"]))
476
+ cw = pdk.width_of(p["function"], p["variant"])
477
+ if p["cell"] and p["pitch"] < cw - 1e-9:
478
+ narrow.setdefault(cw, []).append(str(p["no"]))
474
479
  for width, nos in narrow.items():
475
480
  warnings.append(f"Pitch smaller than the IO cell ({width:g} µm) at pin " + ", ".join(nos))
476
481
  for dom in domains:
@@ -76,31 +76,32 @@ def parse_line(line):
76
76
  return {"split": True, "domain": t.strip("= \t")}
77
77
  typ = size = pitch = group = function = drive = variant = None
78
78
  lock = False
79
+ # read from the right: a second tag or option of one kind ends the reading and stays in the name, a finding
79
80
  while True:
80
81
  m = SIZE_RE.search(t)
81
- if m and m.start() > 0 and num(m.group(1), 0) and num(m.group(2), 0): # else it stays in the name, a finding
82
+ if m and m.start() > 0 and num(m.group(1), 0) and num(m.group(2), 0) and size is None: # else it stays in the name
82
83
  size = (num(m.group(1), 1), num(m.group(2), 1))
83
84
  t = t[:m.start()]
84
85
  continue
85
86
  m = PITCH_RE.search(t)
86
- if m and m.start() > 0 and num(m.group(1), 0):
87
+ if m and m.start() > 0 and num(m.group(1), 0) and pitch is None:
87
88
  pitch = num(m.group(1), 1)
88
89
  t = t[:m.start()]
89
90
  continue
90
91
  m = TAG_RE.search(t)
91
92
  if m and m.start() > 0:
92
93
  k = m.group(1).lower()
93
- if k in TAGS:
94
+ if k in TAGS and typ is None:
94
95
  typ = TAGS[k]
95
- elif k in GROUPS:
96
+ elif k in GROUPS and group is None:
96
97
  group = k
97
- elif k in FUNCTION_TAGS:
98
+ elif k in FUNCTION_TAGS and function is None:
98
99
  function = FUNCTION_TAGS[k]
99
- elif k in VARIANT_TAGS:
100
+ elif k in VARIANT_TAGS and variant is None:
100
101
  variant = k
101
- elif k == "lock":
102
+ elif k == "lock" and not lock:
102
103
  lock = True
103
- elif DRIVE_RE.fullmatch(k) and int(DRIVE_RE.fullmatch(k).group(1)):
104
+ elif DRIVE_RE.fullmatch(k) and int(DRIVE_RE.fullmatch(k).group(1)) and drive is None:
104
105
  drive = int(DRIVE_RE.fullmatch(k).group(1))
105
106
  else:
106
107
  break # e.g. bus name D[3] stays part of the name
@@ -57,25 +57,45 @@ class Pdk:
57
57
  """Die edge to where the IO cells of a side begin: past the corner cell, which may be taller than wide."""
58
58
  return self.edge_spacing + self.corner[0 if side in "TB" else 1]
59
59
 
60
- def width_of(self, function):
60
+ def spec(self, function, variant=None):
61
+ """The IO cell entry of a function, with the fields of ``variant`` laid over it if the cell has that variant.
62
+
63
+ A variant may name its own master, pins, supply pins, ties, width or bond pad, the rest is the cell's.
64
+ Its pins keep the roles of the function, so the core ports do not depend on the variant.
65
+ """
66
+ c = self.cells.get(function, {})
67
+ own = c.get("variants", {}).get(variant, {}) if variant else {}
68
+ return {**{k: v for k, v in c.items() if k != "variants"}, **own}
69
+
70
+ def width_of(self, function, variant=None):
61
71
  """Size along the edge of the IO cell of a function, ``cell_width`` unless the cell has its own."""
62
- return self.cells.get(function, {}).get("width", self.cell_width)
72
+ return self.spec(function, variant).get("width", self.cell_width)
63
73
 
64
- def power_pins_of(self, function):
74
+ def power_pins_of(self, function, variant=None):
65
75
  """Rail kind → supply pins of the IO cell of a function, ``power_pins`` unless the cell has its own."""
66
- pins = self.cells.get(function, {}).get("power_pins", self.power_pins)
76
+ pins = self.spec(function, variant).get("power_pins", self.power_pins)
67
77
  return {rail: [p] if isinstance(p, str) else list(p) for rail, p in pins.items()}
68
78
 
69
- def bondpad_of(self, function):
79
+ def bondpad_of(self, function, variant=None):
70
80
  """``(w, h, inset)`` of the bond pad of a function, ``inset`` as in ``bondpad_inset``."""
71
- own = self.cells.get(function, {}).get("bondpad", {})
81
+ own = self.spec(function, variant).get("bondpad", {})
72
82
  return own.get("w", self.bondpad_w), own.get("h", self.bondpad_h), own.get("inset", self.bondpad_inset)
73
83
 
74
- def bondpad_shift(self, function):
84
+ def bondpad_shift(self, function, variant=None):
75
85
  """Bond pad centre minus cell centre along the row, in die coordinates (x or y upward)."""
76
- own = self.cells.get(function, {}).get("bondpad", {})
86
+ own = self.spec(function, variant).get("bondpad", {})
77
87
  return own.get("shift", self.bondpad_default_shift)
78
88
 
89
+ def outward_of(self, function, variant=None):
90
+ """How far the IO cell reaches past the outer edge of its row, toward the die edge.
91
+
92
+ A cell with ``own_bondpad`` carries its bond pad where the separate bondpads of the other cells go, so it
93
+ sits the bondpad depth further out. In a PDK whose cells all carry their bond pad this means nothing.
94
+ """
95
+ if self.bondpad_inset is None and self.spec(function, variant).get("own_bondpad"):
96
+ return self.bondpad_h
97
+ return 0.0
98
+
79
99
  def drives(self, function):
80
100
  return list(self.cells.get(function, {}).get("drives", []))
81
101
 
@@ -85,10 +105,10 @@ class Pdk:
85
105
  ``pins`` maps roles (pad, in, out, oe, analog) to the pin names of the master.
86
106
  An unknown drive falls back to the default drive, an unknown variant to the plain cell.
87
107
  """
88
- c = self.cells.get(function)
89
- if c is None:
108
+ if function not in self.cells:
90
109
  return None
91
- master = c.get("variants", {}).get(variant, {}).get("master", c["master"])
110
+ c = self.spec(function, variant)
111
+ master = c["master"]
92
112
  if "{drive}" in master:
93
113
  if drive not in c["drives"]:
94
114
  drive = c["default_drive"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: prep-ic
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: PREP-IC (Pinout, Ring and Early floorplan Planner for ICs): plan IC pad ring pinouts with live die sizing, RF/GSG pad groups and exports.
5
5
  Author-email: Maximilian Golser <maximilian.golser@jku.at>, Simon Dorrer <simon.dorrer@jku.at>
6
6
  License-Expression: Apache-2.0
@@ -101,6 +101,7 @@ The code is split into a pure-Python, Qt-free model and exporters (`prep_ic.mode
101
101
  ├─ 📁 src/prep_ic/ the package (pip-installable)
102
102
  │ ├─ 📁 data/ PDK profiles (pdks/*.json) and the package library (packages.json)
103
103
  │ ├─ 📁 formats/ project files and exports, no Qt
104
+ │ │ ├─ files.py writes the files of an export all or none
104
105
  │ │ ├─ lef.py minimal LEF reader: macro size and pins
105
106
  │ │ ├─ librelane.py pad ring config, pad_cfg.tcl, chip_top.sv, macros.yaml, bondplan PINOUT
106
107
  │ │ ├─ pinlist.py pin list as CSV or tab-separated text
@@ -227,7 +228,7 @@ One line per entry. Each side lists its pads as seen on the die: top and bottom
227
228
  | `LO [gsgsg]` | differential: GND, LO_P, GND, LO_N, GND |
228
229
  | `NAME [in\|out\|tri\|io\|analog\|vdd\|vss\|iovdd\|iovss\|none]` | IO function, selects the IO cell (default guessed from name and type) |
229
230
  | `NAME [16mA]` | drive strength of output, tristate and bidirectional cells |
230
- | `NAME [schmitt]`, `NAME [noesd]` | another IO cell of the same function, where the PDK has one: a Schmitt trigger input, an analog pad without ESD clamp |
231
+ | `NAME [schmitt]`, `NAME [noesd]`, `NAME [rfpad]` | another IO cell of the same function, where the PDK has one: a Schmitt trigger input, an analog pad without ESD clamp, the RF pad of the IHP chip templates |
231
232
  | `NAME [lock]` | locked pad: it can no longer be dragged and *Optimize Pad Order* leaves it in place |
232
233
  | `=== NAME` | power split: cuts the IO ring here and starts power domain `NAME` |
233
234
 
@@ -341,7 +342,7 @@ The GUI tests run offscreen and are skipped when Qt is not installed.
341
342
  | `prep-ic export chip.json --librelane DIR` | write the LibreLane files into `DIR` (needs a PDK in the project) |
342
343
  | `prep-ic check chip.json` | list the findings of the project |
343
344
 
344
- The `export` options combine, e.g. `prep-ic export chip.json --csv pins.csv --svg ring.svg`. Each written LibreLane file is printed, and all findings go to stderr. Exit code 0 from `export` says only that the files were written, so gate a script on `check`: it prints one finding per line or `no findings`, and exits 0 when clean, 1 with findings and 2 when the check did not run. A finding is a layout warning, an entry of the project file that could not be read, a macro LEF that is gone, a marked pin no longer in the LEF, or what `prep.analyse` reports: unknown tags and options, bad power domain names, crossings, long analog flylines, pins without a pad, split differential pairs, sensitive pads next to noisy ones, macro and supply checks. Both commands run without Qt. From a source checkout without installing, use `python -m prep_ic` with `src` on the Python path in place of `prep-ic`.
345
+ The `export` options combine, e.g. `prep-ic export chip.json --csv pins.csv --svg ring.svg`. Each written LibreLane file is printed, and all findings go to stderr. `export` builds every output before it writes the first and writes all files or none, so a failure leaves the files as they were. Exit code 0 from `export` says only that the files were written, so gate a script on `check`: it prints one finding per line or `no findings`, and exits 0 when clean, 1 with findings and 2 when the check did not run. A finding is a layout warning, an entry of the project file that could not be read, a macro LEF that is gone, a marked pin no longer in the LEF, or what `prep.analyse` reports: unknown tags and options, bad power domain names, crossings, long analog flylines, pins without a pad, split differential pairs, sensitive pads next to noisy ones, macro and supply checks. Both commands run without Qt. From a source checkout without installing, use `python -m prep_ic` with `src` on the Python path in place of `prep-ic`.
345
346
 
346
347
 
347
348
  ## Supported PDKs and Packages
@@ -370,7 +371,7 @@ The IO function of a pad selects its cell (`<lib>` is `sg13g2` or `sg13cmos5l`,
370
371
  | `[out]` | `<lib>_IOPadOut<drive>mA` | `gpiov2_pad` | `bi_24t` |
371
372
  | `[tri]` | `<lib>_IOPadTriOut<drive>mA` | `gpiov2_pad` | `bi_24t` |
372
373
  | `[io]` | `<lib>_IOPadInOut<drive>mA` | `gpiov2_pad` | `bi_24t` |
373
- | `[analog]` | `<lib>_IOPadAnalog` | `analog_esd_pad`, with `[noesd]` `analog_noesd_pad` | `asig_5p0` |
374
+ | `[analog]` | `<lib>_IOPadAnalog`, with `[rfpad]` `<lib>_ip__rfpad_70x70` | `analog_esd_pad`, with `[noesd]` `analog_noesd_pad` | `asig_5p0` |
374
375
  | `[vdd]`, `[vss]` | `<lib>_IOPadVdd`, `<lib>_IOPadVss` | `vccd_lvc_clamped_pad`, `vssd_lvc_clamped_pad` | `dvdd`, `dvss` |
375
376
  | `[iovdd]`, `[iovss]` | `<lib>_IOPadIOVdd`, `<lib>_IOPadIOVss` | `vddio_hvc_clamped_pad`, `vssio_hvc_clamped_pad` | `dvdd`, `dvss` |
376
377
  | `[none]` | no IO cell | no IO cell | no IO cell |
@@ -378,6 +379,8 @@ The IO function of a pad selects its cell (`<lib>` is `sg13g2` or `sg13cmos5l`,
378
379
 
379
380
  The control pins of the sky130A and gf180mcuD cells are tied per function in `chip_top.sv`, so the core ports are the same as for IHP.
380
381
 
382
+ On IHP, `[rfpad]` picks the RF pad of the chip templates instead of `IOPadAnalog`, for an `[analog]` pad or the signal pad of a group (`RF [gsg] [rfpad]`): `ip/sg13g2_ip__rfpad_70x70` of [ihp-sg13g2-ams-chip-template](https://github.com/iic-jku/ihp-sg13g2-ams-chip-template) and `ip/sg13cmos5l_ip__rfpad_70x70` of [ihp-sg13cmos5l-ams-chip-template](https://github.com/iic-jku/ihp-sg13cmos5l-ams-chip-template). It is one 80 × 250 µm cell with its own bond pad, ESD and shield, and no series resistor, so the core is wired to `padbare` instead of `padres`. Its bond pad sits where the bondpads of the other cells go, and `pad_cfg.tcl` moves the cell outward by the bondpad depth, checks that its supplies are on nets, places its top-level terminal and gives it no bondpad. `padring_config.yaml` names the four views to add to your `config.yaml`, in `PAD_LEFS`, `PAD_VERILOG_MODELS`, `EXTRA_GDS` and every corner of `LIB`. The README of the IP has the details.
383
+
381
384
  On sky130A, PREP-IC adds two 20 µm connect cells in front of the first IO supply pad. They tie `VCCHIB` to `VCCD`, `VSWITCH` and `VDDA` to `VDDIO`, and `VSSA` to `VSSIO`, and that side grows by 40 µm. On gf180mcuD, the `dvdd` and `dvss` pads short their two supply rings, so the IO supply and the core supply are one net (`VDD`, `VSS`).
382
385
 
383
386
  [`examples/`](https://github.com/iic-jku/prep-ic/tree/main/examples) has one project per wafer.space gf180mcuD slot (`wafer_space_slot_*.json`) with the die of the slot, its pad order and positions, and the supply pads locked. Name your signals and save it under a new name. Three slots put an analog pad next to a digital one, which `prep-ic check` reports as `Sensitive pad next to noisy pad`.
@@ -21,6 +21,7 @@ src/prep_ic/data/pdks/ihp-sg13cmos5l.json
21
21
  src/prep_ic/data/pdks/ihp-sg13g2.json
22
22
  src/prep_ic/data/pdks/sky130a.json
23
23
  src/prep_ic/formats/__init__.py
24
+ src/prep_ic/formats/files.py
24
25
  src/prep_ic/formats/lef.py
25
26
  src/prep_ic/formats/librelane.py
26
27
  src/prep_ic/formats/pinlist.py
@@ -13,6 +13,7 @@ from prep_ic.model.chip import (add_missing_pads, align_macros, analyse, auto_ro
13
13
  move_line, optimize_pad_order, place_line, suggest_supply_pads,
14
14
  toggle_lock)
15
15
  from prep_ic.model.floorplan import Macro, MacroDef
16
+ from prep_ic.model.parse import format_entry, parse_line
16
17
 
17
18
  MACRO_DIR = ROOT / "tests" / "data" / "macros" / "adc_sar"
18
19
  FIXTURE = MACRO_DIR / "final" / "lef" / "adc_sar_top.lef"
@@ -86,6 +87,16 @@ class AnalyseTests(unittest.TestCase):
86
87
  self.assertIn(f"Unknown tag or option in pad name: {line}",
87
88
  analyse(set_lines(chip(), "L", [line])).warnings)
88
89
 
90
+ def test_a_second_tag_of_one_kind_stays_in_the_name(self):
91
+ # the rightmost one counts, the other is reported instead of overwriting it without a word
92
+ for line, name in (("A [noesd] [schmitt]", "A [noesd]"), ("A @100 @200", "A @100"), ("A [in] [out]", "A [in]"),
93
+ ("A [4mA] [16mA]", "A [4mA]"), ("A {60x60} {70x70}", "A {60x60}"), ("A [lock] [lock]", "A [lock]"),
94
+ ("A [gsg] [gs]", "A [gsg]"), ("A [d] [a]", "A [d]")):
95
+ self.assertIn(f"Unknown tag or option in pad name: {name}", analyse(set_lines(chip(), "L", [line])).warnings)
96
+ e = parse_line("A [noesd] [schmitt]")
97
+ self.assertEqual((e["name"], e["variant"]), ("A [noesd]", "schmitt"))
98
+ self.assertEqual(format_entry(e), "A [noesd] [schmitt]") # a rewrite from the Pin List keeps both
99
+
89
100
  def test_valid_lines_are_not_flagged(self):
90
101
  for line in ("A", "A[3]", "A [3]", "DOUT[3] [out] [4mA]", "RFOUT [gsg] {70x70} @125", "B [lock]", "---", "NC",
91
102
  "=== ANA", "", "A {60x60}", "A{60x60}", "A @120", "A@120",
@@ -150,6 +150,45 @@ class CommandLine(unittest.TestCase):
150
150
  self.assertNotIn("Exception ignored", r.stderr)
151
151
  self.assertTrue(Path(d, "pad_cfg.tcl").is_file())
152
152
 
153
+ def test_export_writes_all_files_or_none(self):
154
+ with tempfile.TemporaryDirectory() as d:
155
+ d = Path(d)
156
+ # an output that cannot be written: the CSV before it stays unwritten
157
+ r = self.run_cli("export", "examples/padring.json", "--csv", str(d / "p.csv"), "--svg", str(d / "no" / "p.svg"))
158
+ self.assertEqual(r.returncode, 1, r.stderr)
159
+ self.assertFalse((d / "p.csv").exists())
160
+ # LibreLane files without a PDK: nothing at all, not even the folder
161
+ r = self.run_cli("export", "examples/padring.json", "--csv", str(d / "q.csv"), "--librelane", str(d / "ll"))
162
+ self.assertEqual(r.returncode, 1, r.stderr)
163
+ self.assertFalse((d / "q.csv").exists() or (d / "ll").exists())
164
+ # one LibreLane file that cannot be written: the others keep what they held before
165
+ ll = d / "ll2"
166
+ (ll / "chip_top.sv").mkdir(parents=True)
167
+ (ll / "pad_cfg.tcl").write_text("old", encoding="utf-8")
168
+ r = self.run_cli("export", "examples/ihp_sg13g2_domains.json", "--librelane", str(ll))
169
+ self.assertEqual(r.returncode, 1, r.stderr)
170
+ self.assertEqual(sorted(p.name for p in ll.iterdir()), ["chip_top.sv", "pad_cfg.tcl"])
171
+ self.assertEqual((ll / "pad_cfg.tcl").read_text(encoding="utf-8"), "old")
172
+
173
+ def test_a_rename_that_fails_midway_puts_the_old_files_back(self):
174
+ from unittest import mock
175
+ from prep_ic.formats import files
176
+ with tempfile.TemporaryDirectory() as d:
177
+ a, b, c = (Path(d, n) for n in ("a.txt", "b.txt", "c.txt"))
178
+ a.write_text("old a", encoding="utf-8")
179
+ b.write_text("old b", encoding="utf-8")
180
+ real = os.replace
181
+
182
+ def flaky(src, dst):
183
+ if str(src).endswith("b.txt.prep-ic-tmp"): # the second new file cannot go into place
184
+ raise PermissionError("locked")
185
+ return real(src, dst)
186
+ with mock.patch.object(files.os, "replace", flaky), self.assertRaises(PermissionError):
187
+ files.write_all({a: b"new a", b: b"new b", c: b"new c"})
188
+ self.assertEqual((a.read_text(encoding="utf-8"), b.read_text(encoding="utf-8"), c.exists()),
189
+ ("old a", "old b", False))
190
+ self.assertEqual(sorted(p.name for p in Path(d).iterdir()), ["a.txt", "b.txt"])
191
+
153
192
  def test_export_without_a_stdout_succeeds(self):
154
193
  code = ("import sys\nimport prep_ic.cli as cli\nsys.stdout = None\n"
155
194
  "sys.exit(cli.main(['export', 'examples/ihp_sg13g2_domains.json', '--librelane', sys.argv[1]]))\n")
@@ -156,6 +156,63 @@ class PdkGeometry(unittest.TestCase):
156
156
  self.assertEqual(lay.warnings, [])
157
157
  self.assertIn("my_schmitt pad_clk", chip_top_sv(lay))
158
158
 
159
+ def test_cell_variant_brings_its_own_pins_supplies_ties_and_width(self):
160
+ # a variant lays its fields over those of the cell, the rest stays the cell's
161
+ own = {"master": "my_rf", "pins": {"pad": "pad", "analog": "padbare"}, "width": 90.0, "ties": {"TEST": "1'b0"},
162
+ "power_pins": {"vdd": "vdd", "vss": "vss", "iovdd": "iovdd", "iovss": "iovss"}}
163
+ with with_cell("analog", variants={"noesd": own}):
164
+ p = compac_like()
165
+ p.sides["R"][0] = "ain[0] [analog] [noesd]"
166
+ lay = p.layout()
167
+ sv = chip_top_sv(lay)
168
+ pdk = pdk_model.get_pdk("ihp-sg13g2")
169
+ self.assertEqual(lay.warnings, [])
170
+ self.assertEqual((pdk.width_of("analog", "noesd"), pdk.width_of("analog")), (90.0, 80.0))
171
+ rf = re.search(r"my_rf pad_ain_0 \((.*?)\);", sv, re.S).group(1)
172
+ self.assertEqual(set(re.findall(r"\.(\w+)\(", rf)), {"pad", "padbare", "TEST", "vdd", "vss", "iovdd", "iovss"})
173
+ plain = re.search(r"sg13g2_IOPadAnalog pad_ain_1 \((.*?)\);", sv, re.S).group(1)
174
+ self.assertEqual(set(re.findall(r"\.(\w+)\(", plain)), {"pad", "padres", "vdd", "vss", "iovdd", "iovss"})
175
+ self.assertIn(".padbare(ain_padres[0])", rf) # the core net of the role, whichever pin carries it
176
+
177
+ OWN_BONDPAD = {"master": "my_rf", "own_bondpad": True, "pins": {"pad": "pad", "analog": "padbare"},
178
+ "power_pins": {"vdd": "vdd", "vss": "vss", "iovdd": "iovdd", "iovss": "iovss"}}
179
+
180
+ def own_bondpad_layout(self):
181
+ p = compac_like()
182
+ p.sides["R"][0] = "ain[0] [analog] [noesd]"
183
+ return p.layout()
184
+
185
+ def test_cell_with_its_own_bond_pad_reaches_out_to_where_the_bondpads_go(self):
186
+ with with_cell("analog", variants={"noesd": self.OWN_BONDPAD}):
187
+ lay = self.own_bondpad_layout()
188
+ pdk = pdk_model.get_pdk("ihp-sg13g2")
189
+ self.assertEqual((pdk.outward_of("analog", "noesd"), pdk.outward_of("analog")), (70.0, 0.0))
190
+ own, plain = (next(q for q in lay.pins if q.name == n) for n in ("ain[0]", "ain[1]"))
191
+ self.assertEqual(own.x, plain.x) # the bond pad stays where the separate bondpad would be
192
+ cells = [pr for pr in lay.prims if pr["k"] == "rect" and pr.get("style") == "iocell"]
193
+ own_cell = next(pr for pr in cells if pr.get("tag") == f"R:{own.line}")
194
+ plain_cell = next(pr for pr in cells if pr.get("tag") == f"R:{plain.line}")
195
+ self.assertEqual((own_cell["w"], plain_cell["w"]), (250.0, 180.0)) # right side: the depth runs along x
196
+ self.assertEqual(own_cell["x"] + own_cell["w"], lay.die_width - 70.0)
197
+
198
+ def test_pad_cfg_moves_it_out_checks_its_supplies_and_places_its_terminal(self):
199
+ with with_cell("analog", variants={"noesd": self.OWN_BONDPAD}):
200
+ tcl = pad_cfg_tcl(self.own_bondpad_layout())
201
+ self.assertIn("{IO_EAST pad_ain_0 pad {iovdd iovss vdd vss}}", tcl)
202
+ self.assertIn("$inst setLocation", tcl)
203
+ abut = tcl.index("\nconnect_by_abutment\n")
204
+ self.assertLess(tcl.index("setLocation"), abut) # abutment sees the final place
205
+ self.assertLess(abut, tcl.index("is on no net"))
206
+ self.assertIn("lsearch -exact -index 1 $prp_own_bondpad $inst_name", tcl) # no bondpad cell for it
207
+ self.assertIn("place_io_terminals $inst_name/$pin", tcl)
208
+ self.assertNotIn("prp_own_bondpad", pad_cfg_tcl(compac_like().layout())) # other rings stay as they were
209
+
210
+ def test_own_bond_pad_means_nothing_where_every_cell_has_one(self):
211
+ lay = Sky130A().project().layout()
212
+ pdk = pdk_model.get_pdk("sky130A")
213
+ self.assertEqual(pdk.outward_of("analog"), 0.0)
214
+ self.assertNotIn("prp_own_bondpad", pad_cfg_tcl(lay))
215
+
159
216
  def test_variant_the_pdk_does_not_have_is_a_warning(self):
160
217
  p = compac_like()
161
218
  p.sides["L"][0] = "clk [in] [schmitt]"
@@ -344,6 +401,57 @@ class RingCells(unittest.TestCase):
344
401
  self.assertEqual(compac_like().layout().ring_cells, [])
345
402
 
346
403
 
404
+ class IhpRfPad(unittest.TestCase):
405
+ """The RF pad of the IHP chip templates: one cell with its own bond pad and no series resistor."""
406
+
407
+ def project(self, pdk="ihp-sg13g2"):
408
+ p = prep.Project(sides={"L": ["RF [gsg] [rfpad]", "ain [analog]", "VDD", "VSS"], "T": ["LO [analog] [rfpad]"], "R": [],
409
+ "B": ["IOVDD", "IOVSS"]})
410
+ p.settings.pdk, p.settings.std.pitch = pdk, 100
411
+ return p
412
+
413
+ def test_cells(self):
414
+ for pdk, lib in (("ihp-sg13g2", "sg13g2"), ("ihp-sg13cmos5l", "sg13cmos5l")):
415
+ lay = self.project(pdk).layout()
416
+ cells = {q.name: q.cell for q in lay.pins}
417
+ self.assertEqual((cells["RF"], cells["LO"]), (f"{lib}_ip__rfpad_70x70",) * 2, pdk)
418
+ self.assertEqual((cells["GND"], cells["ain"]), (f"{lib}_IOPadVss", f"{lib}_IOPadAnalog"), pdk)
419
+ self.assertEqual(lay.warnings, [], pdk)
420
+
421
+ def test_bond_pad_stays_where_the_bondpad_goes(self):
422
+ lay = self.project().layout()
423
+ rf, ain = (next(q for q in lay.pins if q.name == n) for n in ("RF", "ain"))
424
+ self.assertEqual((rf.x, ain.x), (105.0, 105.0)) # left side: 140 um seal ring spacing less half the 70 um pad
425
+
426
+ def test_export(self):
427
+ lay = self.project().layout()
428
+ sv, tcl, cfg = chip_top_sv(lay), pad_cfg_tcl(lay), config_yaml(lay)
429
+ lo = re.search(r"sg13g2_ip__rfpad_70x70 pad_LO \((.*?)\);", sv, re.S).group(1)
430
+ self.assertEqual(set(re.findall(r"\.(\w+)\(", lo)), {"pad", "padbare", "vdd", "vss", "iovdd", "iovss"})
431
+ self.assertIn(".pad(LO_PAD)", lo)
432
+ self.assertIn("{IO_NORTH pad_LO pad {iovdd iovss vdd vss}}", tcl)
433
+ for entry in ("PAD_LEFS", "PAD_VERILOG_MODELS", "EXTRA_GDS", "LIB"):
434
+ self.assertRegex(cfg, rf"(?m)^# - {entry}: ip/sg13g2_ip__rfpad_70x70/final/")
435
+ self.assertIn("https://github.com/iic-jku/ihp-sg13g2-ams-chip-template", cfg)
436
+ self.assertNotRegex(cfg, r"(?m)^(PAD_LEFS|PAD_VERILOG_MODELS|EXTRA_GDS|LIB):") # comments, the user's lists stay
437
+ plain = prep.Project(sides={"L": ["ain [analog]", "VDD", "VSS", "IOVDD", "IOVSS"], "T": [], "R": [], "B": []})
438
+ plain.settings.pdk = "ihp-sg13g2"
439
+ self.assertNotIn("rfpad", config_yaml(plain.layout()))
440
+
441
+ def test_only_ihp_has_it(self):
442
+ p = self.project()
443
+ p.settings.pdk = "sky130A"
444
+ self.assertIn("Variant rfpad ignored for pin 2 RF (analog)", p.layout().warnings)
445
+ p = self.project()
446
+ p.sides["T"] = ["clk [in] [rfpad]"]
447
+ self.assertTrue(any(w.startswith("Variant rfpad ignored") and "clk (in)" in w for w in p.layout().warnings))
448
+
449
+ def test_tag_round_trip(self):
450
+ e = parse_line("LO [analog] [rfpad]")
451
+ self.assertEqual((e["name"], e["variant"]), ("LO", "rfpad"))
452
+ self.assertEqual(format_entry(e), "LO [analog] [rfpad]")
453
+
454
+
347
455
  class Sky130A(unittest.TestCase):
348
456
  def project(self):
349
457
  p = prep.Project(sides={"L": ["clk [in]", "o [out]", "t [tri]", "bi [io]"], "T": ["ain [analog]", "bare [analog] [noesd]"], "R": [],
@@ -403,6 +511,19 @@ class Sky130A(unittest.TestCase):
403
511
  self.assertEqual(len(lay.ring_cells), 2)
404
512
  self.assertEqual({r.b - r.a for r in lay.ring_cells}, {20.0})
405
513
 
514
+ def test_the_connect_slices_carry_their_name_in_the_chip_view(self):
515
+ lay = self.project().layout()
516
+ texts = {pr["text"]: pr for pr in lay.prims if pr["k"] == "text"}
517
+ for rc in lay.ring_cells:
518
+ label = texts[rc.name]
519
+ cell = next(pr for pr in lay.prims if pr["k"] == "rect" and pr.get("style") == "iocell" and not pr.get("tag")
520
+ and abs(pr["x"] + pr["w"] / 2 - label["x"]) < 1e-6 and abs(pr["y"] + pr["h"] / 2 - label["y"]) < 1e-6)
521
+ across, along = (cell["w"], cell["h"]) if rc.side in "TB" else (cell["h"], cell["w"])
522
+ self.assertEqual((label["angle"], label["anchor"]), (90 if rc.side in "TB" else 0, "center")) # along the depth
523
+ self.assertLessEqual(label["size"], across) # fits the 20 um cell
524
+ self.assertLessEqual(label["size"] * 0.62 * len(rc.name), along) # and its depth
525
+ self.assertFalse(any(pr["k"] == "text" and pr["text"].startswith("connect") for pr in compac_like().layout().prims))
526
+
406
527
  def test_chip_top(self):
407
528
  sv = chip_top_sv(self.project().layout())
408
529
  for conn in (".OE_N(~bi_c2p_en)", ".OE_N(~t_c2p_en)", ".DM(3'b001)", ".DM(3'b110)", ".HLD_H_N(pad_clk_TIE_HI_ESD)",
@@ -25,8 +25,8 @@ def read_macros(path):
25
25
 
26
26
 
27
27
  def masters(cell):
28
- """Every IO cell master a profile entry can select."""
29
- variants = [v["master"] for v in cell.get("variants", {}).values()]
28
+ """Every IO cell master of the PDK a profile entry can select (a variant with ``ip`` comes from outside it)."""
29
+ variants = [v["master"] for v in cell.get("variants", {}).values() if "ip" not in v]
30
30
  if "{drive}" in cell["master"]:
31
31
  return [cell["master"].format(drive=d) for d in cell["drives"]] + variants
32
32
  return [cell["master"]] + variants
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes