librelane 2.4.0.dev0__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 (166) hide show
  1. librelane/__init__.py +38 -0
  2. librelane/__main__.py +470 -0
  3. librelane/__version__.py +43 -0
  4. librelane/common/__init__.py +61 -0
  5. librelane/common/cli.py +75 -0
  6. librelane/common/drc.py +245 -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 +402 -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 +117 -0
  19. librelane/config/__init__.py +32 -0
  20. librelane/config/__main__.py +158 -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 +722 -0
  27. librelane/container.py +264 -0
  28. librelane/env_info.py +306 -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 +330 -0
  45. librelane/flows/cli.py +463 -0
  46. librelane/flows/flow.py +985 -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/logging/__init__.py +40 -0
  52. librelane/logging/logger.py +323 -0
  53. librelane/open_pdks_rev +1 -0
  54. librelane/plugins.py +21 -0
  55. librelane/py.typed +0 -0
  56. librelane/scripts/base.sdc +80 -0
  57. librelane/scripts/klayout/Readme.md +2 -0
  58. librelane/scripts/klayout/open_design.py +63 -0
  59. librelane/scripts/klayout/render.py +121 -0
  60. librelane/scripts/klayout/stream_out.py +176 -0
  61. librelane/scripts/klayout/xml_drc_report_to_json.py +45 -0
  62. librelane/scripts/klayout/xor.drc +120 -0
  63. librelane/scripts/magic/Readme.md +1 -0
  64. librelane/scripts/magic/common/read.tcl +114 -0
  65. librelane/scripts/magic/def/antenna_check.tcl +35 -0
  66. librelane/scripts/magic/def/mag.tcl +19 -0
  67. librelane/scripts/magic/def/mag_gds.tcl +81 -0
  68. librelane/scripts/magic/drc.tcl +79 -0
  69. librelane/scripts/magic/extract_spice.tcl +98 -0
  70. librelane/scripts/magic/gds/drc_batch.tcl +74 -0
  71. librelane/scripts/magic/gds/erase_box.tcl +32 -0
  72. librelane/scripts/magic/gds/extras_mag.tcl +47 -0
  73. librelane/scripts/magic/gds/mag_with_pointers.tcl +32 -0
  74. librelane/scripts/magic/get_bbox.tcl +11 -0
  75. librelane/scripts/magic/lef/extras_maglef.tcl +63 -0
  76. librelane/scripts/magic/lef/maglef.tcl +27 -0
  77. librelane/scripts/magic/lef.tcl +57 -0
  78. librelane/scripts/magic/open.tcl +28 -0
  79. librelane/scripts/magic/wrapper.tcl +19 -0
  80. librelane/scripts/netgen/setup.tcl +28 -0
  81. librelane/scripts/odbpy/apply_def_template.py +49 -0
  82. librelane/scripts/odbpy/cell_frequency.py +107 -0
  83. librelane/scripts/odbpy/check_antenna_properties.py +116 -0
  84. librelane/scripts/odbpy/contextualize.py +109 -0
  85. librelane/scripts/odbpy/defutil.py +574 -0
  86. librelane/scripts/odbpy/diodes.py +373 -0
  87. librelane/scripts/odbpy/disconnected_pins.py +305 -0
  88. librelane/scripts/odbpy/exception_codes.py +17 -0
  89. librelane/scripts/odbpy/filter_unannotated.py +100 -0
  90. librelane/scripts/odbpy/io_place.py +482 -0
  91. librelane/scripts/odbpy/label_macro_pins.py +277 -0
  92. librelane/scripts/odbpy/lefutil.py +97 -0
  93. librelane/scripts/odbpy/placers.py +162 -0
  94. librelane/scripts/odbpy/power_utils.py +395 -0
  95. librelane/scripts/odbpy/random_place.py +57 -0
  96. librelane/scripts/odbpy/reader.py +246 -0
  97. librelane/scripts/odbpy/remove_buffers.py +173 -0
  98. librelane/scripts/odbpy/snap_to_grid.py +57 -0
  99. librelane/scripts/odbpy/wire_lengths.py +93 -0
  100. librelane/scripts/openroad/antenna_check.tcl +20 -0
  101. librelane/scripts/openroad/antenna_repair.tcl +31 -0
  102. librelane/scripts/openroad/basic_mp.tcl +24 -0
  103. librelane/scripts/openroad/buffer_list.tcl +10 -0
  104. librelane/scripts/openroad/common/dpl.tcl +24 -0
  105. librelane/scripts/openroad/common/dpl_cell_pad.tcl +26 -0
  106. librelane/scripts/openroad/common/grt.tcl +32 -0
  107. librelane/scripts/openroad/common/io.tcl +476 -0
  108. librelane/scripts/openroad/common/pdn_cfg.tcl +135 -0
  109. librelane/scripts/openroad/common/resizer.tcl +103 -0
  110. librelane/scripts/openroad/common/set_global_connections.tcl +78 -0
  111. librelane/scripts/openroad/common/set_layer_adjustments.tcl +31 -0
  112. librelane/scripts/openroad/common/set_power_nets.tcl +30 -0
  113. librelane/scripts/openroad/common/set_rc.tcl +75 -0
  114. librelane/scripts/openroad/common/set_routing_layers.tcl +30 -0
  115. librelane/scripts/openroad/cts.tcl +80 -0
  116. librelane/scripts/openroad/cut_rows.tcl +24 -0
  117. librelane/scripts/openroad/dpl.tcl +24 -0
  118. librelane/scripts/openroad/drt.tcl +37 -0
  119. librelane/scripts/openroad/fill.tcl +30 -0
  120. librelane/scripts/openroad/floorplan.tcl +145 -0
  121. librelane/scripts/openroad/gpl.tcl +88 -0
  122. librelane/scripts/openroad/grt.tcl +30 -0
  123. librelane/scripts/openroad/gui.tcl +15 -0
  124. librelane/scripts/openroad/insert_buffer.tcl +127 -0
  125. librelane/scripts/openroad/ioplacer.tcl +67 -0
  126. librelane/scripts/openroad/irdrop.tcl +51 -0
  127. librelane/scripts/openroad/pdn.tcl +52 -0
  128. librelane/scripts/openroad/rcx.tcl +32 -0
  129. librelane/scripts/openroad/repair_design.tcl +70 -0
  130. librelane/scripts/openroad/repair_design_postgrt.tcl +48 -0
  131. librelane/scripts/openroad/rsz_timing_postcts.tcl +68 -0
  132. librelane/scripts/openroad/rsz_timing_postgrt.tcl +70 -0
  133. librelane/scripts/openroad/sta/check_macro_instances.tcl +53 -0
  134. librelane/scripts/openroad/sta/corner.tcl +393 -0
  135. librelane/scripts/openroad/tapcell.tcl +25 -0
  136. librelane/scripts/openroad/write_views.tcl +27 -0
  137. librelane/scripts/pyosys/construct_abc_script.py +177 -0
  138. librelane/scripts/pyosys/json_header.py +84 -0
  139. librelane/scripts/pyosys/synthesize.py +493 -0
  140. librelane/scripts/pyosys/ys_common.py +153 -0
  141. librelane/scripts/tclsh/hello.tcl +1 -0
  142. librelane/state/__init__.py +24 -0
  143. librelane/state/__main__.py +61 -0
  144. librelane/state/design_format.py +180 -0
  145. librelane/state/state.py +351 -0
  146. librelane/steps/__init__.py +61 -0
  147. librelane/steps/__main__.py +511 -0
  148. librelane/steps/checker.py +637 -0
  149. librelane/steps/common_variables.py +340 -0
  150. librelane/steps/cvc_rv.py +169 -0
  151. librelane/steps/klayout.py +509 -0
  152. librelane/steps/magic.py +566 -0
  153. librelane/steps/misc.py +160 -0
  154. librelane/steps/netgen.py +253 -0
  155. librelane/steps/odb.py +955 -0
  156. librelane/steps/openroad.py +2433 -0
  157. librelane/steps/openroad_alerts.py +102 -0
  158. librelane/steps/pyosys.py +629 -0
  159. librelane/steps/step.py +1547 -0
  160. librelane/steps/tclstep.py +288 -0
  161. librelane/steps/verilator.py +222 -0
  162. librelane/steps/yosys.py +371 -0
  163. librelane-2.4.0.dev0.dist-info/METADATA +151 -0
  164. librelane-2.4.0.dev0.dist-info/RECORD +166 -0
  165. librelane-2.4.0.dev0.dist-info/WHEEL +4 -0
  166. librelane-2.4.0.dev0.dist-info/entry_points.txt +8 -0
@@ -0,0 +1,177 @@
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 re
16
+
17
+
18
+ class ABCScriptCreator:
19
+ def __init__(self, config):
20
+ self.config = config
21
+
22
+ self.rs_K = "resub -K "
23
+ self.rs = "resub"
24
+ self.rsz = "resub -z"
25
+ self.rf = "drf -l"
26
+ self.rfz = "drf -l -z"
27
+ self.rw = "drw -l"
28
+ self.rwz = "drw -l -z"
29
+ self.rw_K = "drw -l -K"
30
+
31
+ if config["SYNTH_ABC_LEGACY_REFACTOR"]:
32
+ self.rf = "refactor"
33
+ self.rfz = "refactor -z"
34
+
35
+ if config["SYNTH_ABC_LEGACY_REWRITE"]:
36
+ self.rw = "rewrite"
37
+ self.rwz = "rewrite -z"
38
+ self.rw_K = "rewrite -K"
39
+
40
+ self.b = "balance"
41
+ self.resyn2 = f"{self.b}; {self.rw}; {self.rf}; {self.b}; {self.rw}; {self.rwz}; {self.b}; {self.rfz}; {self.rwz}; {self.b}"
42
+ self.share = f"strash; multi -m; {self.resyn2}"
43
+ self.resyn2a = f"{self.b};{self.rw};{self.b};{self.rw};{self.rwz};{self.b};{self.rwz};{self.b}"
44
+ self.resyn3 = f"{self.b}; resub; resub -K 6; {self.b};resub -z;resub -z -K 6; {self.b};resub -z -K 5; {self.b}"
45
+ self.resyn2rs = f"{self.b};{self.rs_K} 6;{self.rw};{self.rs_K} 6 -N 2;{self.rf};{self.rs_K} 8;{self.rw};{self.rs_K} 10;{self.rwz};{self.rs_K} 10 -N 2;{self.b} {self.rs_K} 12;{self.rfz};{self.rs_K} 12 -N 2;{self.rwz};{self.b}"
46
+
47
+ self.choice = f"fraig_store; {self.resyn2}; fraig_store; {self.resyn2}; fraig_store; fraig_restore"
48
+ self.choice2 = f"fraig_store; {self.b}; fraig_store; {self.resyn2}; fraig_store; {self.resyn2}; fraig_store; {self.resyn2}; fraig_store; fraig_restore"
49
+
50
+ self.area_mfs3 = ""
51
+ self.delay_mfs3 = ""
52
+ if config["SYNTH_ABC_USE_MFS3"]:
53
+ self.area_mfs3 = "mfs3 -aemvz -I 4 -O 2"
54
+ self.delay_mfs3 = "mfs3 -emvz -I 4 -O 2"
55
+
56
+ self.map_old_area = "map -p -a -B 0.2 -A 0.9 -M 0"
57
+ self.map_old_dly = "map -p -B 0.2 -A 0.9 -M 0"
58
+ self.retime_area = "retime {D} -M 5"
59
+ self.retime_dly = "retime {D} -M 6"
60
+ self.map_new_area = "amap -m -Q 0.1 -F 20 -A 20 -C 5000"
61
+
62
+ if config["SYNTH_ABC_AREA_USE_NF"]:
63
+ self.map_new_area = "&get -n; &nf -R 1000; &put"
64
+
65
+ self.max_fanout = config["MAX_FANOUT_CONSTRAINT"]
66
+ self.max_transition = (
67
+ config.get("MAX_TRANSITION_CONSTRAINT") or 0
68
+ ) * 1000 # ns -> ps
69
+ self.fine_tune = ""
70
+ if config["SYNTH_ABC_BUFFERING"]:
71
+ max_tr_arg = ""
72
+ if self.max_transition != 0:
73
+ max_tr_arg = f" -S {self.max_transition}"
74
+ self.fine_tune = (
75
+ f"buffer -N {self.max_fanout}{max_tr_arg};upsize {{D}};dnsize {{D}}"
76
+ )
77
+ elif config["SYNTH_SIZING"]:
78
+ self.fine_tune = "upsize {D};dnsize {D}"
79
+
80
+ def generate_abc_script(self, step_dir, strategy):
81
+ strategy_clean = re.sub(r"\s+", "_", strategy)
82
+ abc_script_path = os.path.join(step_dir, f"{strategy_clean}.abc")
83
+ f = open(abc_script_path, "w")
84
+
85
+ if strategy == "AREA 3":
86
+ # ORFS Area Script
87
+ print("strash", file=f)
88
+ print("dch", file=f)
89
+ print("map -B 0.9", file=f)
90
+ print("topo", file=f)
91
+ print("stime -c", file=f)
92
+ print(f"buffer -c -N {self.max_fanout}", file=f)
93
+ print("upsize -c", file=f)
94
+ print("dnsize -c", file=f)
95
+ elif strategy == "DELAY 4":
96
+ # ORFS Delay Script
97
+ def repeated_sequence(f):
98
+ print("&st", file=f)
99
+ print("&syn2", file=f)
100
+ print("&if -g -K 6", file=f)
101
+ print("&synch2", file=f)
102
+ print("&nf", file=f)
103
+
104
+ print("&get -n", file=f)
105
+ print("&st", file=f)
106
+ print("&dch", file=f)
107
+ print("&nf", file=f)
108
+
109
+ for _ in range(5):
110
+ repeated_sequence(f)
111
+
112
+ print("&put", file=f)
113
+ print(f"buffer -c -N {self.max_fanout}", file=f)
114
+ print("topo", file=f)
115
+ print("stime -c", file=f)
116
+ print("upsize -c", file=f)
117
+ print("dnsize -c", file=f)
118
+ else:
119
+ print("fx", file=f)
120
+ print("mfs", file=f)
121
+ print("strash", file=f)
122
+ print(self.rf, file=f)
123
+
124
+ # Resynth/Retime
125
+ if strategy == "AREA 2":
126
+ print(self.choice2, file=f)
127
+ else:
128
+ print(self.resyn2, file=f)
129
+ if strategy.startswith("AREA ") or strategy == "DELAY 3":
130
+ print(self.retime_area, file=f)
131
+ else:
132
+ print(self.retime_dly, file=f)
133
+ print("scleanup", file=f)
134
+
135
+ if strategy in ["AREA 4", "DELAY 2"]:
136
+ print(self.choice, file=f)
137
+ elif strategy != "DELAY 0":
138
+ print(self.choice2, file=f)
139
+ if strategy.startswith("AREA ") or strategy == "DELAY 3":
140
+ print(self.map_new_area, file=f)
141
+ else:
142
+ print(self.map_old_dly, file=f)
143
+
144
+ # Area Recovery
145
+ if strategy in ["AREA 1", "AREA 2"]:
146
+ print(self.choice2, file=f)
147
+ print(self.map_new_area, file=f)
148
+ elif strategy in ["DELAY 1"]:
149
+ print(self.choice2, file=f)
150
+ print("map", file=f)
151
+ elif strategy in ["DELAY 2"]:
152
+ print(self.choice, file=f)
153
+ print("map", file=f)
154
+ elif strategy in ["DELAY 3"]:
155
+ print(self.choice2, file=f)
156
+ print(self.map_old_dly, file=f)
157
+
158
+ if strategy.startswith("AREA "):
159
+ print(self.area_mfs3, file=f)
160
+ else:
161
+ print(self.delay_mfs3, file=f)
162
+
163
+ print("retime {D}", file=f)
164
+
165
+ # & space
166
+ print("&get -n", file=f)
167
+ print("&st", file=f)
168
+ print("&dch", file=f)
169
+ print("&nf", file=f)
170
+ print("&put", file=f)
171
+ print(self.fine_tune, file=f)
172
+
173
+ # Common Conclusion
174
+ print("stime -p", file=f)
175
+ print("print_stats -m", file=f)
176
+ f.close()
177
+ return abc_script_path
@@ -0,0 +1,84 @@
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 json
15
+
16
+ import click
17
+
18
+ from ys_common import ys
19
+
20
+
21
+ @click.command()
22
+ @click.option("--output", type=click.Path(exists=False, dir_okay=False), required=True)
23
+ @click.option(
24
+ "--config-in", type=click.Path(exists=True, dir_okay=False), required=True
25
+ )
26
+ @click.option("--extra-in", type=click.Path(exists=True, dir_okay=False), required=True)
27
+ def json_header(
28
+ output,
29
+ config_in,
30
+ extra_in,
31
+ ):
32
+ config = json.load(open(config_in))
33
+ extra = json.load(open(extra_in))
34
+
35
+ blackbox_models = extra["blackbox_models"]
36
+
37
+ includes = config["VERILOG_INCLUDE_DIRS"] or []
38
+ defines = (
39
+ (config["VERILOG_DEFINES"] or [])
40
+ + [
41
+ f"PDK_{config['PDK']}",
42
+ f"SCL_{config['STD_CELL_LIBRARY']}",
43
+ "__librelane__",
44
+ "__pnr__",
45
+ ]
46
+ + (
47
+ []
48
+ if config.get("VERILOG_POWER_DEFINE") is None
49
+ else [config.get("VERILOG_POWER_DEFINE")]
50
+ )
51
+ )
52
+
53
+ d = ys.Design()
54
+ d.add_blackbox_models(
55
+ blackbox_models,
56
+ includes=includes,
57
+ defines=defines,
58
+ )
59
+ d.read_verilog_files(
60
+ config["VERILOG_FILES"],
61
+ top=config["DESIGN_NAME"],
62
+ synth_parameters=config["SYNTH_PARAMETERS"] or [],
63
+ includes=includes,
64
+ defines=defines,
65
+ use_synlig=config["USE_SYNLIG"],
66
+ synlig_defer=config["SYNLIG_DEFER"],
67
+ )
68
+ d.run_pass(
69
+ "hierarchy",
70
+ "-check",
71
+ "-top",
72
+ config["DESIGN_NAME"],
73
+ "-nokeep_prints",
74
+ "-nokeep_asserts",
75
+ )
76
+ d.run_pass("rename", "-top", config["DESIGN_NAME"])
77
+ d.run_pass("proc")
78
+ d.run_pass("flatten")
79
+ d.run_pass("opt_clean", "-purge")
80
+ d.run_pass("json", "-o", output)
81
+
82
+
83
+ if __name__ == "__main__":
84
+ json_header()