siliconcompiler 0.35.2__py3-none-any.whl → 0.35.4__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 (86) hide show
  1. siliconcompiler/_metadata.py +1 -1
  2. siliconcompiler/apps/sc_issue.py +18 -2
  3. siliconcompiler/apps/smake.py +106 -100
  4. siliconcompiler/checklist.py +2 -1
  5. siliconcompiler/constraints/asic_component.py +49 -11
  6. siliconcompiler/constraints/asic_floorplan.py +23 -21
  7. siliconcompiler/constraints/asic_pins.py +55 -17
  8. siliconcompiler/constraints/asic_timing.py +53 -22
  9. siliconcompiler/constraints/fpga_timing.py +5 -6
  10. siliconcompiler/data/templates/replay/replay.sh.j2 +27 -14
  11. siliconcompiler/flowgraph.py +418 -129
  12. siliconcompiler/library.py +5 -4
  13. siliconcompiler/package/__init__.py +17 -6
  14. siliconcompiler/package/https.py +10 -5
  15. siliconcompiler/project.py +92 -33
  16. siliconcompiler/remote/client.py +17 -6
  17. siliconcompiler/scheduler/docker.py +24 -25
  18. siliconcompiler/scheduler/scheduler.py +284 -121
  19. siliconcompiler/scheduler/schedulernode.py +196 -90
  20. siliconcompiler/scheduler/slurm.py +113 -29
  21. siliconcompiler/scheduler/taskscheduler.py +0 -7
  22. siliconcompiler/schema/__init__.py +3 -2
  23. siliconcompiler/schema/_metadata.py +1 -1
  24. siliconcompiler/schema/baseschema.py +205 -93
  25. siliconcompiler/schema/editableschema.py +29 -0
  26. siliconcompiler/schema/namedschema.py +21 -13
  27. siliconcompiler/schema/parametervalue.py +14 -2
  28. siliconcompiler/schema/safeschema.py +18 -7
  29. siliconcompiler/schema_support/dependencyschema.py +4 -3
  30. siliconcompiler/schema_support/option.py +82 -1
  31. siliconcompiler/schema_support/pathschema.py +14 -15
  32. siliconcompiler/schema_support/record.py +5 -4
  33. siliconcompiler/targets/asap7_demo.py +4 -1
  34. siliconcompiler/tool.py +56 -29
  35. siliconcompiler/tools/builtin/__init__.py +2 -0
  36. siliconcompiler/tools/builtin/filter.py +8 -1
  37. siliconcompiler/tools/builtin/importfiles.py +2 -0
  38. siliconcompiler/tools/klayout/__init__.py +3 -0
  39. siliconcompiler/tools/klayout/scripts/klayout_convert_drc_db.py +1 -0
  40. siliconcompiler/tools/klayout/scripts/klayout_export.py +1 -0
  41. siliconcompiler/tools/klayout/scripts/klayout_operations.py +1 -0
  42. siliconcompiler/tools/klayout/scripts/klayout_show.py +2 -1
  43. siliconcompiler/tools/klayout/scripts/klayout_utils.py +3 -4
  44. siliconcompiler/tools/klayout/show.py +17 -5
  45. siliconcompiler/tools/openroad/__init__.py +27 -1
  46. siliconcompiler/tools/openroad/_apr.py +81 -4
  47. siliconcompiler/tools/openroad/clock_tree_synthesis.py +1 -0
  48. siliconcompiler/tools/openroad/global_placement.py +1 -0
  49. siliconcompiler/tools/openroad/init_floorplan.py +116 -7
  50. siliconcompiler/tools/openroad/power_grid_analysis.py +174 -0
  51. siliconcompiler/tools/openroad/repair_design.py +1 -0
  52. siliconcompiler/tools/openroad/repair_timing.py +1 -0
  53. siliconcompiler/tools/openroad/scripts/apr/preamble.tcl +1 -1
  54. siliconcompiler/tools/openroad/scripts/apr/sc_init_floorplan.tcl +42 -4
  55. siliconcompiler/tools/openroad/scripts/apr/sc_irdrop.tcl +146 -0
  56. siliconcompiler/tools/openroad/scripts/apr/sc_repair_design.tcl +1 -1
  57. siliconcompiler/tools/openroad/scripts/apr/sc_write_data.tcl +4 -6
  58. siliconcompiler/tools/openroad/scripts/common/procs.tcl +1 -1
  59. siliconcompiler/tools/openroad/scripts/common/reports.tcl +1 -1
  60. siliconcompiler/tools/openroad/scripts/rcx/sc_rcx_bench.tcl +2 -4
  61. siliconcompiler/tools/opensta/__init__.py +1 -1
  62. siliconcompiler/tools/opensta/scripts/sc_timing.tcl +17 -12
  63. siliconcompiler/tools/vivado/scripts/sc_bitstream.tcl +11 -0
  64. siliconcompiler/tools/vivado/scripts/sc_place.tcl +11 -0
  65. siliconcompiler/tools/vivado/scripts/sc_route.tcl +11 -0
  66. siliconcompiler/tools/vivado/scripts/sc_syn_fpga.tcl +10 -0
  67. siliconcompiler/tools/vpr/__init__.py +28 -0
  68. siliconcompiler/tools/yosys/prepareLib.py +7 -2
  69. siliconcompiler/tools/yosys/scripts/sc_screenshot.tcl +1 -1
  70. siliconcompiler/tools/yosys/scripts/sc_synth_asic.tcl +40 -4
  71. siliconcompiler/tools/yosys/scripts/sc_synth_fpga.tcl +15 -5
  72. siliconcompiler/tools/yosys/syn_asic.py +62 -2
  73. siliconcompiler/tools/yosys/syn_fpga.py +8 -0
  74. siliconcompiler/toolscripts/_tools.json +6 -6
  75. siliconcompiler/utils/__init__.py +243 -51
  76. siliconcompiler/utils/curation.py +89 -56
  77. siliconcompiler/utils/issue.py +6 -1
  78. siliconcompiler/utils/multiprocessing.py +35 -2
  79. siliconcompiler/utils/paths.py +21 -0
  80. siliconcompiler/utils/settings.py +141 -0
  81. {siliconcompiler-0.35.2.dist-info → siliconcompiler-0.35.4.dist-info}/METADATA +5 -4
  82. {siliconcompiler-0.35.2.dist-info → siliconcompiler-0.35.4.dist-info}/RECORD +86 -83
  83. {siliconcompiler-0.35.2.dist-info → siliconcompiler-0.35.4.dist-info}/WHEEL +0 -0
  84. {siliconcompiler-0.35.2.dist-info → siliconcompiler-0.35.4.dist-info}/entry_points.txt +0 -0
  85. {siliconcompiler-0.35.2.dist-info → siliconcompiler-0.35.4.dist-info}/licenses/LICENSE +0 -0
  86. {siliconcompiler-0.35.2.dist-info → siliconcompiler-0.35.4.dist-info}/top_level.txt +0 -0
@@ -1,5 +1,5 @@
1
1
  # Version number following semver standard.
2
- version = '0.35.2'
2
+ version = '0.35.4'
3
3
 
4
4
  # Default server address for remote runs, if unspecified.
5
5
  default_server = 'https://server.siliconcompiler.com'
@@ -72,6 +72,21 @@ To run a testcase, use:
72
72
  if not issue.get("cmdarg", "run"):
73
73
  project: Project = Project.from_manifest(filepath=issue.get("cmdarg", "cfg"))
74
74
 
75
+ # Determine abs path for build dir
76
+ builddir = project.option.get_builddir()
77
+ if isinstance(builddir, str) and not os.path.isabs(builddir):
78
+ builddirname = os.path.basename(builddir)
79
+ fullpath = os.path.dirname(os.path.abspath(issue.get("cmdarg", "cfg")))
80
+ while True:
81
+ if os.path.basename(fullpath) == builddirname:
82
+ project.option.set_builddir(fullpath)
83
+ break
84
+ parent = os.path.dirname(fullpath)
85
+ if parent == fullpath:
86
+ # Reached filesystem root without finding a match
87
+ break
88
+ fullpath = parent
89
+
75
90
  if issue.get("arg", "step"):
76
91
  project.set("arg", "step", issue.get("arg", "step"))
77
92
  if issue.get("arg", "index"):
@@ -143,8 +158,9 @@ To run a testcase, use:
143
158
 
144
159
  # Modify run environment to point to extracted files
145
160
  builddir_key = ['option', 'builddir']
146
- new_builddir = f"{test_dir}/{project.get(*builddir_key)}"
147
- project.logger.info(f"Changing {builddir_key} to '{new_builddir}'")
161
+ new_builddir = os.path.abspath(
162
+ os.path.join(test_dir, f"{os.path.basename(project.get(*builddir_key))}"))
163
+ project.logger.info(f"Changing [{','.join(builddir_key)}] to '{new_builddir}'")
148
164
  project.set(*builddir_key, new_builddir)
149
165
 
150
166
  # Run task
@@ -12,8 +12,8 @@ Python without the need for complex boilerplate code.
12
12
  """
13
13
  import argparse
14
14
  import sys
15
+ import tempfile
15
16
 
16
- import importlib.util
17
17
  import os.path
18
18
 
19
19
  from typing import Union, Tuple, Optional, Dict
@@ -29,7 +29,7 @@ from siliconcompiler.schema import utils
29
29
  __default_source_file = "make.py"
30
30
 
31
31
 
32
- def __process_file(path: Union[Path, str]) -> Tuple[Dict, Optional[str], Optional[str]]:
32
+ def __process_file(path: Union[Path, str], dir: str) -> Tuple[Dict, Optional[str], Optional[str]]:
33
33
  """
34
34
  Dynamically loads a Python module and inspects it for runnable targets.
35
35
 
@@ -54,16 +54,18 @@ def __process_file(path: Union[Path, str]) -> Tuple[Dict, Optional[str], Optiona
54
54
  if not os.path.exists(path):
55
55
  return {}, None, None
56
56
 
57
+ mod_name, _ = os.path.splitext(os.path.basename(path))
58
+
57
59
  # Dynamically load the specified file as a Python module.
58
- mod_name = 'scmake'
59
- spec = importlib.util.spec_from_file_location(mod_name, path)
60
- make = importlib.util.module_from_spec(spec)
61
- sys.modules[mod_name] = make
62
- # Temporarily add CWD to path to allow the makefile to import local modules.
63
- syspath = sys.path.copy()
60
+ with open(os.path.join(dir, "sc_module_load.py"), "w") as f:
61
+ f.write(f"import {mod_name} as make\n")
62
+
64
63
  sys.path.insert(0, os.getcwd())
65
- spec.loader.exec_module(make)
66
- sys.path = syspath
64
+ sys.path.insert(0, os.path.dirname(path))
65
+
66
+ # Load newly created file
67
+ import sc_module_load
68
+ make = sc_module_load.make
67
69
 
68
70
  # Inspect the module for public functions to treat as targets.
69
71
  args = {}
@@ -172,100 +174,104 @@ To run a target with arguments, use:
172
174
  print(f"Error: Unable to change directory to {source_dir}")
173
175
  return 1
174
176
 
175
- # --- Process the source file to discover targets ---
176
- make_args, default_arg, module_help = __process_file(source_file) \
177
- if source_file else ({}, None, None)
178
-
179
- if module_help:
180
- description += f"\n\n{module_help}\n\n"
181
- description += "-----------------------------------------------------------"
182
-
183
- # --- Set up the main argument parser ---
184
- parser = argparse.ArgumentParser(
185
- progname,
186
- description=description,
187
- formatter_class=argparse.RawDescriptionHelpFormatter)
188
-
189
- parser.add_argument(
190
- '--file', '-f',
191
- metavar='<file>',
192
- help=f'Use file as makefile, default is {__default_source_file}')
193
- parser.add_argument(
194
- '--directory', '-C',
195
- metavar='<directory>',
196
- help='Change to directory <directory> before reading the makefile.')
197
- parser.add_argument(
198
- '--version', '-v',
199
- action='version',
200
- version=f"%(prog)s {version}")
201
-
202
- # --- Create subparsers for each discovered target ---
203
- targetparsers = parser.add_subparsers(
204
- dest='target',
205
- metavar='<target>',
206
- help='Target to execute')
207
-
208
- for arg, info in make_args.items():
209
- subparse = targetparsers.add_parser(
210
- arg,
211
- description=info['full_help'],
212
- help=info['help'],
213
- formatter_class=argparse.RawDescriptionHelpFormatter)
177
+ with tempfile.TemporaryDirectory(prefix="smake") as dir:
178
+ # Add temp dir to path
179
+ sys.path.insert(0, dir)
214
180
 
215
- # Add arguments for each parameter of the target function.
216
- for subarg, subarg_info in info['args'].items():
217
- add_args = {}
218
- if "default" not in subarg_info:
219
- add_args["required"] = True
220
- else:
221
- add_args["default"] = subarg_info["default"]
222
-
223
- # Handle boolean arguments correctly.
224
- arg_type = subarg_info["type"]
225
- if arg_type is bool:
226
- # Use a custom string-to-boolean converter.
227
- def str2bool(v):
228
- val = str(v).lower()
229
- if val in ('y', 'yes', 't', 'true', 'on', '1'):
230
- return True
231
- elif val in ('n', 'no', 'f', 'false', 'off', '0'):
232
- return False
233
- raise ValueError(f"invalid truth value {val!r}")
234
- arg_type = str2bool
235
-
236
- subparse.add_argument(
237
- f'--{subarg}',
238
- dest=f'sub_{subarg}',
239
- metavar=f'<{subarg}>',
240
- type=arg_type,
241
- **add_args)
242
-
243
- # --- Parse arguments and execute the target ---
244
- args = parser.parse_args()
245
- target = args.target or default_arg
246
-
247
- if not target:
248
- if make_args:
249
- print("Error: No target specified and no default target found.")
250
- parser.print_help()
251
- else:
252
- print(f"Error: Unable to load makefile '{source_file}'.")
253
- return 1
181
+ # --- Process the source file to discover targets ---
182
+ make_args, default_arg, module_help = __process_file(source_file, dir) \
183
+ if source_file else ({}, None, None)
254
184
 
255
- if target not in make_args:
256
- print(f"Error: Target '{target}' not found in '{source_file}'.")
257
- return 1
185
+ if module_help:
186
+ description += f"\n\n{module_help}\n\n"
187
+ description += "-----------------------------------------------------------"
258
188
 
259
- # Prepare arguments to pass to the target function.
260
- call_args = {}
261
- args_vars = vars(args)
262
- for arg in make_args[target]["args"]:
263
- arg_key = f'sub_{arg}'
264
- if arg_key in args_vars and args_vars[arg_key] is not None:
265
- call_args[arg] = args_vars[arg_key]
189
+ # --- Set up the main argument parser ---
190
+ parser = argparse.ArgumentParser(
191
+ progname,
192
+ description=description,
193
+ formatter_class=argparse.RawDescriptionHelpFormatter)
266
194
 
267
- # Call the selected function with its arguments.
268
- make_args[target]["function"](**call_args)
195
+ parser.add_argument(
196
+ '--file', '-f',
197
+ metavar='<file>',
198
+ help=f'Use file as makefile, default is {__default_source_file}')
199
+ parser.add_argument(
200
+ '--directory', '-C',
201
+ metavar='<directory>',
202
+ help='Change to directory <directory> before reading the makefile.')
203
+ parser.add_argument(
204
+ '--version', '-v',
205
+ action='version',
206
+ version=f"%(prog)s {version}")
207
+
208
+ # --- Create subparsers for each discovered target ---
209
+ targetparsers = parser.add_subparsers(
210
+ dest='target',
211
+ metavar='<target>',
212
+ help='Target to execute')
213
+
214
+ for arg, info in make_args.items():
215
+ subparse = targetparsers.add_parser(
216
+ arg,
217
+ description=info['full_help'],
218
+ help=info['help'],
219
+ formatter_class=argparse.RawDescriptionHelpFormatter)
220
+
221
+ # Add arguments for each parameter of the target function.
222
+ for subarg, subarg_info in info['args'].items():
223
+ add_args = {}
224
+ if "default" not in subarg_info:
225
+ add_args["required"] = True
226
+ else:
227
+ add_args["default"] = subarg_info["default"]
228
+
229
+ # Handle boolean arguments correctly.
230
+ arg_type = subarg_info["type"]
231
+ if arg_type is bool:
232
+ # Use a custom string-to-boolean converter.
233
+ def str2bool(v):
234
+ val = str(v).lower()
235
+ if val in ('y', 'yes', 't', 'true', 'on', '1'):
236
+ return True
237
+ elif val in ('n', 'no', 'f', 'false', 'off', '0'):
238
+ return False
239
+ raise ValueError(f"invalid truth value {val!r}")
240
+ arg_type = str2bool
241
+
242
+ subparse.add_argument(
243
+ f'--{subarg}',
244
+ dest=f'sub_{subarg}',
245
+ metavar=f'<{subarg}>',
246
+ type=arg_type,
247
+ **add_args)
248
+
249
+ # --- Parse arguments and execute the target ---
250
+ args = parser.parse_args()
251
+ target = args.target or default_arg
252
+
253
+ if not target:
254
+ if make_args:
255
+ print("Error: No target specified and no default target found.")
256
+ parser.print_help()
257
+ else:
258
+ print(f"Error: Unable to load makefile '{source_file}'.")
259
+ return 1
260
+
261
+ if target not in make_args:
262
+ print(f"Error: Target '{target}' not found in '{source_file}'.")
263
+ return 1
264
+
265
+ # Prepare arguments to pass to the target function.
266
+ call_args = {}
267
+ args_vars = vars(args)
268
+ for arg in make_args[target]["args"]:
269
+ arg_key = f'sub_{arg}'
270
+ if arg_key in args_vars and args_vars[arg_key] is not None:
271
+ call_args[arg] = args_vars[arg_key]
272
+
273
+ # Call the selected function with its arguments.
274
+ make_args[target]["function"](**call_args)
269
275
 
270
276
  return 0
271
277
 
@@ -6,6 +6,7 @@ from typing import Tuple, List, Optional, Union, Dict, Iterable
6
6
  from siliconcompiler.schema import NamedSchema, EditableSchema, Parameter, Scope, BaseSchema
7
7
  from siliconcompiler.schema.utils import trim
8
8
  from siliconcompiler import NodeStatus, utils
9
+ from siliconcompiler.utils.paths import cwdirsafe
9
10
 
10
11
 
11
12
  class Criteria(NamedSchema):
@@ -328,7 +329,7 @@ class Checklist(NamedSchema):
328
329
 
329
330
  schema_root = self._parent(root=True)
330
331
  logger = getattr(schema_root, "logger", None)
331
- cwd = getattr(schema_root, "_Project__cwd", os.getcwd())
332
+ cwd = cwdirsafe(schema_root)
332
333
 
333
334
  assert hasattr(schema_root, "history"), f"{schema_root}"
334
335
 
@@ -1,4 +1,4 @@
1
- from typing import Tuple, Union
1
+ from typing import Tuple, Union, Optional
2
2
 
3
3
  from siliconcompiler.schema import BaseSchema, NamedSchema, EditableSchema, Parameter, \
4
4
  PerNode, Scope
@@ -13,7 +13,7 @@ class ASICComponentConstraint(NamedSchema):
13
13
  keepout halo, and rotation.
14
14
  """
15
15
 
16
- def __init__(self, name: str = None):
16
+ def __init__(self, name: Optional[str] = None):
17
17
  super().__init__()
18
18
  self.set_name(name)
19
19
 
@@ -113,7 +113,8 @@ class ASICComponentConstraint(NamedSchema):
113
113
  270 deg ccw
114
114
  """))
115
115
 
116
- def set_placement(self, x: float, y: float, step: str = None, index: Union[str, int] = None):
116
+ def set_placement(self, x: float, y: float,
117
+ step: Optional[str] = None, index: Optional[Union[str, int]] = None):
117
118
  """
118
119
  Sets the placement constraint for the component.
119
120
 
@@ -134,7 +135,8 @@ class ASICComponentConstraint(NamedSchema):
134
135
  raise TypeError("y must be a number")
135
136
  return self.set("placement", (x, y), step=step, index=index)
136
137
 
137
- def get_placement(self, step: str = None, index: Union[str, int] = None) -> Tuple[float, float]:
138
+ def get_placement(self, step: Optional[str] = None, index: Optional[Union[str, int]] = None) \
139
+ -> Tuple[float, float]:
138
140
  """
139
141
  Retrieves the current placement constraint of the component.
140
142
 
@@ -148,7 +150,8 @@ class ASICComponentConstraint(NamedSchema):
148
150
  """
149
151
  return self.get("placement", step=step, index=index)
150
152
 
151
- def set_partname(self, name: str, step: str = None, index: Union[str, int] = None):
153
+ def set_partname(self, name: str,
154
+ step: Optional[str] = None, index: Optional[Union[str, int]] = None):
152
155
  """
153
156
  Sets the part name (cell name) constraint for the component.
154
157
 
@@ -165,7 +168,8 @@ class ASICComponentConstraint(NamedSchema):
165
168
  raise ValueError("a partname is required")
166
169
  return self.set("partname", name, step=step, index=index)
167
170
 
168
- def get_partname(self, step: str = None, index: Union[str, int] = None) -> str:
171
+ def get_partname(self, step: Optional[str] = None, index: Optional[Union[str, int]] = None) \
172
+ -> str:
169
173
  """
170
174
  Retrieves the current part name (cell name) constraint of the component.
171
175
 
@@ -178,7 +182,8 @@ class ASICComponentConstraint(NamedSchema):
178
182
  """
179
183
  return self.get("partname", step=step, index=index)
180
184
 
181
- def set_halo(self, x: float, y: float, step: str = None, index: Union[str, int] = None):
185
+ def set_halo(self, x: float, y: float,
186
+ step: Optional[str] = None, index: Optional[Union[str, int]] = None):
182
187
  """
183
188
  Sets the placement keepout halo constraint around the component.
184
189
 
@@ -204,7 +209,8 @@ class ASICComponentConstraint(NamedSchema):
204
209
  raise ValueError("y must be a positive number")
205
210
  return self.set("halo", (x, y), step=step, index=index)
206
211
 
207
- def get_halo(self, step: str = None, index: Union[str, int] = None) -> Tuple[float, float]:
212
+ def get_halo(self, step: Optional[str] = None, index: Optional[Union[str, int]] = None) \
213
+ -> Tuple[float, float]:
208
214
  """
209
215
  Retrieves the current placement keepout halo constraint of the component.
210
216
 
@@ -218,7 +224,8 @@ class ASICComponentConstraint(NamedSchema):
218
224
  """
219
225
  return self.get("halo", step=step, index=index)
220
226
 
221
- def set_rotation(self, rotation: str, step: str = None, index: Union[str, int] = None):
227
+ def set_rotation(self, rotation: str,
228
+ step: Optional[str] = None, index: Optional[Union[str, int]] = None):
222
229
  """
223
230
  Sets the rotation constraint for the component.
224
231
 
@@ -231,7 +238,8 @@ class ASICComponentConstraint(NamedSchema):
231
238
  """
232
239
  return self.set("rotation", rotation, step=step, index=index)
233
240
 
234
- def get_rotation(self, step: str = None, index: Union[str, int] = None) -> str:
241
+ def get_rotation(self, step: Optional[str] = None, index: Optional[Union[str, int]] = None) \
242
+ -> str:
235
243
  """
236
244
  Retrieves the current rotation constraint of the component.
237
245
 
@@ -286,7 +294,7 @@ class ASICComponentConstraints(BaseSchema):
286
294
 
287
295
  EditableSchema(self).insert(component.name, component, clobber=True)
288
296
 
289
- def get_component(self, component: str = None):
297
+ def get_component(self, component: Optional[str] = None):
290
298
  """
291
299
  Retrieves one or all component constraints from the configuration.
292
300
 
@@ -350,6 +358,36 @@ class ASICComponentConstraints(BaseSchema):
350
358
  self.add_component(constraint)
351
359
  return constraint
352
360
 
361
+ def copy_component(self, component: str, name: str, insert: bool = True) \
362
+ -> ASICComponentConstraint:
363
+ """
364
+ Copies an existing component constraint, renames it, and optionally adds it to the design.
365
+
366
+ This method retrieves the component constraint identified by ``component``, creates a
367
+ deep copy of it, and renames the copy to ``name``. If ``insert`` is True,
368
+ the new constraint is immediately added to the configuration.
369
+
370
+ Args:
371
+ component (str): The name of the existing component constraint to be copied.
372
+ name (str): The name to assign to the new copied constraint.
373
+ insert (bool, optional): Whether to add the newly created constraint
374
+ to the configuration. Defaults to True.
375
+
376
+ Returns:
377
+ ASICComponentConstraint: The newly created copy of the component constraint.
378
+
379
+ Raises:
380
+ LookupError: If the source component constraint specified by ``component`` does not
381
+ exist.
382
+ """
383
+ constraint = EditableSchema(self.get_component(component)).copy()
384
+ EditableSchema(constraint).rename(name)
385
+ if insert:
386
+ if self.valid(name):
387
+ raise ValueError(f"{name} already exists")
388
+ self.add_component(constraint)
389
+ return constraint
390
+
353
391
  def remove_component(self, component: str) -> bool:
354
392
  """
355
393
  Removes a component constraint from the design configuration.
@@ -1,4 +1,4 @@
1
- from typing import Union, List, Tuple
1
+ from typing import Union, List, Tuple, Optional
2
2
 
3
3
  from siliconcompiler.schema import BaseSchema, EditableSchema, Parameter, PerNode, Scope
4
4
 
@@ -99,9 +99,9 @@ class ASICAreaConstraint(BaseSchema):
99
99
 
100
100
  def set_density(self,
101
101
  density: float,
102
- aspectratio: float = None,
103
- coremargin: float = None,
104
- step: str = None, index: Union[str, int] = None):
102
+ aspectratio: Optional[float] = None,
103
+ coremargin: Optional[float] = None,
104
+ step: Optional[str] = None, index: Optional[Union[str, int]] = None):
105
105
  """
106
106
  Sets the target layout density.
107
107
 
@@ -145,7 +145,8 @@ class ASICAreaConstraint(BaseSchema):
145
145
  params.append(self.set_coremargin(coremargin, step=step, index=index))
146
146
  return params
147
147
 
148
- def get_density(self, step: str = None, index: Union[str, int] = None) -> float:
148
+ def get_density(self, step: Optional[str] = None, index: Optional[Union[str, int]] = None) \
149
+ -> float:
149
150
  """
150
151
  Retrieves the current target layout density.
151
152
 
@@ -162,7 +163,7 @@ class ASICAreaConstraint(BaseSchema):
162
163
 
163
164
  def set_aspectratio(self,
164
165
  aspectratio: float,
165
- step: str = None, index: Union[str, int] = None):
166
+ step: Optional[str] = None, index: Optional[Union[str, int]] = None):
166
167
  """
167
168
  Sets the layout aspect ratio.
168
169
 
@@ -192,8 +193,8 @@ class ASICAreaConstraint(BaseSchema):
192
193
 
193
194
  return self.set("aspectratio", aspectratio, step=step, index=index)
194
195
 
195
- def get_aspectratio(self,
196
- step: str = None, index: Union[str, int] = None) -> float:
196
+ def get_aspectratio(self, step: Optional[str] = None, index: Optional[Union[str, int]] = None) \
197
+ -> float:
197
198
  """
198
199
  Retrieves the current layout aspect ratio.
199
200
 
@@ -210,7 +211,7 @@ class ASICAreaConstraint(BaseSchema):
210
211
 
211
212
  def set_coremargin(self,
212
213
  coremargin: float,
213
- step: str = None, index: Union[str, int] = None):
214
+ step: Optional[str] = None, index: Optional[Union[str, int]] = None):
214
215
  """
215
216
  Sets the core margin.
216
217
 
@@ -240,8 +241,8 @@ class ASICAreaConstraint(BaseSchema):
240
241
 
241
242
  return self.set("coremargin", coremargin, step=step, index=index)
242
243
 
243
- def get_coremargin(self,
244
- step: str = None, index: Union[str, int] = None) -> float:
244
+ def get_coremargin(self, step: Optional[str] = None, index: Optional[Union[str, int]] = None) \
245
+ -> float:
245
246
  """
246
247
  Retrieves the current core margin.
247
248
 
@@ -259,8 +260,8 @@ class ASICAreaConstraint(BaseSchema):
259
260
  def set_diearea_rectangle(self,
260
261
  height: float,
261
262
  width: float,
262
- coremargin: Union[float, Tuple[float, float]] = None,
263
- step: str = None, index: Union[str, int] = None):
263
+ coremargin: Optional[Union[float, Tuple[float, float]]] = None,
264
+ step: Optional[str] = None, index: Optional[Union[str, int]] = None):
264
265
  """
265
266
  Sets the die area as a rectangle with its bottom-left corner at (0,0).
266
267
 
@@ -311,7 +312,7 @@ class ASICAreaConstraint(BaseSchema):
311
312
  dieheight: float,
312
313
  diewidth: float,
313
314
  coremargin: Union[float, Tuple[float, float]],
314
- step: str = None, index: Union[str, int] = None):
315
+ step: Optional[str] = None, index: Optional[Union[str, int]] = None):
315
316
  """
316
317
  Sets the core area as a rectangle within a die area, based on margins.
317
318
 
@@ -378,7 +379,7 @@ class ASICAreaConstraint(BaseSchema):
378
379
 
379
380
  def set_diearea(self,
380
381
  points: List[Tuple[float, float]],
381
- step: str = None, index: Union[str, int] = None):
382
+ step: Optional[str] = None, index: Optional[Union[str, int]] = None):
382
383
  """
383
384
  Sets the die area using a list of points defining its boundary.
384
385
 
@@ -396,8 +397,8 @@ class ASICAreaConstraint(BaseSchema):
396
397
  """
397
398
  return self.set("diearea", points, step=step, index=index)
398
399
 
399
- def get_diearea(self,
400
- step: str = None, index: Union[str, int] = None) -> List[Tuple[float, float]]:
400
+ def get_diearea(self, step: Optional[str] = None, index: Optional[Union[str, int]] = None) \
401
+ -> List[Tuple[float, float]]:
401
402
  """
402
403
  Retrieves the current die area definition.
403
404
 
@@ -415,7 +416,7 @@ class ASICAreaConstraint(BaseSchema):
415
416
 
416
417
  def set_corearea(self,
417
418
  points: List[Tuple[float, float]],
418
- step: str = None, index: Union[str, int] = None):
419
+ step: Optional[str] = None, index: Optional[Union[str, int]] = None):
419
420
  """
420
421
  Sets the core area using a list of points defining its boundary.
421
422
 
@@ -432,8 +433,8 @@ class ASICAreaConstraint(BaseSchema):
432
433
  """
433
434
  return self.set("corearea", points, step=step, index=index)
434
435
 
435
- def get_corearea(self,
436
- step: str = None, index: Union[str, int] = None) -> List[Tuple[float, float]]:
436
+ def get_corearea(self, step: Optional[str] = None, index: Optional[Union[str, int]] = None) \
437
+ -> List[Tuple[float, float]]:
437
438
  """
438
439
  Retrieves the current core area definition.
439
440
 
@@ -449,7 +450,8 @@ class ASICAreaConstraint(BaseSchema):
449
450
  """
450
451
  return self.get("corearea", step=step, index=index)
451
452
 
452
- def calc_diearea(self, step: str = None, index: str = None) -> float:
453
+ def calc_diearea(self, step: Optional[str] = None, index: Optional[Union[str, int]] = None) \
454
+ -> float:
453
455
  '''Calculates the area of a rectilinear die.
454
456
 
455
457
  Uses the shoelace formula to calculate the design area from the (x,y)