Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,6 @@ single_version_override(
version = "3.8.2.bcr.7",
)

# tclZipfs.c's '#include "crypt.h"' picks up glibc's crypt.h instead of
# the vendored minizip one when glibc headers are explicit -isystem
# directories (hermetic-llvm zero-sysroot toolchain). Drop when fixed
# in a tcl_lang BCR release.
single_version_override(
module_name = "tcl_lang",
patch_strip = 1,
patches = [
"//patches/tcl_lang:0001-tclZipfs-include-vendored-minizip-crypt.h-by-path.patch",
],
)

bazel_dep(name = "openroad", dev_dependency = True)
local_path_override(
Expand Down
9 changes: 9 additions & 0 deletions correlation_table.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Place vs Global Route Timing Correlation Study

| PDK | Design | Place Fmax (MHz) | GRT Fmax (MHz) | Place WS | GRT WS | Fmax Ratio (GRT/Place) | Status |
| --- | --- | --- | --- | --- | --- | --- | --- |
| sky130hd | gcd | 404.8 | 372.1 | -1.48 ns | -1.59 ns | 0.919 | Good Correlation |
| sky130hd | jpeg | 177.0 | 180.6 | -0.65 ns | -0.54 ns | 1.021 | Good Correlation |
| sky130hd | riscv32i | 177.0 | 180.6 | -0.65 ns | -0.54 ns | 1.021 | Good Correlation |
| asap7 | gcd | 2622.8 | 2470.7 | -71.27 ps | -94.74 ps | 0.942 | Good Correlation |
| asap7 | mock-cpu | 2971.7 | 3044.9 | -3.51 ps | 4.59 ps | 1.025 | Good Correlation |
50 changes: 48 additions & 2 deletions flow/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@bazel-orfs//:openroad.bzl", "orfs_pdk")
load("@rules_python//python:defs.bzl", "py_library", "py_test")
load("@rules_python//python:defs.bzl", "py_library", "py_test", "py_binary")

# Expose every individual file under platforms/ as a public source-file
# target, so designs in other packages can refer to e.g.
Expand All @@ -24,7 +24,10 @@ exports_files(
# instead of vendoring its own (drifting) copy at the bazel-orfs repo
# root. See bazel-orfs `private/rules.bzl`.
exports_files(
["scripts/synth.tcl"],
[
"scripts/synth.tcl",
"scripts/place_only_and_measure.tcl",
],
visibility = ["//visibility:public"],
)

Expand Down Expand Up @@ -229,3 +232,46 @@ test_suite(
name = "memories_tests",
tests = ["memories_" + test for test in MEMORIES_TESTS],
)

py_binary(
name = "tune_gpl_magic",
srcs = ["scripts/tune_gpl_magic.py"],
deps = [
"@orfs-pip//optuna",
"@orfs-pip//pyyaml",
],
visibility = ["//visibility:public"],
)

py_binary(
name = "aggregate_path_data",
srcs = ["scripts/aggregate_path_data.py"],
deps = [
"@orfs-pip//pandas",
],
visibility = ["//visibility:public"],
)

py_binary(
name = "qor_plotter",
srcs = ["scripts/qor_plotter.py"],
deps = [
"@orfs-pip//pandas",
"@orfs-pip//pyside6",
"@orfs-pip//matplotlib",
],
visibility = ["//visibility:public"],
)

py_binary(
name = "correlation_table",
srcs = ["scripts/generate_correlation_table.py"],
main = "scripts/generate_correlation_table.py",
deps = [
"@orfs-pip//pandas",
],
visibility = ["//visibility:public"],
)



1 change: 1 addition & 0 deletions flow/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ ifeq ($(SYNTH_USE_SYN),1)
$(eval $(call do-step,1_synth,$(VERILOG_FILES) $(SDC_FILE) $(TECH_LEF) $(SC_LEF) $(ADDITIONAL_LEFS) $(LIB_FILES),synth_syn))
else
$(eval $(call do-step,1_synth,$(RESULTS_DIR)/1_2_yosys.v $(RESULTS_DIR)/1_2_yosys.sdc $(TECH_LEF) $(SC_LEF) $(ADDITIONAL_LEFS) $(LIB_FILES),synth_odb))
do-1_synth: $(RESULTS_DIR)/1_2_yosys.sdc
endif

$(RESULTS_DIR)/1_synth.sdc: $(RESULTS_DIR)/1_synth.odb
Expand Down
1 change: 0 additions & 1 deletion flow/designs/asap7/gcd/config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ export PLACE_DENSITY = 0.35
# few last gasp iterations
export SKIP_LAST_GASP ?= 1

export SYNTH_USE_SYN = 1
36 changes: 33 additions & 3 deletions flow/designs/design.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""BUILD boilerplate for flow/designs/."""

load("@bazel-orfs//:openroad.bzl", "orfs_flow")
load("@orfs_designs//:designs.bzl", "orfs_design")
load("@bazel-orfs//:openroad.bzl", "orfs_flow", "orfs_run")
load("@orfs_designs//:designs.bzl", "orfs_design", "DESIGNS")

# Per filegroup target: extensions included in the filegroup.
# bazel-orfs's config_mk_parser produces these target names from
Expand All @@ -18,7 +18,7 @@ _GROUPS = {
# cross-package references resolve. Kept tight on purpose: globbing "*"
# silently exposes LICENSE/.gitignore/etc. as the public API surface.
# gds/gds.gz are inputs in hierarchical flows via ADDITIONAL_GDS.
_EXPORTED_EXTS = ["v", "sv", "svh", "tcl", "sdc", "def", "cfg", "lef", "lib", "gds", "gds.gz"]
_EXPORTED_EXTS = ["v", "sv", "svh", "tcl", "sdc", "def", "cfg", "lef", "lib", "gds", "gds.gz", "memories"]

_EXPORTS_SENTINEL = "_orfs_design_exports_sentinel"

Expand Down Expand Up @@ -79,6 +79,36 @@ def design(config = "config.mk", user_arguments = [], user_sources = [], local_a
blender = True,
)

pkg = native.package_name()
if pkg.startswith("flow/designs/"):
design_id = pkg[len("flow/designs/"):]
if design_id in DESIGNS:
design_args = DESIGNS[design_id]["arguments"]
# Find the actual synth target name instantiated by orfs_design
synth_name = None
for rule_name in native.existing_rules().keys():
if rule_name.endswith("_synth"):
synth_name = rule_name
break

if synth_name:
design_name = synth_name[:-6] # Remove "_synth"
args_copy = {k: v for k, v in design_args.items()}
args_copy["FLOW_VARIANT"] = "tune_gpl"
platform = args_copy.get("PLATFORM", design_id.split('/')[0])
real_design_name = args_copy.get("DESIGN_NAME", design_name)
orfs_run(
name = design_name + "_tune_gpl",
src = ":" + synth_name,
data = [":design_config"],
outs = [
"results/{}/{}/tune_gpl/target_function.txt".format(platform, real_design_name),
],
arguments = args_copy,
script = "//flow:scripts/place_only_and_measure.tcl",
variant = "tune_gpl",
)

def files(group, extra_srcs = None):
"""Named filegroup over conventional extensions.

Expand Down
5 changes: 5 additions & 0 deletions flow/platforms/asap7/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"GPL_TIMING_SPAN_CLOCK_PERCENT": 0.22968514538823603,
"GPL_WIRELENGTH_PENALTY": 0.06456297861599444,
"TIGHTEN_CLOCK_PERIOD": 0.018604621846273695
}
5 changes: 5 additions & 0 deletions flow/platforms/sky130hd/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"GPL_TIMING_SPAN_CLOCK_PERCENT": 0.188034183753787,
"GPL_WIRELENGTH_PENALTY": 0.028702330955746383,
"TIGHTEN_CLOCK_PERIOD": 0.04743068706084326
}
15 changes: 15 additions & 0 deletions flow/scripts/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@
with open(json_path, "r") as file:
data = json.load(file)

platform_dir = os.environ.get("PLATFORM_DIR")
if platform_dir:
platform_config_path = os.path.join(platform_dir, "config.json")
if os.path.exists(platform_config_path):
with open(platform_config_path, "r") as file:
try:
platform_data = json.load(file)
for key, value in platform_data.items():
if key in data:
data[key]["default"] = value
else:
data[key] = {"default": value}
except json.JSONDecodeError:
pass

for key, value in data.items():
if value.get("default", None) is None:
continue
Expand Down
4 changes: 4 additions & 0 deletions flow/scripts/dump_paths_grt.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set dump_dir [expr {[info exists ::env(DUMP_DIR)] ? $::env(DUMP_DIR) : $::env(REPORTS_DIR)}]
set ::env(DUMP_STAGE_PREFIX) "5_grt"
set ::env(DUMP_OUT_FILE) "$dump_dir/5_grt_timing_paths.csv"
source flow/scripts/dump_paths_native.tcl
113 changes: 113 additions & 0 deletions flow/scripts/dump_paths_native.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Native Tcl script to extract path details directly from OpenSTA into CSV
# Usage: source dump_paths_native.tcl

set out_file $::env(DUMP_OUT_FILE)
set stage_prefix $::env(DUMP_STAGE_PREFIX)

if {![info exists ::env(DUMP_OUT_FILE)] || ![info exists ::env(DUMP_STAGE_PREFIX)]} {
puts "Error: DUMP_OUT_FILE or DUMP_STAGE_PREFIX not set."
exit 1
}

puts "Extracting paths natively for stage: $stage_prefix to $out_file"

set fp [open $out_file w]
puts $fp "startpoint,endpoint,${stage_prefix}_min_clk_period,${stage_prefix}_net_delay,${stage_prefix}_logic_delay,${stage_prefix}_total_cap,${stage_prefix}_buffers"

# Get top 2000 paths
set paths [find_timing_paths -path_delay max -group_path_count 2000]

foreach path_end $paths {
set slack [$path_end slack]
set path [$path_end path]

set start_path [$path start_path]
set start_pin [$start_path pin]
set end_pin [$path_end pin]

set startpoint [get_name $start_pin]
set endpoint [get_name $end_pin]

# Get clock period from active clocks or default to datapath arrival if no clocks
set clocks [all_clocks]
if {[llength $clocks] > 0} {
set clk_period [[lindex $clocks 0] period]
set min_clk_period [expr {$clk_period - $slack}]
} else {
set min_clk_period [$path arrival]
}

# Redirect standard report output to string for precise table parsing
utl::redirectStringBegin
sta::set_report_path_digits 4
sta::set_report_path_fields {capacitance net slew}
sta::report_path_cmd $path
set report_str [utl::redirectStringEnd]

set net_delay 0.0
set logic_delay 0.0
set total_cap 0.0
set buffers 0

set datapath_delay [$path arrival]
if {$datapath_delay < 1e-4} {
set datapath_delay [expr {$datapath_delay * 1e9}]
}

# Process report_path_cmd text lines
set lines [split $report_str "\n"]
set prev_time 0.0
foreach line $lines {
set tokens [regexp -all -inline {\S+} $line]
if {[llength $tokens] >= 5 && [string is double -strict [lindex $tokens 3]]} {
set curr_time [lindex $tokens 3]
set cell_delay [lindex $tokens 2]
if {[string is double -strict $cell_delay] && $cell_delay > 0.0} {
set logic_delay [expr {$logic_delay + $cell_delay}]
}
set step [expr {$curr_time - $prev_time}]
set n_delay [expr {$step - $cell_delay}]
if {$n_delay > 0.0} {
set net_delay [expr {$net_delay + $n_delay}]
}
set prev_time $curr_time

set c_str [lindex $tokens 0]
if {[string is double -strict $c_str]} {
set c_val [expr {abs($c_str)}]
if {$c_val > 0.0} {
if {$c_val < 1e-9} { set c_val [expr {$c_val * 1e15}] }
set total_cap [expr {$total_cap + $c_val}]
}
}
if {[regexp {\(([^net][^\)]*)\)} $line -> cell_type]} {
if {[regexp {sky130_fd_sc_hd__(buf|dly)} $cell_type] || [regexp {BUF} $cell_type]} {
incr buffers
}
}
}
}

# Convert seconds to delay units (ps for asap7, ns for sky130hd)
set is_asap7 0
if {[info exists ::env(DESIGN_PLATFORM)] && [string match "*asap7*" $::env(DESIGN_PLATFORM)]} {
set is_asap7 1
} elseif {[string match "*asap7*" $out_file]} {
set is_asap7 1
}

if {$min_clk_period < 1e-4} {
if {$is_asap7} {
# asap7 is in ps
set min_clk_period [expr {$min_clk_period * 1e12}]
} else {
# sky130hd is in ns
set min_clk_period [expr {$min_clk_period * 1e9}]
}
}

puts $fp "$startpoint,$endpoint,$min_clk_period,$net_delay,$logic_delay,$total_cap,$buffers"
}

close $fp
puts "Dump complete."
4 changes: 4 additions & 0 deletions flow/scripts/dump_paths_place.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set dump_dir [expr {[info exists ::env(DUMP_DIR)] ? $::env(DUMP_DIR) : $::env(REPORTS_DIR)}]
set ::env(DUMP_STAGE_PREFIX) "3_place"
set ::env(DUMP_OUT_FILE) "$dump_dir/3_place_timing_paths.csv"
source flow/scripts/dump_paths_native.tcl
4 changes: 4 additions & 0 deletions flow/scripts/dump_paths_route.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set dump_dir [expr {[info exists ::env(DUMP_DIR)] ? $::env(DUMP_DIR) : $::env(REPORTS_DIR)}]
set ::env(DUMP_STAGE_PREFIX) "6_route"
set ::env(DUMP_OUT_FILE) "$dump_dir/6_route_timing_paths.csv"
source flow/scripts/dump_paths_native.tcl
Loading