librelane 2.4.0__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.

Potentially problematic release.


This version of librelane might be problematic. Click here for more details.

Files changed (170) hide show
  1. librelane/__init__.py +38 -0
  2. librelane/__main__.py +479 -0
  3. librelane/__version__.py +43 -0
  4. librelane/common/__init__.py +63 -0
  5. librelane/common/cli.py +75 -0
  6. librelane/common/drc.py +246 -0
  7. librelane/common/generic_dict.py +319 -0
  8. librelane/common/metrics/__init__.py +35 -0
  9. librelane/common/metrics/__main__.py +413 -0
  10. librelane/common/metrics/library.py +354 -0
  11. librelane/common/metrics/metric.py +186 -0
  12. librelane/common/metrics/util.py +279 -0
  13. librelane/common/misc.py +456 -0
  14. librelane/common/ring_buffer.py +63 -0
  15. librelane/common/tcl.py +80 -0
  16. librelane/common/toolbox.py +549 -0
  17. librelane/common/tpe.py +41 -0
  18. librelane/common/types.py +116 -0
  19. librelane/config/__init__.py +32 -0
  20. librelane/config/__main__.py +155 -0
  21. librelane/config/config.py +1025 -0
  22. librelane/config/flow.py +490 -0
  23. librelane/config/pdk_compat.py +255 -0
  24. librelane/config/preprocessor.py +464 -0
  25. librelane/config/removals.py +45 -0
  26. librelane/config/variable.py +743 -0
  27. librelane/container.py +285 -0
  28. librelane/env_info.py +320 -0
  29. librelane/examples/spm/config.yaml +33 -0
  30. librelane/examples/spm/pin_order.cfg +14 -0
  31. librelane/examples/spm/src/impl.sdc +73 -0
  32. librelane/examples/spm/src/signoff.sdc +68 -0
  33. librelane/examples/spm/src/spm.v +73 -0
  34. librelane/examples/spm/verify/spm_tb.v +106 -0
  35. librelane/examples/spm-user_project_wrapper/SPM_example.v +286 -0
  36. librelane/examples/spm-user_project_wrapper/base_sdc_file.sdc +145 -0
  37. librelane/examples/spm-user_project_wrapper/config-tut.json +12 -0
  38. librelane/examples/spm-user_project_wrapper/config.json +13 -0
  39. librelane/examples/spm-user_project_wrapper/defines.v +66 -0
  40. librelane/examples/spm-user_project_wrapper/template.def +7656 -0
  41. librelane/examples/spm-user_project_wrapper/user_project_wrapper.v +123 -0
  42. librelane/flows/__init__.py +24 -0
  43. librelane/flows/builtins.py +18 -0
  44. librelane/flows/classic.py +327 -0
  45. librelane/flows/cli.py +463 -0
  46. librelane/flows/flow.py +1049 -0
  47. librelane/flows/misc.py +71 -0
  48. librelane/flows/optimizing.py +179 -0
  49. librelane/flows/sequential.py +367 -0
  50. librelane/flows/synth_explore.py +173 -0
  51. librelane/help/__main__.py +39 -0
  52. librelane/logging/__init__.py +40 -0
  53. librelane/logging/logger.py +323 -0
  54. librelane/open_pdks_rev +1 -0
  55. librelane/plugins.py +21 -0
  56. librelane/py.typed +0 -0
  57. librelane/scripts/base.sdc +80 -0
  58. librelane/scripts/klayout/Readme.md +2 -0
  59. librelane/scripts/klayout/open_design.py +63 -0
  60. librelane/scripts/klayout/render.py +121 -0
  61. librelane/scripts/klayout/stream_out.py +176 -0
  62. librelane/scripts/klayout/xml_drc_report_to_json.py +45 -0
  63. librelane/scripts/klayout/xor.drc +120 -0
  64. librelane/scripts/magic/Readme.md +1 -0
  65. librelane/scripts/magic/common/read.tcl +114 -0
  66. librelane/scripts/magic/def/antenna_check.tcl +35 -0
  67. librelane/scripts/magic/def/mag.tcl +19 -0
  68. librelane/scripts/magic/def/mag_gds.tcl +79 -0
  69. librelane/scripts/magic/drc.tcl +78 -0
  70. librelane/scripts/magic/extract_spice.tcl +98 -0
  71. librelane/scripts/magic/gds/drc_batch.tcl +74 -0
  72. librelane/scripts/magic/gds/erase_box.tcl +32 -0
  73. librelane/scripts/magic/gds/extras_mag.tcl +45 -0
  74. librelane/scripts/magic/gds/mag_with_pointers.tcl +31 -0
  75. librelane/scripts/magic/get_bbox.tcl +11 -0
  76. librelane/scripts/magic/lef/extras_maglef.tcl +61 -0
  77. librelane/scripts/magic/lef/maglef.tcl +26 -0
  78. librelane/scripts/magic/lef.tcl +57 -0
  79. librelane/scripts/magic/open.tcl +28 -0
  80. librelane/scripts/magic/wrapper.tcl +21 -0
  81. librelane/scripts/netgen/setup.tcl +28 -0
  82. librelane/scripts/odbpy/apply_def_template.py +49 -0
  83. librelane/scripts/odbpy/cell_frequency.py +107 -0
  84. librelane/scripts/odbpy/check_antenna_properties.py +116 -0
  85. librelane/scripts/odbpy/contextualize.py +109 -0
  86. librelane/scripts/odbpy/defutil.py +573 -0
  87. librelane/scripts/odbpy/diodes.py +373 -0
  88. librelane/scripts/odbpy/disconnected_pins.py +305 -0
  89. librelane/scripts/odbpy/eco_buffer.py +181 -0
  90. librelane/scripts/odbpy/eco_diode.py +139 -0
  91. librelane/scripts/odbpy/filter_unannotated.py +100 -0
  92. librelane/scripts/odbpy/io_place.py +482 -0
  93. librelane/scripts/odbpy/ioplace_parser/__init__.py +23 -0
  94. librelane/scripts/odbpy/ioplace_parser/parse.py +147 -0
  95. librelane/scripts/odbpy/label_macro_pins.py +277 -0
  96. librelane/scripts/odbpy/lefutil.py +97 -0
  97. librelane/scripts/odbpy/placers.py +162 -0
  98. librelane/scripts/odbpy/power_utils.py +397 -0
  99. librelane/scripts/odbpy/random_place.py +57 -0
  100. librelane/scripts/odbpy/reader.py +250 -0
  101. librelane/scripts/odbpy/remove_buffers.py +173 -0
  102. librelane/scripts/odbpy/snap_to_grid.py +57 -0
  103. librelane/scripts/odbpy/wire_lengths.py +93 -0
  104. librelane/scripts/openroad/antenna_check.tcl +20 -0
  105. librelane/scripts/openroad/antenna_repair.tcl +31 -0
  106. librelane/scripts/openroad/basic_mp.tcl +24 -0
  107. librelane/scripts/openroad/buffer_list.tcl +10 -0
  108. librelane/scripts/openroad/common/dpl.tcl +24 -0
  109. librelane/scripts/openroad/common/dpl_cell_pad.tcl +26 -0
  110. librelane/scripts/openroad/common/grt.tcl +32 -0
  111. librelane/scripts/openroad/common/io.tcl +540 -0
  112. librelane/scripts/openroad/common/pdn_cfg.tcl +135 -0
  113. librelane/scripts/openroad/common/resizer.tcl +103 -0
  114. librelane/scripts/openroad/common/set_global_connections.tcl +78 -0
  115. librelane/scripts/openroad/common/set_layer_adjustments.tcl +31 -0
  116. librelane/scripts/openroad/common/set_power_nets.tcl +30 -0
  117. librelane/scripts/openroad/common/set_rc.tcl +75 -0
  118. librelane/scripts/openroad/common/set_routing_layers.tcl +30 -0
  119. librelane/scripts/openroad/cts.tcl +80 -0
  120. librelane/scripts/openroad/cut_rows.tcl +24 -0
  121. librelane/scripts/openroad/dpl.tcl +24 -0
  122. librelane/scripts/openroad/drt.tcl +37 -0
  123. librelane/scripts/openroad/fill.tcl +30 -0
  124. librelane/scripts/openroad/floorplan.tcl +145 -0
  125. librelane/scripts/openroad/gpl.tcl +88 -0
  126. librelane/scripts/openroad/grt.tcl +30 -0
  127. librelane/scripts/openroad/gui.tcl +37 -0
  128. librelane/scripts/openroad/insert_buffer.tcl +127 -0
  129. librelane/scripts/openroad/ioplacer.tcl +67 -0
  130. librelane/scripts/openroad/irdrop.tcl +51 -0
  131. librelane/scripts/openroad/pdn.tcl +52 -0
  132. librelane/scripts/openroad/rcx.tcl +32 -0
  133. librelane/scripts/openroad/repair_design.tcl +70 -0
  134. librelane/scripts/openroad/repair_design_postgrt.tcl +48 -0
  135. librelane/scripts/openroad/rsz_timing_postcts.tcl +68 -0
  136. librelane/scripts/openroad/rsz_timing_postgrt.tcl +70 -0
  137. librelane/scripts/openroad/sta/check_macro_instances.tcl +53 -0
  138. librelane/scripts/openroad/sta/corner.tcl +393 -0
  139. librelane/scripts/openroad/tapcell.tcl +25 -0
  140. librelane/scripts/openroad/write_views.tcl +27 -0
  141. librelane/scripts/pyosys/construct_abc_script.py +177 -0
  142. librelane/scripts/pyosys/json_header.py +84 -0
  143. librelane/scripts/pyosys/synthesize.py +493 -0
  144. librelane/scripts/pyosys/ys_common.py +153 -0
  145. librelane/scripts/tclsh/hello.tcl +1 -0
  146. librelane/state/__init__.py +24 -0
  147. librelane/state/__main__.py +61 -0
  148. librelane/state/design_format.py +195 -0
  149. librelane/state/state.py +359 -0
  150. librelane/steps/__init__.py +61 -0
  151. librelane/steps/__main__.py +510 -0
  152. librelane/steps/checker.py +637 -0
  153. librelane/steps/common_variables.py +340 -0
  154. librelane/steps/cvc_rv.py +169 -0
  155. librelane/steps/klayout.py +509 -0
  156. librelane/steps/magic.py +576 -0
  157. librelane/steps/misc.py +160 -0
  158. librelane/steps/netgen.py +253 -0
  159. librelane/steps/odb.py +1088 -0
  160. librelane/steps/openroad.py +2460 -0
  161. librelane/steps/openroad_alerts.py +102 -0
  162. librelane/steps/pyosys.py +640 -0
  163. librelane/steps/step.py +1571 -0
  164. librelane/steps/tclstep.py +288 -0
  165. librelane/steps/verilator.py +222 -0
  166. librelane/steps/yosys.py +371 -0
  167. librelane-2.4.0.dist-info/METADATA +169 -0
  168. librelane-2.4.0.dist-info/RECORD +170 -0
  169. librelane-2.4.0.dist-info/WHEEL +4 -0
  170. librelane-2.4.0.dist-info/entry_points.txt +9 -0
@@ -0,0 +1,153 @@
1
+ # Copyright 2020-2024 Efabless Corporation
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.
14
+ import os
15
+ import sys
16
+ from typing import Iterable, List, Union
17
+
18
+ try:
19
+ import libyosys as ys
20
+ except ImportError:
21
+ try:
22
+ from pyosys import libyosys as ys
23
+ except ImportError:
24
+ ys.log_error(
25
+ "Could not find pyosys in 'PYTHONPATH'-- make sure Yosys is compiled with ENABLE_PYTHON set to 1.",
26
+ file=sys.stderr,
27
+ )
28
+ exit(-1)
29
+
30
+
31
+ def _Design_run_pass(self, *command):
32
+ ys.Pass.call__YOSYS_NAMESPACE_RTLIL_Design__std_vector_string_(self, list(command))
33
+
34
+
35
+ ys.Design.run_pass = _Design_run_pass # type: ignore
36
+
37
+
38
+ def _Design_tee(self, *command: Union[List[str], str], o: str):
39
+ self.run_pass("tee", "-o", o, *command)
40
+
41
+
42
+ ys.Design.tee = _Design_tee # type: ignore
43
+
44
+
45
+ def _Design_read_verilog_files(
46
+ self: ys.Design,
47
+ files: Iterable[str],
48
+ *,
49
+ top: str,
50
+ synth_parameters: Iterable[str],
51
+ includes: Iterable[str],
52
+ defines: Iterable[str],
53
+ use_synlig: bool = False,
54
+ synlig_defer: bool = False,
55
+ ):
56
+ files = list(files) # for easier concatenation
57
+ include_args = [f"-I{dir}" for dir in includes]
58
+ define_args = [f"-D{define}" for define in defines]
59
+ chparams = {}
60
+ synlig_chparam_args = []
61
+ for chparam in synth_parameters:
62
+ param, value = chparam.split("=", maxsplit=1) # validate
63
+ chparams[param] = value
64
+ synlig_chparam_args.append(f"-P{param}={value}")
65
+
66
+ if use_synlig and synlig_defer:
67
+ self.run_pass("plugin", "-i", "synlig-sv")
68
+ for file in files:
69
+ self.run_pass(
70
+ "read_systemverilog",
71
+ "-defer",
72
+ "-sverilog",
73
+ *define_args,
74
+ *include_args,
75
+ file,
76
+ )
77
+ self.run_pass(
78
+ "read_systemverilog",
79
+ "-link",
80
+ "-sverilog",
81
+ "-top",
82
+ top,
83
+ *synlig_chparam_args,
84
+ )
85
+ elif use_synlig:
86
+ self.run_pass("plugin", "-i", "synlig-sv")
87
+ self.run_pass(
88
+ "read_systemverilog",
89
+ "-sverilog",
90
+ "-top",
91
+ top,
92
+ *define_args,
93
+ *include_args,
94
+ *synlig_chparam_args,
95
+ *files,
96
+ )
97
+ else:
98
+ for file in files:
99
+ self.run_pass(
100
+ "read_verilog",
101
+ "-defer",
102
+ "-noautowire",
103
+ "-sv",
104
+ *include_args,
105
+ *define_args,
106
+ file,
107
+ )
108
+ for param, value in chparams.items():
109
+ self.run_pass("chparam", "-set", param, value, top)
110
+
111
+
112
+ ys.Design.read_verilog_files = _Design_read_verilog_files # type: ignore
113
+
114
+
115
+ def _Design_add_blackbox_models(
116
+ self,
117
+ models: Iterable[str],
118
+ *,
119
+ includes: Iterable[str],
120
+ defines: Iterable[str],
121
+ ):
122
+ include_args = [f"-I{dir}" for dir in includes]
123
+ define_args = [f"-D{define}" for define in defines]
124
+
125
+ for model in models:
126
+ model_path, ext = os.path.splitext(model)
127
+ if ext == ".gz":
128
+ # Yosys transparently handles gzip compression
129
+ model_path, ext = os.path.splitext(model_path)
130
+
131
+ if ext in [".v", ".sv", ".vh"]:
132
+ self.run_pass(
133
+ "read_verilog", "-sv", "-lib", *include_args, *define_args, model
134
+ )
135
+ elif ext in [".lib"]:
136
+ self.run_pass(
137
+ "read_liberty",
138
+ "-lib",
139
+ "-ignore_miss_dir",
140
+ "-setattr",
141
+ "blackbox",
142
+ model,
143
+ )
144
+ else:
145
+ ys.log_error(
146
+ f"Black-box model '{model}' has an unrecognized file extension: '{ext}'.",
147
+ file=sys.stderr,
148
+ )
149
+ sys.stderr.flush()
150
+ exit(-1)
151
+
152
+
153
+ ys.Design.add_blackbox_models = _Design_add_blackbox_models # type: ignore
@@ -0,0 +1 @@
1
+ puts stdout "Hello, $::env(USER)!"
@@ -0,0 +1,24 @@
1
+ # Copyright 2023 Efabless Corporation
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.
14
+
15
+ """
16
+ The State Module
17
+ ----------------
18
+
19
+ This module manages the State of a Design before and after the execution of an
20
+ LibreLane step. The State is essentially a list of views in various formats in
21
+ addition to the cumulative set of metrics created by previous Steps.
22
+ """
23
+ from .design_format import DesignFormat, DesignFormatObject
24
+ from .state import State, InvalidState, StateElement
@@ -0,0 +1,61 @@
1
+ # Copyright 2023 Efabless Corporation
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.
14
+ import sys
15
+ import json
16
+ from typing import Optional
17
+
18
+ import cloup
19
+
20
+ from ..common import get_latest_file
21
+ from ..common.cli import formatter_settings
22
+
23
+
24
+ @cloup.group(
25
+ no_args_is_help=True,
26
+ formatter_settings=formatter_settings,
27
+ )
28
+ def cli():
29
+ pass
30
+
31
+
32
+ @cloup.command()
33
+ @cloup.option(
34
+ "--extract-metrics-to",
35
+ default=None,
36
+ )
37
+ @cloup.argument("run_dir")
38
+ def latest(extract_metrics_to: Optional[str], run_dir: str):
39
+ exit_code = 0
40
+
41
+ if latest_state := get_latest_file(run_dir, "state_*.json"):
42
+ try:
43
+ state = json.load(open(latest_state, encoding="utf8"))
44
+ except json.JSONDecodeError as e:
45
+ print(f"Latest state at {latest_state} is invalid: {e}", file=sys.stderr)
46
+ exit(1)
47
+ metrics = state["metrics"]
48
+ print(latest_state, end="")
49
+ if output := extract_metrics_to:
50
+ json.dump(metrics, open(output, "w", encoding="utf8"))
51
+ else:
52
+ print("No state_*.json files found", file=sys.stderr)
53
+ exit_code = 1
54
+
55
+ exit(exit_code)
56
+
57
+
58
+ cli.add_command(latest)
59
+
60
+ if __name__ == "__main__":
61
+ cli()
@@ -0,0 +1,195 @@
1
+ # Copyright 2023 Efabless Corporation
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.
14
+ from enum import Enum
15
+ from typing import Dict, Optional
16
+ from dataclasses import dataclass, replace
17
+
18
+
19
+ @dataclass
20
+ class DesignFormatObject:
21
+ """
22
+ Metadata about the various possible text or binary representations (views)
23
+ of any design.
24
+
25
+ For example, ``DesignFormat.NETLIST.value`` has the metadata for Netlist
26
+ views.
27
+
28
+ :param id: A lowercase alphanumeric identifier for the design format.
29
+ Some IDs in LibreLane 2.X use dashes. This is an inconsistency that will
30
+ be addressed in the next major version of LibreLane as it would be a
31
+ breaking change.
32
+ :param extension: The file extension for designs saved in this format.
33
+ :param name: A human-readable name for this design format.
34
+ :param folder_override: The subdirectory when
35
+ :meth:`librelane.state.State.save_snapshot` is called on a state. If
36
+ unset, the value for ``id`` will be used.
37
+ :param multiple: Whether this view may have multiple files (typically, files
38
+ that are different across multiple corners or similar.)
39
+ """
40
+
41
+ id: str
42
+ extension: str
43
+ name: str
44
+ folder_override: Optional[str] = None
45
+ multiple: bool = False
46
+
47
+ _instance_optional: bool = False
48
+
49
+ @property
50
+ def folder(self) -> str:
51
+ return self.folder_override or self.id
52
+
53
+ @property
54
+ def optional(self) -> bool:
55
+ return self._instance_optional
56
+
57
+
58
+ class DesignFormat(Enum):
59
+ """
60
+ An `enumeration <https://docs.python.org/3/library/enum.html>`_ of a number
61
+ of :class:`librelane.state.DesignFormatObject`\\s representing the various
62
+ possible text or binary representations (views) supported by LibreLane
63
+ states.
64
+
65
+ Members of this enumeration are used as the keys of
66
+ :class:`librelane.state.State` objects.
67
+ """
68
+
69
+ NETLIST: DesignFormatObject = DesignFormatObject(
70
+ "nl",
71
+ "nl.v",
72
+ "Verilog Netlist",
73
+ )
74
+ POWERED_NETLIST: DesignFormatObject = DesignFormatObject(
75
+ "pnl",
76
+ "pnl.v",
77
+ "Powered Verilog Netlist",
78
+ )
79
+ POWERED_NETLIST_SDF_FRIENDLY: DesignFormatObject = DesignFormatObject(
80
+ "pnl-sdf-friendly",
81
+ "pnl-sdf.v",
82
+ "Powered Verilog Netlist For SDF Simulation (Without Fill Cells)",
83
+ folder_override="pnl",
84
+ )
85
+ POWERED_NETLIST_NO_PHYSICAL_CELLS: DesignFormatObject = DesignFormatObject(
86
+ "pnl-npc",
87
+ "pnl-npc.v",
88
+ "Powered Verilog Netlist Without Physical Cells (Fill Cells and Diode Cells)",
89
+ folder_override="pnl",
90
+ )
91
+
92
+ DEF: DesignFormatObject = DesignFormatObject(
93
+ "def",
94
+ "def",
95
+ "Design Exchange Format",
96
+ )
97
+ LEF: DesignFormatObject = DesignFormatObject(
98
+ "lef",
99
+ "lef",
100
+ "Library Exchange Format",
101
+ )
102
+ OPENROAD_LEF: DesignFormatObject = DesignFormatObject(
103
+ "openroad-lef",
104
+ "openroad.lef",
105
+ "Library Exchange Format Generated by OpenROAD",
106
+ folder_override="lef",
107
+ )
108
+ ODB: DesignFormatObject = DesignFormatObject(
109
+ "odb",
110
+ "odb",
111
+ "OpenDB Database",
112
+ )
113
+
114
+ SDC: DesignFormatObject = DesignFormatObject(
115
+ "sdc",
116
+ "sdc",
117
+ "Design Constraints",
118
+ )
119
+ SDF: DesignFormatObject = DesignFormatObject(
120
+ "sdf",
121
+ "sdf",
122
+ "Standard Delay Format",
123
+ multiple=True,
124
+ )
125
+ SPEF: DesignFormatObject = DesignFormatObject(
126
+ "spef",
127
+ "spef",
128
+ "Standard Parasitics Extraction Format",
129
+ multiple=True, # nom, min, max, ...
130
+ )
131
+ LIB: DesignFormatObject = DesignFormatObject(
132
+ "lib",
133
+ "lib",
134
+ "LIB Timing Library Format",
135
+ multiple=True,
136
+ )
137
+ SPICE: DesignFormatObject = DesignFormatObject(
138
+ "spice",
139
+ "spice",
140
+ "Simulation Program with Integrated Circuit Emphasis",
141
+ )
142
+
143
+ MAG: DesignFormatObject = DesignFormatObject(
144
+ "mag",
145
+ "mag",
146
+ "Magic VLSI View",
147
+ )
148
+
149
+ GDS: DesignFormatObject = DesignFormatObject(
150
+ "gds",
151
+ "gds",
152
+ "GDSII Stream",
153
+ )
154
+ MAG_GDS: DesignFormatObject = DesignFormatObject(
155
+ "mag_gds",
156
+ "magic.gds",
157
+ "GDSII Stream (Magic)",
158
+ )
159
+ KLAYOUT_GDS: DesignFormatObject = DesignFormatObject(
160
+ "klayout_gds",
161
+ "klayout.gds",
162
+ "GDSII Stream (KLayout)",
163
+ )
164
+
165
+ JSON_HEADER: DesignFormatObject = DesignFormatObject(
166
+ "json_h",
167
+ "h.json",
168
+ "Design JSON Header File",
169
+ )
170
+ VERILOG_HEADER: DesignFormatObject = DesignFormatObject(
171
+ "vh",
172
+ "vh",
173
+ "Verilog Header",
174
+ )
175
+
176
+ def __str__(self) -> str:
177
+ return self.value.id
178
+
179
+ @staticmethod
180
+ def by_id(id: str) -> Optional["DesignFormat"]:
181
+ return _designformat_by_id.get(id)
182
+
183
+ def mkOptional(self) -> "DesignFormat":
184
+ # HACK: Create ephemeral DesignFormat copy until 3.0.0 lets us do this
185
+ # a bit more appropriately.
186
+ clone = object.__new__(DesignFormat)
187
+ clone._name_ = self._name_
188
+ clone._value_ = replace(self._value_)
189
+ clone._value_._instance_optional = True
190
+ return clone
191
+
192
+
193
+ _designformat_by_id: Dict[str, "DesignFormat"] = {
194
+ format.value.id: format for format in DesignFormat
195
+ }