2929set_input_delay [expr $clk_period * $clk_io_pct] -clock $clk_name $non_clock_inputs
3030set_output_delay [expr $clk_period * $clk_io_pct] -clock $clk_name [all_outputs]
3131"""
32+ # Maps ORFS stage to a name of produced metrics
33+ STAGE_TO_METRICS = {
34+ "route" : "detailedroute" ,
35+ "place" : "detailedplace" ,
36+ "final" : "finish" ,
37+ }
3238# Name of the SDC file with constraints
3339CONSTRAINTS_SDC = "constraint.sdc"
3440# Name of the TCL script run before routing
@@ -245,6 +251,7 @@ def openroad(
245251 flow_variant ,
246252 path = "" ,
247253 install_path = None ,
254+ stage = "" ,
248255):
249256 """
250257 Run OpenROAD-flow-scripts with a given set of parameters.
@@ -268,7 +275,7 @@ def openroad(
268275
269276 make_command = export_command
270277 make_command += f"make -C { base_dir } /flow DESIGN_CONFIG=designs/"
271- make_command += f"{ args .platform } /{ args .design } /config.mk"
278+ make_command += f"{ args .platform } /{ args .design } /config.mk { stage } "
272279 make_command += f" PLATFORM={ args .platform } "
273280 make_command += f" FLOW_VARIANT={ flow_variant } { parameters } "
274281 make_command += " EQUIVALENCE_CHECK=0"
@@ -319,10 +326,11 @@ def openroad(
319326)
320327
321328
322- def read_metrics (file_name ):
329+ def read_metrics (file_name , stage = "" ):
323330 """
324331 Collects metrics to evaluate the user-defined objective function.
325332 """
333+ metric_name = STAGE_TO_METRICS .get (stage if stage else "final" , stage )
326334 with open (file_name ) as file :
327335 data = json .load (file )
328336 clk_period = 9999999
@@ -345,17 +353,17 @@ def read_metrics(file_name):
345353 num_drc = value ["route__drc_errors" ]
346354 if stage_name == "detailedroute" and "route__wirelength" in value :
347355 wirelength = value ["route__wirelength" ]
348- if stage_name == "finish" and "timing__setup__ws" in value :
356+ if stage_name == metric_name and "timing__setup__ws" in value :
349357 worst_slack = value ["timing__setup__ws" ]
350- if stage_name == "finish" and "power__total" in value :
358+ if stage_name == metric_name and "power__total" in value :
351359 total_power = value ["power__total" ]
352- if stage_name == "finish" and "design__instance__utilization" in value :
360+ if stage_name == metric_name and "design__instance__utilization" in value :
353361 final_util = value ["design__instance__utilization" ]
354- if stage_name == "finish" and "design__instance__area" in value :
362+ if stage_name == metric_name and "design__instance__area" in value :
355363 design_area = value ["design__instance__area" ]
356- if stage_name == "finish" and "design__core__area" in value :
364+ if stage_name == metric_name and "design__core__area" in value :
357365 core_area = value ["design__core__area" ]
358- if stage_name == "finish" and "design__die__area" in value :
366+ if stage_name == metric_name and "design__die__area" in value :
359367 die_area = value ["design__die__area" ]
360368 for i , stage_name in reversed (STAGES ):
361369 if stage_name in data and [d for d in data [stage_name ].values () if d != "ERR" ]:
@@ -370,9 +378,15 @@ def read_metrics(file_name):
370378 "design_area" : design_area ,
371379 "core_area" : core_area ,
372380 "die_area" : die_area ,
373- "wirelength" : wirelength ,
374- "num_drc" : num_drc ,
375- }
381+ "last_successful_stage" : last_stage ,
382+ } | (
383+ {
384+ "wirelength" : wirelength ,
385+ "num_drc" : num_drc ,
386+ }
387+ if metric_name in ("detailedroute" , "finish" )
388+ else {}
389+ )
376390 return ret
377391
378392
@@ -681,6 +695,7 @@ def openroad_distributed(
681695 flow_variant = f"{ uuid ()} -{ variant } " ,
682696 path = path ,
683697 install_path = install_path ,
698+ stage = args .to_stage ,
684699 )
685700 duration = time () - t
686701 return metric_file , duration
@@ -721,6 +736,13 @@ def add_common_args(parser: argparse.ArgumentParser):
721736 required = True ,
722737 help = "Configuration file that sets which knobs to use for Autotuning." ,
723738 )
739+ parser .add_argument (
740+ "--to-stage" ,
741+ type = str ,
742+ choices = ("floorplan" , "place" , "cts" , "route" , "finish" ),
743+ default = "" ,
744+ help = "Run ORFS only to the given stage (inclusive)" ,
745+ )
724746 parser .add_argument (
725747 "--timeout" ,
726748 type = float ,
0 commit comments