Skip to content

Commit

Permalink
Fix PDN OR script sourcing OpenLane utils (The-OpenROAD-Project#1234)
Browse files Browse the repository at this point in the history
+ Add contributing guidelines for tool-specific tcl scripts
~ Fix `--verbose` output in `or_issue.py` and add a guard against `/dev` paths
~ Remove `source` statement from `pdn_cfg.tcl`, remove `puts_err` (don't use OpenLane utils in OpenROAD scripts)
  • Loading branch information
donn authored Jul 26, 2022
1 parent b50b4d0 commit 281281c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
11 changes: 11 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ Try to write all major code in Python. Writing some Tcl is usually a necessity b

Please do not write new shell scripts.

## Yosys, OpenROAD and Magic Scripts
There are some special guidelines for scripts in `scripts/yosys`, `scripts/openroad`, and `scripts/magic`:

* The scripts for each tool are a self-contained ecosystem: do not `source` scripts from outside their directories.
* You may duplicate functionality if you deem it necessary.
* Do not reference the following environment variables anywhere in this folder to avoid causing recursion when generating issue reproducibles:
* $PWD
* $RUN_DIR
* $DESIGN_DIR


# Submissions
Make your changes and then submit them as a pull requests to the `master` branch.

Expand Down
6 changes: 2 additions & 4 deletions scripts/openroad/pdn_cfg.tcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
source $::env(SCRIPTS_DIR)/utils/utils.tcl

# Power nets
if { [info exists ::env(FP_PDN_ENABLE_GLOBAL_CONNECTIONS)] } {
if { $::env(FP_PDN_ENABLE_GLOBAL_CONNECTIONS) == 1 } {
Expand Down Expand Up @@ -31,8 +29,8 @@ if { $::env(FP_PDN_ENABLE_MACROS_GRID) == 1 &&
set ground_pin [lindex $pdn_hook 4]

if { $power_pin == "" || $ground_pin == "" } {
puts_err "FP_PDN_MACRO_HOOKS missing power and ground pin names"
return -code error
puts "FP_PDN_MACRO_HOOKS missing power and ground pin names"
exit -1
}

add_global_connection \
Expand Down
13 changes: 9 additions & 4 deletions scripts/or_issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def shift(deque):

script_counter = 0

def get_script():
def get_script_key():
nonlocal script_counter
value = f"PACKAGED_SCRIPT_{script_counter}"
script_counter += 1
Expand All @@ -237,12 +237,14 @@ def get_script():
tcls = set()
current = shift(tcls_to_process)
while current is not None:
env_key = get_script()
env_key = get_script_key()
env_keys_used.add(env_key)
env[env_key] = current

try:
script = open(current).read()
if verbose:
print(f"Processing {current}...", file=sys.stderr)

for key, value in env.items():
key_accessor = re.compile(
Expand All @@ -252,6 +254,7 @@ def get_script():
use: List[str]
full, accessor, extra = use
env_keys_used.add(key)
print(f"Found {accessor}…", file=sys.stderr)

value_substituted = full.replace(accessor, value)

Expand Down Expand Up @@ -309,7 +312,7 @@ def do_copy():
for key in env_keys_used:
value = env[key]
if verbose:
print(f"{key}: {value}")
print(f"Processing {key}: {value}…", file=sys.stderr)
if value == input_file:
final_path = join(destination_folder, "in.def")
from_path = value
Expand Down Expand Up @@ -347,7 +350,9 @@ def do_copy():
if value != "/openlane/scripts": # Too many files to copy otherwise
copy(from_path, final_path)
final_env[key] = final_value
elif value.startswith("/"):
elif value.startswith("/") and not value.startswith(
"/dev"
): # /dev/null, /dev/stdout, /dev/stderr, etc should still work
final_value = value[1:]
final_path = join(destination_folder, final_value)
copy(value, final_path)
Expand Down

0 comments on commit 281281c

Please sign in to comment.