Skip to content

Commit

Permalink
skew plot: bling, plot macros
Browse files Browse the repository at this point in the history
Signed-off-by: Øyvind Harboe <[email protected]>
  • Loading branch information
oharboe committed Nov 1, 2024
1 parent 2965bd3 commit 5155fde
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 13 deletions.
61 changes: 49 additions & 12 deletions plot-3d-slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import numpy as np
from scipy.interpolate import griddata
import sys
import yaml


def load_data(filename):
Expand All @@ -11,20 +12,34 @@ def load_data(filename):
slack = []

with open(filename, "r") as file:
for line in file:
parts = line.split()
if len(parts) == 5:
s = float(parts[2])
slack.append(s * pow(10, 12))
x.append(float(parts[3]))
y.append(float(parts[4]))
data = yaml.load(file, Loader=yaml.FullLoader)

return np.array(x), np.array(y), np.array(slack)
for line in data["stats"]:
parts = line.split()
if len(parts) == 5:
s = float(parts[2])
slack.append(s * pow(10, 12))
x.append(float(parts[3]))
y.append(float(parts[4]))

macros = {}

def plot_3d(x, y, z):
for line in data["masters"]:
parts = line.split()
if len(parts) == 5:
macros[parts[0]] = {
"minx": float(parts[1]),
"miny": float(parts[2]),
"maxx": float(parts[3]),
"maxy": float(parts[4]),
}

return np.array(x), np.array(y), np.array(slack), macros


def plot_3d(x, y, z, macros):
# Create grid data for surface plot
grid_x, grid_y = np.mgrid[0: 2000: 100j, 0: 2000: 100j]
grid_x, grid_y = np.mgrid[0:2000:100j, 0:2000:100j]
grid_z = griddata((x, y), z, (grid_x, grid_y), method="linear")

fig = plt.figure()
Expand All @@ -36,10 +51,32 @@ def plot_3d(x, y, z):
ax.set_zlabel("Skew")
fig.colorbar(surf, ax=ax, shrink=0.5, aspect=5)

for macro in macros:
minx = macros[macro]["minx"]
miny = macros[macro]["miny"]
maxx = macros[macro]["maxx"]
maxy = macros[macro]["maxy"]

# Plot a solid rectangle
ax.bar3d(minx, miny, 0, maxx - minx, maxy - miny, 50, color="red", alpha=0.5)

# # Add title text on the flat surface of the box
# ax.text(
# (minx + maxx) / 2, # x-coordinate of the text
# (miny + maxy) / 2, # y-coordinate of the text
# 0.5, # z-coordinate of the text (middle of the box height)
# macro, # text to display
# color='black', # text color
# ha='center', # horizontal alignment
# va='center', # vertical alignment
# fontsize=12, # font size
# bbox=dict(facecolor='white', alpha=0.5, edgecolor='none') # background box
# )

plt.show()


if __name__ == "__main__":
filename = sys.argv[1]
x, y, z = load_data(filename)
plot_3d(x, y, z)
x, y, z, macros = load_data(filename)
plot_3d(x, y, z, macros)
14 changes: 13 additions & 1 deletion slack-positions.tcl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# To test from ~/OpenROAD-flow-scripts, run:
# make RUN_SCRIPT=~/megaboom/slack-positions.tcl ODB_FILE=results/nangate45/gcd/base/4_cts.odb run OUTPUT=xxx.txt
source $::env(SCRIPTS_DIR)/open.tcl

set paths [find_timing_paths -path_group reg2reg -sort_by_slack -group_count 1000000]
Expand All @@ -6,6 +8,7 @@ set db [::ord::get_db]
set block [[$db getChip] getBlock]

set fp [open $::env(OUTPUT) w]
puts $fp "stats:"
foreach path $paths {
set endpoint [get_property $path endpoint]
set instance [sta::sta_to_db_inst [$endpoint instance]]
Expand All @@ -23,6 +26,15 @@ foreach path $paths {
set slack [get_property $path slack]
set skew [$path clk_skew]
set bbox [$obj getBBox]
puts $fp "$name $slack $skew [ord::dbu_to_microns [$bbox xMin]] [ord::dbu_to_microns [$bbox yMin]]"
puts $fp " - $name $slack $skew [ord::dbu_to_microns [$bbox xMin]] [ord::dbu_to_microns [$bbox yMin]]"
}

puts $fp "masters:"
foreach master [$block getInsts] {
if {[$master isBlock]} {
set bbox [$master getBBox]
puts $fp " - [$master getName] [ord::dbu_to_microns [$bbox xMin]] [ord::dbu_to_microns [$bbox yMin]] [ord::dbu_to_microns [$bbox xMax]] [ord::dbu_to_microns [$bbox yMax]]"
}
}

close $fp

0 comments on commit 5155fde

Please sign in to comment.