6565set_input_delay [expr $clk_period * $clk_io_pct] -clock $clk_name $non_clock_inputs
6666set_output_delay [expr $clk_period * $clk_io_pct] -clock $clk_name [all_outputs]
6767"""
68+ # Maps ORFS stage to a name of produced metrics
69+ STAGE_TO_METRICS = {
70+ "route" : "detailedroute" ,
71+ "place" : "detailedplace" ,
72+ "final" : "finish" ,
73+ }
6874# Name of the SDC file with constraints
6975CONSTRAINTS_SDC = "constraint.sdc"
7076# Name of the TCL script run before routing
@@ -296,6 +302,7 @@ def openroad(
296302 parameters ,
297303 flow_variant ,
298304 install_path = None ,
305+ stage = "" ,
299306):
300307 """
301308 Run OpenROAD-flow-scripts with a given set of parameters.
@@ -331,7 +338,7 @@ def openroad(
331338 limit = int (args .memory_limit * 1_000_000 )
332339 make_command += f"ulimit -v { limit } ; "
333340 make_command += f"make -C { base_dir } /flow DESIGN_CONFIG=designs/"
334- make_command += f"{ args .platform } /{ args .design } /config.mk"
341+ make_command += f"{ args .platform } /{ args .design } /config.mk { stage } "
335342 make_command += f" PLATFORM={ args .platform } "
336343 make_command += f" FLOW_VARIANT={ flow_variant } { parameters } "
337344 make_command += " EQUIVALENCE_CHECK=0"
@@ -387,7 +394,7 @@ def openroad(
387394)
388395
389396
390- def read_metrics (file_name , stop_stage ):
397+ def read_metrics (file_name , stop_stage = "" ):
391398 """
392399 Collects metrics to evaluate the user-defined objective function.
393400
@@ -396,6 +403,7 @@ def read_metrics(file_name, stop_stage):
396403 before "finish", then no need to extract the metrics from the route stage,
397404 so set them to 0
398405 """
406+ validated_stage = STAGE_TO_METRICS .get (stop_stage if stop_stage else "final" , stop_stage )
399407 with open (file_name ) as file :
400408 data = json .load (file )
401409 clk_period = 9999999
@@ -420,17 +428,17 @@ def read_metrics(file_name, stop_stage):
420428 num_drc = value ["route__drc_errors" ]
421429 if stage_name == "detailedroute" and "route__wirelength" in value :
422430 wirelength = value ["route__wirelength" ]
423- if stage_name == stop_stage and "timing__setup__ws" in value :
431+ if stage_name == validated_stage and "timing__setup__ws" in value :
424432 worst_slack = value ["timing__setup__ws" ]
425- if stage_name == stop_stage and "power__total" in value :
433+ if stage_name == validated_stage and "power__total" in value :
426434 total_power = value ["power__total" ]
427- if stage_name == stop_stage and "design__instance__utilization" in value :
435+ if stage_name == validated_stage and "design__instance__utilization" in value :
428436 final_util = value ["design__instance__utilization" ]
429- if stage_name == stop_stage and "design__instance__area" in value :
437+ if stage_name == validated_stage and "design__instance__area" in value :
430438 design_area = value ["design__instance__area" ]
431- if stage_name == stop_stage and "design__core__area" in value :
439+ if stage_name == validated_stage and "design__core__area" in value :
432440 core_area = value ["design__core__area" ]
433- if stage_name == stop_stage and "design__die__area" in value :
441+ if stage_name == validated_stage and "design__die__area" in value :
434442 die_area = value ["design__die__area" ]
435443 for i , stage_name in reversed (STAGES ):
436444 if stage_name in data and [d for d in data [stage_name ].values () if d != "ERR" ]:
@@ -445,9 +453,15 @@ def read_metrics(file_name, stop_stage):
445453 "design_area" : design_area ,
446454 "core_area" : core_area ,
447455 "die_area" : die_area ,
448- "wirelength" : wirelength ,
449- "num_drc" : num_drc ,
450- }
456+ "last_successful_stage" : last_stage ,
457+ } | (
458+ {
459+ "wirelength" : wirelength ,
460+ "num_drc" : num_drc ,
461+ }
462+ if validated_stage in ("detailedroute" , "finish" )
463+ else {}
464+ )
451465 return ret
452466
453467
@@ -706,6 +720,7 @@ def openroad_distributed(
706720 parameters = config ,
707721 flow_variant = f"{ uuid .uuid4 ()} -{ variant } " if variant else f"{ uuid .uuid4 ()} " ,
708722 install_path = install_path ,
723+ stage = args .stop_stage ,
709724 )
710725 duration = time .time () - t
711726 return metric_file , duration
@@ -746,6 +761,14 @@ def add_common_args(parser: argparse.ArgumentParser):
746761 required = True ,
747762 help = "Configuration file that sets which knobs to use for Autotuning." ,
748763 )
764+ parser .add_argument (
765+ "--stop_stage" ,
766+ type = str ,
767+ metavar = "<str>" ,
768+ choices = ["floorplan" , "place" , "cts" , "globalroute" , "route" , "finish" ],
769+ default = "finish" ,
770+ help = "Name of the stage to stop after. Default is finish." ,
771+ )
749772 parser .add_argument (
750773 "--timeout" ,
751774 type = float ,
0 commit comments