librelane 3.1.0.dev5__py3-none-any.whl → 3.1.0.dev8__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 (75) hide show
  1. librelane/__main__.py +0 -1
  2. librelane/common/__init__.py +1 -0
  3. librelane/common/drc.py +2 -0
  4. librelane/common/metrics/__init__.py +1 -0
  5. librelane/common/metrics/__main__.py +3 -3
  6. librelane/common/metrics/library.py +0 -1
  7. librelane/common/misc.py +4 -4
  8. librelane/common/tcl.py +73 -58
  9. librelane/config/__init__.py +1 -0
  10. librelane/config/config.py +7 -18
  11. librelane/config/pdk_compat.py +6 -15
  12. librelane/config/variable.py +6 -4
  13. librelane/container.py +0 -37
  14. librelane/flows/__init__.py +1 -0
  15. librelane/flows/basic.py +16 -0
  16. librelane/flows/builtins.py +1 -0
  17. librelane/flows/chip.py +1 -12
  18. librelane/pdk_hashes.yaml +3 -3
  19. librelane/scripts/base.sdc +31 -25
  20. librelane/scripts/klayout/Readme.md +17 -1
  21. librelane/scripts/klayout/insert_cell.py +9 -5
  22. librelane/scripts/klayout/open_design.py +17 -8
  23. librelane/scripts/klayout/render.py +26 -9
  24. librelane/scripts/klayout/smoke.py +16 -0
  25. librelane/scripts/klayout/stream_out.py +61 -23
  26. librelane/scripts/klayout/xml_drc_report_to_json.py +15 -3
  27. librelane/scripts/klayout/xor.drc +2 -0
  28. librelane/scripts/klayout/xor.py +145 -0
  29. librelane/scripts/magic/def/mag_gds.tcl +4 -0
  30. librelane/scripts/odbpy/apply_def_template.py +2 -4
  31. librelane/scripts/odbpy/cell_frequency.py +6 -5
  32. librelane/scripts/odbpy/check_antenna_properties.py +4 -3
  33. librelane/scripts/odbpy/contextualize.py +2 -2
  34. librelane/scripts/odbpy/defutil.py +21 -26
  35. librelane/scripts/odbpy/diodes.py +7 -8
  36. librelane/scripts/odbpy/disconnected_pins.py +21 -21
  37. librelane/scripts/odbpy/eco_buffer.py +10 -9
  38. librelane/scripts/odbpy/eco_diode.py +9 -8
  39. librelane/scripts/odbpy/filter_unannotated.py +8 -9
  40. librelane/scripts/odbpy/io_place.py +27 -38
  41. librelane/scripts/odbpy/ioplace_parser/__init__.py +4 -1
  42. librelane/scripts/odbpy/ioplace_parser/parse.py +10 -11
  43. librelane/scripts/odbpy/label_macro_pins.py +10 -16
  44. librelane/scripts/odbpy/lefutil.py +8 -12
  45. librelane/scripts/odbpy/placers.py +8 -9
  46. librelane/scripts/odbpy/power_utils.py +30 -30
  47. librelane/scripts/odbpy/random_place.py +1 -2
  48. librelane/scripts/odbpy/reader.py +25 -6
  49. librelane/scripts/odbpy/remove_buffers.py +10 -10
  50. librelane/scripts/odbpy/wire_lengths.py +2 -4
  51. librelane/scripts/openroad/common/io.tcl +20 -45
  52. librelane/scripts/openroad/common/set_routing_layers.tcl +1 -4
  53. librelane/scripts/openroad/drt.tcl +2 -0
  54. librelane/scripts/openroad/rcx.tcl +2 -3
  55. librelane/scripts/openroad/sta/corner.tcl +14 -14
  56. librelane/scripts/pyosys/construct_abc_script.py +1 -1
  57. librelane/scripts/pyosys/json_header.py +5 -3
  58. librelane/scripts/pyosys/synthesize.py +56 -53
  59. librelane/state/__init__.py +1 -0
  60. librelane/steps/__init__.py +2 -0
  61. librelane/steps/{common_variables.py → common.py} +9 -1
  62. librelane/steps/gdsfill.py +75 -0
  63. librelane/steps/klayout.py +260 -114
  64. librelane/steps/magic.py +18 -13
  65. librelane/steps/netgen.py +26 -47
  66. librelane/steps/odb.py +19 -19
  67. librelane/steps/openroad.py +146 -53
  68. librelane/steps/openroad_alerts.py +0 -1
  69. librelane/steps/pyosys.py +103 -30
  70. librelane/steps/step.py +0 -1
  71. librelane/steps/tclstep.py +12 -44
  72. {librelane-3.1.0.dev5.dist-info → librelane-3.1.0.dev8.dist-info}/METADATA +10 -6
  73. {librelane-3.1.0.dev5.dist-info → librelane-3.1.0.dev8.dist-info}/RECORD +75 -71
  74. {librelane-3.1.0.dev5.dist-info → librelane-3.1.0.dev8.dist-info}/WHEEL +0 -0
  75. {librelane-3.1.0.dev5.dist-info → librelane-3.1.0.dev8.dist-info}/entry_points.txt +0 -0
librelane/__main__.py CHANGED
@@ -264,7 +264,6 @@ def run_included_example(
264
264
  final_path = os.path.join(d, "smoke_test_design")
265
265
  cleanup = True
266
266
  kwargs.update(
267
- flow_name=None,
268
267
  scl=None,
269
268
  pad=None,
270
269
  tag=None,
@@ -17,6 +17,7 @@ Common Utilities Module
17
17
 
18
18
  A number of common utility functions and classes used throughout the codebase.
19
19
  """
20
+
20
21
  import os
21
22
 
22
23
  from .tcl import TclUtils
librelane/common/drc.py CHANGED
@@ -289,6 +289,8 @@ class DRC:
289
289
 
290
290
  with ET.xmlfile(out, encoding="utf8", buffered=False) as xf:
291
291
  xf.write_declaration()
292
+ xf.write(ET.Comment(" KLayout Marker Database "))
293
+ xf.write(ET.Comment(" Created using LibreLane DRC Rosetta "))
292
294
  with xf.element("report-database"):
293
295
  # 1. Cells
294
296
  with xf.element("cells"):
@@ -30,6 +30,7 @@ Metrics Module
30
30
 
31
31
  Classes and functions for dealing with Metrics based on the `METRICS2.1 <https://github.com/ieee-ceda-datc/datc-rdf-Metrics4ML>`_ standard.
32
32
  """
33
+
33
34
  from . import library
34
35
  from .metric import MetricAggregator, MetricComparisonResult, Metric
35
36
  from .util import parse_metric_modifiers, aggregate_metrics, MetricDiff
@@ -27,7 +27,7 @@ from decimal import Decimal
27
27
  from typing import Optional, Tuple
28
28
 
29
29
  import cloup
30
- import httpx
30
+ import httpx2
31
31
 
32
32
  from .util import MetricDiff, TableVerbosity
33
33
  from .compare import compare_metric_directories, default_filter_set
@@ -210,7 +210,7 @@ def compare_remote(
210
210
  result = session.get(
211
211
  f"https://api.github.com/repos/{repo}/branches/{branch}"
212
212
  )
213
- except httpx.HTTPStatusError as e:
213
+ except httpx2.HTTPStatusError as e:
214
214
  if e.response is not None and e.response.status_code == 404:
215
215
  print(f"'{branch}' branch of repo {repo} not found.", file=sys.stderr)
216
216
  else:
@@ -264,7 +264,7 @@ def compare_remote(
264
264
  if table_out is not None:
265
265
  table_file = open(table_out, "w", encoding="utf8")
266
266
  print(tables, file=table_file)
267
- except httpx.HTTPStatusError as e:
267
+ except httpx2.HTTPStatusError as e:
268
268
  if e.response is not None and e.response.status_code == 404:
269
269
  print(f"Metrics not found for commit: {commit}.", file=sys.stderr)
270
270
  else:
@@ -13,7 +13,6 @@
13
13
  # limitations under the License.
14
14
  from .metric import Metric, sum_aggregator, min_aggregator, max_aggregator
15
15
 
16
-
17
16
  # Area and Counts
18
17
  Metric(
19
18
  "design__core__area",
librelane/common/misc.py CHANGED
@@ -39,7 +39,7 @@ from typing import (
39
39
  Union,
40
40
  )
41
41
 
42
- import httpx
42
+ import httpx2
43
43
  from deprecated.sphinx import deprecated
44
44
 
45
45
  from ..__version__ import __version__
@@ -407,7 +407,7 @@ def get_latest_file(in_path: Union[str, os.PathLike], filename: str) -> Optional
407
407
  return latest_json
408
408
 
409
409
 
410
- def get_httpx_session(token: Optional[str] = None) -> httpx.Client:
410
+ def get_httpx_session(token: Optional[str] = None) -> httpx2.Client:
411
411
  """
412
412
  Creates an ``httpx`` session client that follows redirects and has the
413
413
  User-Agent header set to ``librelane/{__version__}``.
@@ -416,11 +416,11 @@ def get_httpx_session(token: Optional[str] = None) -> httpx.Client:
416
416
  Authorization: Bearer {token}, is included.
417
417
  :returns: The created client
418
418
  """
419
- session = httpx.Client(follow_redirects=True)
419
+ session = httpx2.Client(follow_redirects=True)
420
420
  headers_raw = {"User-Agent": f"librelane/{__version__}"}
421
421
  if token is not None and token.strip() != "":
422
422
  headers_raw["Authorization"] = f"Bearer {token}"
423
- session.headers = httpx.Headers(headers_raw)
423
+ session.headers = httpx2.Headers(headers_raw)
424
424
  return session
425
425
 
426
426
 
librelane/common/tcl.py CHANGED
@@ -15,10 +15,17 @@
15
15
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
16
  # See the License for the specific language governing permissions and
17
17
  # limitations under the License.
18
+ import os
18
19
  import re
19
- from typing import Dict, Mapping, Any, Iterable
20
+ from enum import Enum
21
+ from decimal import Decimal
22
+ from dataclasses import asdict, is_dataclass
23
+ from typing import Callable, Dict, Mapping, Any, Iterable, Union
24
+
25
+ from minitcl import Interpreter
26
+
27
+ from .types import is_string
20
28
 
21
- _env_rx = re.compile(r"(?:\:\:)?env\((\w+)\)")
22
29
  _find_unsafe = re.compile(r"[^\w@%+=:,./-]", re.ASCII).search
23
30
  _escapes_in_quotes = re.compile(r"([\\\$\"\[])")
24
31
 
@@ -57,67 +64,75 @@ class TclUtils(object):
57
64
  return " ".join(TclUtils.escape(arg) for arg in ss)
58
65
 
59
66
  @staticmethod
60
- def _eval_env(env_in: Mapping[str, Any], tcl_in: str) -> Dict[str, Any]:
61
- import tkinter
67
+ def value_to_tcl(value: Any) -> str:
68
+ """
69
+ Converts an arbitrary Python value to Tcl as follows:
70
+
71
+ * If the value is a dict, the keys and values are escaped recursively
72
+ using: :meth:`TclUtils.join`.
73
+ * If the value is an instance of a dataclass, it is treated as a dict.
74
+ * If the value is a list, it is joined using :meth:`TclUtils.join`.
75
+ * If the value is an Enum, its name is returned.
76
+ * If the value is Boolean, "1" is returned for True and "0" for False.
77
+ * If the value is numeric, it is converted to a string.
78
+ * Otherwise, the value is passed to ``str()``.
79
+ """
80
+ if not isinstance(value, type) and is_dataclass(value):
81
+ return TclUtils.value_to_tcl(asdict(value))
82
+ elif isinstance(value, Mapping):
83
+ result = []
84
+ for v_key, v_value in value.items():
85
+ result.append(TclUtils.value_to_tcl(v_key))
86
+ result.append(TclUtils.value_to_tcl(v_value))
87
+ return TclUtils.join(result)
88
+ elif isinstance(value, Iterable) and not is_string(value):
89
+ result = []
90
+ for item in value:
91
+ result.append(TclUtils.value_to_tcl(item))
92
+ return TclUtils.join(result)
93
+ elif isinstance(value, Enum):
94
+ return value.name
95
+ elif isinstance(value, bool):
96
+ return "1" if value else "0"
97
+ elif isinstance(value, Decimal):
98
+ if value.to_integral_value() == value:
99
+ # ensure there's a .0 so it is not parsed as an int
100
+ return f"{value:.1f}"
101
+ return str(value)
102
+ elif isinstance(value, int):
103
+ return str(value)
104
+ else:
105
+ return str(value)
62
106
 
63
- interpreter = tkinter.Tcl()
107
+ @staticmethod
108
+ def _eval_env_common(
109
+ env_in: Mapping[str, Any], do_eval: Callable
110
+ ) -> Dict[str, str]:
111
+ interpreter = Interpreter()
64
112
 
65
113
  interpreter.eval("array unset ::env")
66
114
  for key, value in env_in.items():
67
- interpreter.setvar(f"env({key})", str(value))
115
+ if value is not None:
116
+ interpreter.set_var("env", key, TclUtils.value_to_tcl(value))
68
117
 
69
118
  env_out = dict(env_in)
119
+ do_eval(interpreter)
120
+ interpreter.eval("set _env_dict [array get ::env]")
121
+
122
+ parsed = interpreter.parse_list(interpreter.get_var("_env_dict"))
123
+ env_out = {}
124
+ for i in range(len(parsed) // 2):
125
+ key = parsed[2 * i]
126
+ val = parsed[2 * i + 1]
127
+ env_out[key] = val
128
+ return env_out
70
129
 
71
- def py_set(key, value=None):
72
- if match := _env_rx.fullmatch(key):
73
- if value is not None:
74
- env_out[match.group(1)] = value
75
-
76
- def py_dict(command, target=None, *args):
77
- if command == "set":
78
- if match := _env_rx.fullmatch(target):
79
-
80
- if len(args) > 1:
81
- value = args[-1]
82
- keys = args[:-1]
83
-
84
- # Create new dict if it does not exist
85
- if not match.group(1) in env_out:
86
- env_out[match.group(1)] = {}
87
-
88
- # set ::env(...) [dict create]
89
- # will create an empty string ""
90
- # convert into an empty dictionary
91
- if env_out[match.group(1)] == "":
92
- env_out[match.group(1)] = {}
93
-
94
- # Set key value pair
95
- cur_dict = env_out[match.group(1)]
96
-
97
- # Create all nested dicts
98
- for key in keys[:-1]:
99
- if key in cur_dict:
100
- cur_dict = cur_dict[key]
101
- else:
102
- cur_dict[key] = {}
103
- cur_dict = cur_dict[key]
104
-
105
- # Finally set the value
106
- cur_dict[keys[-1]] = value
107
-
108
- py_set_name = interpreter.register(py_set)
109
- py_dict_name = interpreter.register(py_dict)
110
- interpreter.call("rename", py_set_name, "_py_set")
111
- interpreter.call("rename", "set", "_orig_set")
112
- interpreter.call("rename", py_dict_name, "_py_dict")
113
- interpreter.call("rename", "dict", "_orig_dict")
114
- interpreter.eval(
115
- "proc set args { _py_set {*}$args; tailcall _orig_set {*}$args; }"
116
- )
117
- interpreter.eval(
118
- "proc dict args { _py_dict {*}$args; tailcall _orig_dict {*}$args; }"
119
- )
120
-
121
- interpreter.eval(tcl_in)
130
+ @staticmethod
131
+ def _eval_env(env_in: Mapping[str, Any], tcl_in: str) -> Dict[str, Any]:
132
+ return TclUtils._eval_env_common(env_in, lambda i: i.eval(tcl_in))
122
133
 
123
- return env_out
134
+ @staticmethod
135
+ def _eval_env_file(
136
+ env_in: Mapping[str, Any], tcl_in: Union[str, os.PathLike]
137
+ ) -> Dict[str, Any]:
138
+ return TclUtils._eval_env_common(env_in, lambda i: i.eval_file(tcl_in))
@@ -22,6 +22,7 @@ The Configuration Module
22
22
  This modules includes various functions for importing and/or generating LibreLane
23
23
  configuration objects. Configuration objects are the primary input to a flow.
24
24
  """
25
+
25
26
  from .preprocessor import Keys
26
27
  from .variable import Instance, Macro, Variable
27
28
  from .config import (
@@ -832,7 +832,7 @@ class Config(GenericImmutableDict[str, Any]):
832
832
  def __get_pdk_raw(
833
833
  pdk_root: str, pdk: str, scl: Optional[str], pad: Optional[str]
834
834
  ) -> Tuple[GenericImmutableDict[str, Any], str, str, Optional[str]]:
835
- pdk_config: GenericDict[str, Any] = GenericDict(
835
+ seed_config: GenericDict[str, Any] = GenericDict(
836
836
  {
837
837
  SpecialKeys.pdk_root: pdk_root,
838
838
  SpecialKeys.pdk: pdk,
@@ -840,15 +840,15 @@ class Config(GenericImmutableDict[str, Any]):
840
840
  )
841
841
 
842
842
  if scl is not None:
843
- pdk_config[SpecialKeys.scl] = scl
843
+ seed_config[SpecialKeys.scl] = scl
844
844
 
845
845
  # HACK: Prevent loading default SCL cfg vars for old openlane PDK
846
846
  # configs
847
847
  # For more info: https://github.com/librelane/librelane/issues/932
848
- pdk_config["STD_CELL_LIBRARY_OPT"] = scl
848
+ seed_config["STD_CELL_LIBRARY_OPT"] = scl
849
849
 
850
850
  if pad is not None:
851
- pdk_config[SpecialKeys.pad] = pad
851
+ seed_config[SpecialKeys.pad] = pad
852
852
 
853
853
  pdkpath = os.path.join(pdk_root, pdk)
854
854
  if not os.path.exists(pdkpath):
@@ -875,10 +875,7 @@ class Config(GenericImmutableDict[str, Any]):
875
875
  )
876
876
  pdk_config_path = pdk_config_path_alt
877
877
 
878
- pdk_env = TclUtils._eval_env(
879
- pdk_config,
880
- open(pdk_config_path, encoding="utf8").read(),
881
- )
878
+ pdk_env = TclUtils._eval_env_file(seed_config, pdk_config_path)
882
879
 
883
880
  scl = pdk_env.get("STD_CELL_LIBRARY", None)
884
881
  assert (
@@ -902,12 +899,7 @@ class Config(GenericImmutableDict[str, Any]):
902
899
  )
903
900
  scl_config_path = scl_config_path_alt
904
901
 
905
- full_env = migrate_old_config(
906
- TclUtils._eval_env(
907
- pdk_env,
908
- open(scl_config_path, encoding="utf8").read(),
909
- )
910
- )
902
+ full_env = migrate_old_config(TclUtils._eval_env_file(pdk_env, scl_config_path))
911
903
 
912
904
  pad = pdk_env.get("PAD_CELL_LIBRARY", None)
913
905
 
@@ -923,10 +915,7 @@ class Config(GenericImmutableDict[str, Any]):
923
915
  )
924
916
 
925
917
  full_env = migrate_old_config(
926
- TclUtils._eval_env(
927
- full_env,
928
- open(pad_config_path, encoding="utf8").read(),
929
- )
918
+ TclUtils._eval_env_file(full_env, pad_config_path)
930
919
  )
931
920
 
932
921
  return GenericImmutableDict(full_env), pdkpath, scl, pad
@@ -354,20 +354,11 @@ def migrate_old_config(config: Mapping[str, Any]) -> Dict[str, Any]:
354
354
  if "HEURISTIC_ANTENNA_THRESHOLD" not in config:
355
355
  new["HEURISTIC_ANTENNA_THRESHOLD"] = 130
356
356
 
357
- # x7. KLAYOUT_DRC_OPTIONS to defines
358
- if new["PDK"].startswith("sky130") and "KLAYOUT_DRC_OPTIONS" in new:
359
- tcl_dict = new["KLAYOUT_DRC_OPTIONS"]
360
- ws_rx = re.compile(r"\s+")
361
- del new["KLAYOUT_DRC_OPTIONS"]
362
- new["KLAYOUT_DRC_DEFINES"] = {}
363
- # deliberately not checking for bad dicts or dicts that require quoting
364
- # it's already overkill to assume people modified the PDK files here
365
- #
366
- # if someone complains we can parse a Tcl dict later
367
- tcl_dict_entries = ws_rx.split(tcl_dict)
368
- while len(tcl_dict_entries):
369
- key = tcl_dict_entries.pop(0)
370
- value = tcl_dict_entries.pop(0)
371
- new["KLAYOUT_DRC_DEFINES"][key] = value
357
+ if new["PDK"].startswith("sky130"):
358
+ new["KLAYOUT_ISOSUB_LAYER"] = (81, 53)
359
+ if new["PDK"].startswith("gf180mcu"):
360
+ new["KLAYOUT_ISOSUB_LAYER"] = (23, 5)
361
+ if new["PDK"].startswith("ihp-sg13"):
362
+ new["KLAYOUT_ISOSUB_LAYER"] = (40, 0)
372
363
 
373
364
  return new
@@ -15,7 +15,6 @@
15
15
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
16
  # See the License for the specific language governing permissions and
17
17
  # limitations under the License.
18
- import shlex
19
18
  import inspect
20
19
  from enum import Enum
21
20
  from decimal import Decimal, InvalidOperation
@@ -46,6 +45,9 @@ from typing import (
46
45
  get_origin,
47
46
  get_args,
48
47
  )
48
+
49
+ from minitcl import Interpreter
50
+
49
51
  from ..state import DesignFormat, State
50
52
  from ..common import GenericDict, Path, is_string, zip_first, Number, slugify
51
53
 
@@ -681,7 +683,7 @@ class Variable:
681
683
  elif ";" in raw:
682
684
  raw = raw.split(";")
683
685
  else:
684
- raw = raw.split()
686
+ raw = Interpreter().parse_list(str(raw))
685
687
  if len(raw) and raw[-1] == "":
686
688
  raw.pop() # Trailing commas
687
689
  else:
@@ -724,7 +726,7 @@ class Variable:
724
726
  )
725
727
  components = raw
726
728
  if is_string(raw):
727
- components = shlex.split(raw)
729
+ components = Interpreter().parse_list(str(raw))
728
730
  assert isinstance(components, list)
729
731
  # Assuming Tcl format:
730
732
  if len(components) % 2 != 0:
@@ -732,7 +734,7 @@ class Variable:
732
734
  f"Tcl-style flat dictionary provided for variable '{key_path}' is invalid: uneven number of components ({len(components)})"
733
735
  )
734
736
  raw = {}
735
- for i in range(0, len(components) // 2):
737
+ for i in range(len(components) // 2):
736
738
  key = components[2 * i]
737
739
  val = components[2 * i + 1]
738
740
  raw[key] = val
librelane/container.py CHANGED
@@ -21,7 +21,6 @@ import pathlib
21
21
  import subprocess
22
22
  from typing import List, NoReturn, Sequence, Optional, Union, Tuple
23
23
 
24
- import httpx
25
24
  import semver
26
25
 
27
26
  from .common import mkdirp
@@ -82,42 +81,6 @@ def image_exists(ce_path: str, image: str) -> bool:
82
81
  return len(images) >= 1
83
82
 
84
83
 
85
- def remote_manifest_exists(image: str) -> bool:
86
- registry = "docker.io"
87
- image_elements = image.split("/", maxsplit=1)
88
- if len(image_elements) > 1:
89
- registry = image_elements[0]
90
- image = image_elements[1]
91
- elements = image.split(":")
92
- repo = elements[0]
93
- tag = "latest"
94
- if len(elements) > 1:
95
- tag = elements[1]
96
-
97
- url = None
98
- if registry == "docker.io":
99
- url = f"https://registry.hub.docker.com/v2/repositories/{repo}/tags/{tag}"
100
- elif registry == "ghcr.io":
101
- url = f"https://ghcr.io/v2/{repo}/manifests/{tag}"
102
- else:
103
- err(f"Unknown registry '{registry}'.")
104
- return False
105
-
106
- try:
107
- httpx.Client(follow_redirects=True).get(
108
- url, headers={"Accept": "application/json"}
109
- )
110
- except httpx.NetworkError:
111
- err("Couldn't connect to the internet to pull container images.")
112
- return False
113
- except httpx.HTTPStatusError as e:
114
- err(
115
- f"The image {image} was not found. This may be because the CI for this image is running- in which case, please try again later. (error: {e})"
116
- )
117
- return False
118
- return True
119
-
120
-
121
84
  def ensure_image(ce_path: str, image: str) -> bool:
122
85
  if image_exists(ce_path, image):
123
86
  return True
@@ -18,6 +18,7 @@ The Flow Module
18
18
  An API for implementing new flows using the LibreLane infrastructure, as well
19
19
  as a number of built-in flows.
20
20
  """
21
+
21
22
  from .flow import FlowError, FlowException, FlowProgressBar, Flow
22
23
  from .sequential import SequentialFlow
23
24
  from . import builtins
@@ -0,0 +1,16 @@
1
+ # Copyright 2026 LibreLane Contributors
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ from .flow import Flow
4
+ from .classic import Classic
5
+
6
+
7
+ @Flow.factory.register()
8
+ class Basic(Classic):
9
+ Substitutions = {
10
+ "Verilator.*": None,
11
+ "Checker.Lint*": None,
12
+ "Yosys.EQY": None,
13
+ # Needs full KLayout
14
+ "KLayout.DRC": None,
15
+ "Checker.KLayoutDRC": None,
16
+ }
@@ -15,5 +15,6 @@
15
15
  from .optimizing import Optimizing
16
16
  from .classic import Classic, VHDLClassic
17
17
  from .chip import Chip
18
+ from .basic import Basic
18
19
  from .misc import OpenInKLayout, OpenInOpenROAD
19
20
  from .synth_explore import SynthesisExploration
librelane/flows/chip.py CHANGED
@@ -1,16 +1,5 @@
1
1
  # Copyright 2025 LibreLane Contributors
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
2
+ # SPDX-License-Identifier: Apache-2.0
14
3
  from .flow import Flow
15
4
  from .classic import Classic
16
5
  from ..steps import (
librelane/pdk_hashes.yaml CHANGED
@@ -1,4 +1,4 @@
1
- sky130: 792ef67037d74c8c51811eab3ce23cf793491296
2
- gf180mcu: 792ef67037d74c8c51811eab3ce23cf793491296
3
- ihp-sg13: 89d42ee6d2fd9b50b86a1aada6fee6673c3e6008
1
+ sky130: 2fdf40d5736413bb321c31418462aefc17b919b8
2
+ gf180mcu: 2fdf40d5736413bb321c31418462aefc17b919b8
3
+ ihp-sg13: e73adb4045731ddec21634146d536380057f6a26
4
4
  freepdk45: 784b1a483a5f4de362d6f3629378de1199453f3c
@@ -1,5 +1,6 @@
1
- set clock_port __VIRTUAL_CLK__
2
- if { [info exists ::env(CLOCK_PORT)] } {
1
+ set clock_name __VIRTUAL_CLK__
2
+ set port_args ""
3
+ if { [info exists ::env(CLOCK_PORT)] && $::env(CLOCK_PORT) ne "" } {
3
4
  set port_count [llength $::env(CLOCK_PORT)]
4
5
 
5
6
  if { $port_count == "0" } {
@@ -9,12 +10,35 @@ if { [info exists ::env(CLOCK_PORT)] } {
9
10
  }
10
11
 
11
12
  if { $port_count > "0" } {
12
- set ::clock_port [lindex $::env(CLOCK_PORT) 0]
13
+ set ::clock_name [lindex $::env(CLOCK_PORT) 0]
13
14
  }
15
+
16
+ set port_args [get_ports $clock_name]
17
+ puts "\[INFO] Using clock $clock_name"
18
+
19
+ set clk_input [get_port $clock_name]
20
+ set clk_indx [lsearch [all_inputs] $clk_input]
21
+ set all_inputs_wo_clk [lreplace [all_inputs] $clk_indx $clk_indx ""]
22
+
23
+ # For now, LibreLane doesn't know what port the reset is
24
+ #set rst_input [get_port resetn]
25
+ #set rst_indx [lsearch [all_inputs] $rst_input]
26
+ #set all_inputs_wo_clk_rst [lreplace $all_inputs_wo_clk $rst_indx $rst_indx ""]
27
+ set all_inputs_wo_clk_rst $all_inputs_wo_clk
28
+
29
+ if { ![info exists ::env(SYNTH_CLK_DRIVING_CELL)] } {
30
+ set ::env(SYNTH_CLK_DRIVING_CELL) $::env(SYNTH_DRIVING_CELL)
31
+ }
32
+
33
+ set_driving_cell \
34
+ -lib_cell [lindex [split $::env(SYNTH_CLK_DRIVING_CELL) "/"] 0] \
35
+ -pin [lindex [split $::env(SYNTH_CLK_DRIVING_CELL) "/"] 1] \
36
+ $clk_input
37
+ } else {
38
+ set all_inputs_wo_clk [all_inputs]
39
+ set all_inputs_wo_clk_rst $all_inputs_wo_clk
14
40
  }
15
- set port_args [get_ports $clock_port]
16
- puts "\[INFO] Using clock $clock_port…"
17
- create_clock {*}$port_args -name $clock_port -period $::env(CLOCK_PERIOD)
41
+ create_clock {*}$port_args -name $clock_name -period $::env(CLOCK_PERIOD)
18
42
 
19
43
  set input_delay_value [expr $::env(CLOCK_PERIOD) * $::env(IO_DELAY_CONSTRAINT) / 100]
20
44
  set output_delay_value [expr $::env(CLOCK_PERIOD) * $::env(IO_DELAY_CONSTRAINT) / 100]
@@ -29,35 +53,17 @@ if { [info exists ::env(MAX_CAPACITANCE_CONSTRAINT)] } {
29
53
  set_max_capacitance $::env(MAX_CAPACITANCE_CONSTRAINT) [current_design]
30
54
  }
31
55
 
32
- set clk_input [get_port $clock_port]
33
- set clk_indx [lsearch [all_inputs] $clk_input]
34
- set all_inputs_wo_clk [lreplace [all_inputs] $clk_indx $clk_indx ""]
35
-
36
- #set rst_input [get_port resetn]
37
- #set rst_indx [lsearch [all_inputs] $rst_input]
38
- #set all_inputs_wo_clk_rst [lreplace $all_inputs_wo_clk $rst_indx $rst_indx ""]
39
- set all_inputs_wo_clk_rst $all_inputs_wo_clk
40
-
41
56
  # correct resetn
42
- set clocks [get_clocks $clock_port]
57
+ set clocks [get_clocks $clock_name]
43
58
 
44
59
  set_input_delay $input_delay_value -clock $clocks $all_inputs_wo_clk_rst
45
60
  set_output_delay $output_delay_value -clock $clocks [all_outputs]
46
61
 
47
- if { ![info exists ::env(SYNTH_CLK_DRIVING_CELL)] } {
48
- set ::env(SYNTH_CLK_DRIVING_CELL) $::env(SYNTH_DRIVING_CELL)
49
- }
50
-
51
62
  set_driving_cell \
52
63
  -lib_cell [lindex [split $::env(SYNTH_DRIVING_CELL) "/"] 0] \
53
64
  -pin [lindex [split $::env(SYNTH_DRIVING_CELL) "/"] 1] \
54
65
  $all_inputs_wo_clk_rst
55
66
 
56
- set_driving_cell \
57
- -lib_cell [lindex [split $::env(SYNTH_CLK_DRIVING_CELL) "/"] 0] \
58
- -pin [lindex [split $::env(SYNTH_CLK_DRIVING_CELL) "/"] 1] \
59
- $clk_input
60
-
61
67
  set cap_load [expr $::env(OUTPUT_CAP_LOAD) / 1000.0]
62
68
  puts "\[INFO] Setting load to: $cap_load"
63
69
  set_load $cap_load [all_outputs]
@@ -1,2 +1,18 @@
1
1
  ## Reference
2
- https://www.klayout.org/downloads/pymod/doc-qt5/code/index.html
2
+ https://www.klayout.de/doc-qt5/code/index.html
3
+
4
+ ## Notes
5
+
6
+ As of KLayout 0.30.13, using the built-in interpreter:
7
+
8
+ - The interpreter does not add the top-level directory to PYTHONPATH.
9
+ - A top-level exception results in a 0 exit. All exceptions must be caught.
10
+ - exit and sys.exit both do not propagate. Use this pattern:
11
+
12
+ ```python3
13
+ try:
14
+ import pya
15
+ pya.Application.instance().exit(1)
16
+ except AttributeError:
17
+ sys.exit(1)
18
+ ```
@@ -13,7 +13,11 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
- import pya
16
+ from klayout.dbcore import (
17
+ DCellInstArray,
18
+ DTrans,
19
+ Layout,
20
+ )
17
21
 
18
22
 
19
23
  def insert_cell(
@@ -22,15 +26,15 @@ def insert_cell(
22
26
  output: str,
23
27
  ):
24
28
  # The main layout where the cell is inserted
25
- main_layout = pya.Layout()
29
+ main_layout = Layout()
26
30
  main_layout.read(input)
27
31
  top = main_layout.top_cell()
28
32
 
29
33
  # The cell to insert
30
- insert_layout = pya.Layout()
34
+ insert_layout = Layout()
31
35
  insert_layout.read(insert)
32
36
 
33
- def copy_cell_to_layout(target_layout, cell):
37
+ def copy_cell_to_layout(target_layout: Layout, cell):
34
38
  cell_in_target = target_layout.create_cell(cell.name)
35
39
  cell_in_target.copy_tree(cell)
36
40
  return cell_in_target
@@ -39,7 +43,7 @@ def insert_cell(
39
43
  insert_in_main = copy_cell_to_layout(main_layout, insert_layout.top_cell())
40
44
 
41
45
  # Instantiate the cell
42
- top.insert(pya.DCellInstArray(insert_in_main.cell_index(), pya.DTrans(0, 0)))
46
+ top.insert(DCellInstArray(insert_in_main.cell_index(), DTrans(0, 0)))
43
47
 
44
48
  main_layout.write(output)
45
49