Skip to content

Commit a5a4f5c

Browse files
Refactor constructor to handle width and size parameters
1 parent 686a3b6 commit a5a4f5c

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

hwcomponents_library/library/aladdin.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,17 @@ class AladdinRegister(LibraryEstimatorClassBase):
103103
def __init__(
104104
self,
105105
tech_node: float,
106-
width: int = 1,
106+
width: int | None = None,
107+
size: int | None = None,
107108
):
109+
if width is None and size is not None:
110+
width = size
111+
elif size is None and width is not None:
112+
size = width
113+
elif width is not None and size is not None and width != size:
114+
raise ValueError("Width and size must be the same if both are provided.")
115+
elif width is None and size is None:
116+
raise ValueError("Either width or size must be provided.")
108117
super().__init__(leak_power=0.0, area=5.98e-12)
109118
self.tech_node: float = self.scale(
110119
"tech_node",
@@ -116,6 +125,7 @@ def __init__(
116125
tech_node_leak,
117126
)
118127
self.width: int = self.scale("width", width, 1, linear, linear, noscale, linear)
128+
self.size = self.width
119129

120130
@action(bits_per_action="width")
121131
def read(self) -> tuple[float, float]:

0 commit comments

Comments
 (0)