Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please add hooks for user scripts into openroad tcl files #1964

Open
chaufe opened this issue Sep 1, 2023 · 1 comment
Open

Please add hooks for user scripts into openroad tcl files #1964

chaufe opened this issue Sep 1, 2023 · 1 comment
Labels
enhancement New feature or request OpenLane 2 Scheduled for next gen OpenLane

Comments

@chaufe
Copy link

chaufe commented Sep 1, 2023

Description

I like OpenLane being a good reference flow for the use of OpenROAD etc.
But as OpenLane cannot fit all user purposes, sometimes files need individual changes that users may have to re-apply whenever new versions of OpenLane are available.
I would like to propose adding hooks into the OpenLane tcl scripts such that users do no longer need to locally patch OpenLane, but just need to provide their user scripts that OpenLane will source-in at pre-defined positions.

/cc @proppy
/cc @dhaentz1

Proposal

Please find attached example code that adds the following changes to the OpenROAD tcl files contained inside scripts/openroad:

An environment variable OPENROAD_USER_SCRIPTS points to a directory containing all user scripts. If the variable does not exist, or if the directory does not exist, no user scripts will be read in.

There are four classes of user scripts for the following phases:
setup: These files will be read during setup, right prior to reading-in the data base via read
pre: These files will be read-in right prior to the actual task of a script, i.e. right prior to detailed routing.
post: These scripts will be read-in after the actual task of a script, i.e. prior to reporting and saving results via write.
final: These scripts will be read-in at the very end.

Setup-scripts can be used to modify variables etc to change how data is read in.
Pre-scripts can be used to modify how the actual main task is performed.
Post-scripts can be used to modify or enhance the result of the main task.
Final-scripts can be used to modify the data written to disk or to add reporting etc.

For all four classes, there are two file names supported:

  • A generic one, i.e. user.setup.tcl, that will be executed in all steps, i.e. groute, droute, pdn etc
  • A specific one, i.e. user.pdn.setup.tcl, that will be executed only in a specific step, i.e. just pdn.
  • Import order is: non-specific script first, specific script afterwards

If user script are not available for a certain phase or step, execution continues w/o complaint.

The following code illustrates how user script hook could be added into the script droute.tcl:

source $::env(SCRIPTS_DIR)/openroad/common/io.tcl

execute_user_setup_hook "droute"

read

set_thread_count $::env(ROUTING_CORES)

set min_layer $::env(RT_MIN_LAYER)
if { [info exists ::env(DRT_MIN_LAYER)] } {
    set min_layer $::env(DRT_MIN_LAYER)
}

set max_layer $::env(RT_MAX_LAYER)
if { [info exists ::env(DRT_MAX_LAYER)] } {
    set max_layer $::env(DRT_MAX_LAYER)
}

read_guides $::env(CURRENT_GUIDE)

execute_user_pre_hook "droute"

detailed_route\
    -bottom_routing_layer $min_layer\
    -top_routing_layer $max_layer\
    -output_maze $::env(_tmp_drt_file_prefix)_maze.log\
    -output_drc $::env(_tmp_drt_rpt_prefix).drc\
    -droute_end_iter $::env(DRT_OPT_ITERS)\
    -or_seed 42\
    -verbose 1

execute_user_post_hook "droute"

write

execute_user_final_hook "droute"

The procedures execute_user_*_hook have been defined inside io.tcl.

openroad_scripts_with_user_hooks.zip

@donn donn added the enhancement New feature or request label Sep 3, 2023
@donn
Copy link
Collaborator

donn commented Sep 3, 2023

It's not a bad idea- but a couple notes:

  1. The rewrite of OpenLane is already designed to let you subclass and replace step scripts entirely as follows: e.g. https://github.com/efabless/openlane2/blob/169378e8b2eba0fe5d177779107a4f16af0d6c1a/openlane/steps/openroad.py#L926
  2. We'd have to commit to an API for these scripts. Currently, we enjoy the flexibility of being able to modify them with prejudice.

I'll bring this up with the team internally, though.

@kareefardi kareefardi added the OpenLane 2 Scheduled for next gen OpenLane label Dec 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request OpenLane 2 Scheduled for next gen OpenLane
Projects
None yet
Development

No branches or pull requests

3 participants