Skip to content

Commit

Permalink
skew: 3d plot
Browse files Browse the repository at this point in the history
Signed-off-by: Øyvind Harboe <[email protected]>
  • Loading branch information
oharboe committed Oct 31, 2024
1 parent d7e7419 commit 2965bd3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
14 changes: 7 additions & 7 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -310,20 +310,20 @@ boom_regfile_rams = {
]

orfs_run(
name = "slack",
src = ":BoomTile_cts",
outs = ["slack.txt"],
name = "xy_stats",
src = ":BoomTile_1_cts",
outs = ["xy_stats"],
arguments = {
"OUTPUT": "$(location :slack.txt)",
"OUTPUT": "$(location :xy_stats)",
},
script = ":slack-positions.tcl",
)

sh_binary(
name = "show_slack",
name = "show_skew",
srcs = ["plot-3d-slack.py"],
args = ["$(location :slack)"],
data = ["slack"],
args = ["$(location :xy_stats)"],
data = ["xy_stats"],
visibility = ["//visibility:public"],
)

Expand Down
24 changes: 12 additions & 12 deletions plot-3d-slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,33 @@ def load_data(filename):
with open(filename, "r") as file:
for line in file:
parts = line.split()
if len(parts) == 4:
s = float(parts[1])
slack.append(s)
x.append(float(parts[2])/1000)
y.append(float(parts[3])/1000)
if len(parts) == 5:
s = float(parts[2])
slack.append(s * pow(10, 12))
x.append(float(parts[3]))
y.append(float(parts[4]))

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


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

fig = plt.figure()
ax = fig.add_subplot(111, projection="3d")
surf = ax.plot_surface(grid_x, grid_y, grid_z, cmap="viridis")

ax.set_xlabel("X Position")
ax.set_ylabel("Y Position")
ax.set_zlabel("Slack")
ax.set_xlabel("X")
ax.set_ylabel("Y")
ax.set_zlabel("Skew")
fig.colorbar(surf, ax=ax, shrink=0.5, aspect=5)

plt.show()


if __name__ == "__main__":
filename = sys.argv[1]
x, y, slack = load_data(filename)
plot_3d(x, y, slack)
x, y, z = load_data(filename)
plot_3d(x, y, z)
30 changes: 15 additions & 15 deletions slack-positions.tcl
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
source $::env(SCRIPTS_DIR)/load.tcl
load_design 4_cts.odb 4_cts.sdc
source $::env(SCRIPTS_DIR)/open.tcl

set paths [find_timing_paths -path_group reg2reg -sort_by_slack -group_count 1000000]

set db [::ord::get_db]
set block [[$db getChip] getBlock]

# open file
set fp [open $::env(OUTPUT) w]
foreach path $paths {
set endpoint [get_property $path endpoint]
set instance [$endpoint instance]
set instance [sta::sta_to_db_inst [$endpoint instance]]
set port [sta::sta_to_db_port [$endpoint port]]
set name [get_property $endpoint full_name]
set slack [get_property $path slack]

# If DFF is in the $name and it ends with /D
if {[regexp {DFF} $name] && [regexp {/D$} $name]} {
# remove the /D suffix
set name [string range $name 0 end-2]
# replace [ and ] with \[ and \]
set name [string map { {[} {\[} {]} {\]} } $name]
set b [$block findInst $name]
set bbox [$b getBBox]
puts $fp "$name $slack [$bbox xMin] [$bbox yMin]"
set obj {NULL}
if {$port!={NULL}} {
set obj $port
} elseif {$instance!={NULL}} {
set obj $instance
} else {
puts "Nothing found for $name"
continue
}
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]]"
}
close $fp

2 comments on commit 2965bd3

@jeffng-or
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: bazel is complaining:

WARNING: .../BUILD.bazel:312:9: target 'xy_stats' is both a rule and a file; please choose another name for the rule

@oharboe
Copy link
Collaborator Author

@oharboe oharboe commented on 2965bd3 Nov 1, 2024 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.