@@ -42,7 +42,7 @@ class AladdinAdder(LibraryEstimatorClassBase):
4242 component_name = ["Adder" , "AladdinAdder" , "IntAdder" ]
4343 priority = 0.1
4444
45- def __init__ (self , tech_node : float , width : int = 32 ):
45+ def __init__ (self , tech_node : float , width : int ):
4646 super ().__init__ (leak_power = 2.40e-6 , area = 278.0e-12 )
4747 self .tech_node : float = self .scale (
4848 "tech_node" ,
@@ -237,9 +237,9 @@ class AladdinMultiplier(LibraryEstimatorClassBase):
237237 def __init__ (
238238 self ,
239239 tech_node : float ,
240- width : int = 32 ,
241- width_a : int = 32 ,
242- width_b : int = 32 ,
240+ width : int = None ,
241+ width_a : int = None ,
242+ width_b : int = None ,
243243 ):
244244 super ().__init__ (leak_power = 8.00e-5 , area = 6350.0e-12 )
245245 self .tech_node : float = self .scale (
@@ -251,25 +251,28 @@ def __init__(
251251 tech_node_latency ,
252252 tech_node_leak ,
253253 )
254- if width_a != 32 and width != 32 :
254+ if width is not None and ( width_a is not None or width_b is not None ) :
255255 raise ValueError (
256- "width and width_a cannot both be set. Either set width of both inputs "
257- "or width_a and width_b separately."
256+ "width and ( width_a or width_b) cannot both be set. Either set width "
257+ "of both inputs with width or set width_a and width_b separately."
258258 )
259- if width != 32 and width_b != 32 :
260- raise ValueError (
261- "width and width_b cannot both be set. Either set width of both inputs "
262- "or width_a and width_b separately."
259+ if width is None and (width_a is None or width_b is None ):
260+ raise ValueError ("Either width or (width_a and width_b) must be set." )
261+
262+ if width is not None :
263+ self .width : int = self .scale (
264+ "width" , width , 32 , quadratic , quadratic , noscale , quadratic
263265 )
264- self .width : int = self .scale (
265- "width" , width , 32 , quadratic , quadratic , noscale , quadratic
266- )
267- self .width_a : int = self .scale (
268- "width_a" , width_a , 32 , linear , linear , noscale , linear
269- )
270- self .width_b : int = self .scale (
271- "width_b" , width_b , 32 , linear , linear , noscale , linear
272- )
266+ self .width_a = width
267+ self .width_b = width
268+ else :
269+ self .width_a : int = self .scale (
270+ "width_a" , width_a , 32 , linear , linear , noscale , linear
271+ )
272+ self .width_b : int = self .scale (
273+ "width_b" , width_b , 32 , linear , linear , noscale , linear
274+ )
275+ self .width = (self .width_a + self .width_b ) / 2
273276
274277 @action
275278 def multiply (self ) -> tuple [float , float ]:
@@ -370,9 +373,7 @@ class AladdinIntMAC(LibraryEstimatorClassBase):
370373 component_name = ["IntMAC" , "AladdinIntMAC" ]
371374 priority = 0.1
372375
373- def __init__ (
374- self , tech_node : float , adder_width : int = 16 , multiplier_width : int = 8
375- ):
376+ def __init__ (self , tech_node : float , adder_width : int , multiplier_width : int ):
376377 self .adder = AladdinAdder (tech_node , adder_width )
377378 self .multiplier = AladdinMultiplier (tech_node , multiplier_width )
378379 super ().__init__ (
0 commit comments