@@ -98,6 +98,7 @@ def makeDict():
9898layer_segments = defaultdict (
9999 lambda : {"lengths" : [], "resistances" : [], "capacitances" : []}
100100)
101+ layer_net_type_length = defaultdict (lambda : defaultdict (float ))
101102routing_layers = []
102103routing_layers_line = None
103104
@@ -150,6 +151,7 @@ def makeDict():
150151 layer_segments [tokens [2 ]]["lengths" ].append (float (tokens [3 ]))
151152 layer_segments [tokens [2 ]]["resistances" ].append (float (tokens [4 ]))
152153 layer_segments [tokens [2 ]]["capacitances" ].append (float (tokens [5 ]))
154+ layer_net_type_length [tokens [2 ]][tokens [1 ]] += float (tokens [3 ])
153155 else :
154156 netName = tokens [0 ]
155157
@@ -372,6 +374,9 @@ def generic_rc_fit(type_sieve):
372374if args .mode == "segment" :
373375 print ("\n Units: resistance [{}/um], capacitance [{}/um]" .format (res_unit , cap_unit ))
374376
377+ # Note that the .csv data comes from ODB which stores capacitance in fF.
378+ cap_ff_to_f = 1e-15
379+
375380 layer_models = {}
376381 for layer_name in routing_layers :
377382 # There may be routing layers with no segments, so we check if the
@@ -422,7 +427,57 @@ def generic_rc_fit(type_sieve):
422427 "set_layer_rc -layer {} -resistance {:.5E} -capacitance {:.5E}" .format (
423428 layer_name ,
424429 res_model .coef_ [0 ] / res_scale ,
425- cap_model .coef_ [0 ] * 1e-15 / cap_scale ,
430+ cap_model .coef_ [0 ] * cap_ff_to_f / cap_scale ,
431+ )
432+ )
433+ print ("" )
434+
435+ def wire_rc_fit (target_net_type = None ):
436+ total_length = 0.0
437+ total_resistance = 0.0
438+ total_capacitance = 0.0
439+
440+ for layer_name , (res_model , cap_model , lengths , _ , _ ) in layer_models .items ():
441+ if target_net_type is not None :
442+ layer_length = sum (
443+ layer_net_type_length [layer_name ][net_type ]
444+ for net_type in target_net_type
445+ )
446+ else :
447+ layer_length = float (lengths .sum ())
448+
449+ total_resistance += res_model .coef_ [0 ] * layer_length
450+ total_capacitance += cap_model .coef_ [0 ] * layer_length
451+ total_length += layer_length
452+
453+ if total_length == 0.0 :
454+ return None
455+
456+ return (
457+ total_resistance / total_length / res_scale ,
458+ total_capacitance / total_length * cap_ff_to_f / cap_scale ,
459+ )
460+
461+ resistance , capacitance = wire_rc_fit ()
462+
463+ print (
464+ "set_wire_rc -resistance {:.5E} -capacitance {:.5E}" .format (
465+ resistance , capacitance
466+ )
467+ )
468+
469+ for net_type in ["signal" , "clock" ]:
470+ result = wire_rc_fit ([net_type ])
471+
472+ if result is None :
473+ print ("[Warning] No {} nets were found." .format (net_type ))
474+ continue
475+
476+ resistance , capacitance = result
477+
478+ print (
479+ "set_wire_rc -{} -resistance {:.5E} -capacitance {:.5E}" .format (
480+ net_type , resistance , capacitance
426481 )
427482 )
428483 print ("" )
0 commit comments