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
@@ -246,6 +252,7 @@ def openroad(
246252 flow_variant ,
247253 path = "" ,
248254 install_path = None ,
255+ stage = "" ,
249256):
250257 """
251258 Run OpenROAD-flow-scripts with a given set of parameters.
@@ -269,7 +276,7 @@ def openroad(
269276
270277 make_command = export_command
271278 make_command += f"make -C { base_dir } /flow DESIGN_CONFIG=designs/"
272- make_command += f"{ args .platform } /{ args .design } /config.mk"
279+ make_command += f"{ args .platform } /{ args .design } /config.mk { stage } "
273280 make_command += f" PLATFORM={ args .platform } "
274281 make_command += f" FLOW_VARIANT={ flow_variant } { parameters } "
275282 make_command += " EQUIVALENCE_CHECK=0"
@@ -320,10 +327,11 @@ def openroad(
320327)
321328
322329
323- def read_metrics (file_name ):
330+ def read_metrics (file_name , stage = "" ):
324331 """
325332 Collects metrics to evaluate the user-defined objective function.
326333 """
334+ metric_name = STAGE_TO_METRICS .get (stage if stage else "final" , stage )
327335 with open (file_name ) as file :
328336 data = json .load (file )
329337 clk_period = 9999999
@@ -346,17 +354,17 @@ def read_metrics(file_name):
346354 num_drc = value ["route__drc_errors" ]
347355 if stage_name == "detailedroute" and "route__wirelength" in value :
348356 wirelength = value ["route__wirelength" ]
349- if stage_name == "finish" and "timing__setup__ws" in value :
357+ if stage_name == metric_name and "timing__setup__ws" in value :
350358 worst_slack = value ["timing__setup__ws" ]
351- if stage_name == "finish" and "power__total" in value :
359+ if stage_name == metric_name and "power__total" in value :
352360 total_power = value ["power__total" ]
353- if stage_name == "finish" and "design__instance__utilization" in value :
361+ if stage_name == metric_name and "design__instance__utilization" in value :
354362 final_util = value ["design__instance__utilization" ]
355- if stage_name == "finish" and "design__instance__area" in value :
363+ if stage_name == metric_name and "design__instance__area" in value :
356364 design_area = value ["design__instance__area" ]
357- if stage_name == "finish" and "design__core__area" in value :
365+ if stage_name == metric_name and "design__core__area" in value :
358366 core_area = value ["design__core__area" ]
359- if stage_name == "finish" and "design__die__area" in value :
367+ if stage_name == metric_name and "design__die__area" in value :
360368 die_area = value ["design__die__area" ]
361369 for i , stage_name in reversed (STAGES ):
362370 if stage_name in data and [d for d in data [stage_name ].values () if d != "ERR" ]:
@@ -371,9 +379,15 @@ def read_metrics(file_name):
371379 "design_area" : design_area ,
372380 "core_area" : core_area ,
373381 "die_area" : die_area ,
374- "wirelength" : wirelength ,
375- "num_drc" : num_drc ,
376- }
382+ "last_successful_stage" : last_stage ,
383+ } | (
384+ {
385+ "wirelength" : wirelength ,
386+ "num_drc" : num_drc ,
387+ }
388+ if metric_name in ("detailedroute" , "finish" )
389+ else {}
390+ )
377391 return ret
378392
379393
@@ -682,6 +696,7 @@ def openroad_distributed(
682696 flow_variant = f"{ uuid ()} -{ variant } " ,
683697 path = path ,
684698 install_path = install_path ,
699+ stage = args .to_stage ,
685700 )
686701 duration = time () - t
687702 return metric_file , duration
@@ -722,6 +737,13 @@ def add_common_args(parser: argparse.ArgumentParser):
722737 required = True ,
723738 help = "Configuration file that sets which knobs to use for Autotuning." ,
724739 )
740+ parser .add_argument (
741+ "--to-stage" ,
742+ type = str ,
743+ choices = ("floorplan" , "place" , "cts" , "route" , "finish" ),
744+ default = "" ,
745+ help = "Run ORFS only to the given stage (inclusive)" ,
746+ )
725747 parser .add_argument (
726748 "--timeout" ,
727749 type = float ,
0 commit comments