Skip to content

Commit b1430d3

Browse files
committed
plot: plot yosys gate equivalents against area
Signed-off-by: Øyvind Harboe <[email protected]>
1 parent fa7672b commit b1430d3

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

flow/scripts/plot_keep.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Load two files passed on the command line with dictionaries
2+
# of the format below, then plot XY scatter plot of the data
3+
#
4+
# rvdff_WIDTH13 13
5+
# rvdff_WIDTH14 14
6+
7+
8+
import sys
9+
import matplotlib.pyplot as plt
10+
11+
12+
def load_data(filename):
13+
data = {}
14+
with open(filename) as f:
15+
for line in f:
16+
key, value = line.split()
17+
data[key] = float(value)
18+
return data
19+
20+
21+
def plot_data(x, y):
22+
plt.scatter(x, y)
23+
plt.xlabel("Yosys gate equivalents")
24+
plt.ylabel("OpenROAD area (um^2)")
25+
plt.show()
26+
27+
28+
def main():
29+
if len(sys.argv) != 3:
30+
print("Usage: {} datafile1 datafile2".format(sys.argv[0]))
31+
sys.exit(1)
32+
data1 = load_data(sys.argv[1])
33+
data2 = load_data(sys.argv[2])
34+
keys = set(data1.keys()) & set(data2.keys())
35+
x = [data1[key] for key in keys]
36+
y = [data2[key] for key in keys]
37+
plot_data(x, y)
38+
39+
40+
if __name__ == "__main__":
41+
main()

flow/scripts/report_area.tcl

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
source $::env(SCRIPTS_DIR)/load.tcl
2+
erase_non_stage_variables floorplan
3+
load_design 2_1_floorplan.odb 2_1_floorplan.sdc
4+
5+
set db [ord::get_db]
6+
set chip [$db getChip]
7+
set block [$chip getBlock]
8+
9+
set scale_to_um [expr [$block getDbUnitsPerMicron] * [$block getDbUnitsPerMicron]]
10+
11+
set insts [$block getInsts]
12+
13+
proc insts_area {insts} {
14+
global scale_to_um
15+
set area 0
16+
foreach inst $insts {
17+
set bbox [$inst getBBox]
18+
set area [expr $area + [$bbox getDX] * [$bbox getDY]]
19+
}
20+
return [expr $area / $scale_to_um]
21+
}
22+
23+
proc module_area {module} {
24+
global scale_to_um
25+
set area 0
26+
set insts [$module getLeafInsts]
27+
foreach inst $insts {
28+
set bbox [$inst getBBox]
29+
set area [expr $area + [$bbox getDX] * [$bbox getDY]]
30+
}
31+
return [expr $area / $scale_to_um]
32+
}
33+
34+
set f [open $::env(REPORTS_DIR)/2_area.txt w]
35+
foreach module [$block getModules] {
36+
set area [module_area $module]
37+
puts $f "[$module getName] $area"
38+
}
39+
close $f

flow/scripts/synth.tcl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,22 @@ if {![env_var_equals SYNTH_HIERARCHICAL 1]} {
2222
puts "Ungroup modules below estimated size of $ungroup_threshold instances"
2323

2424
convert_liberty_areas
25+
26+
# Don't know how to enumerate gate equivalents for cells in the design
27+
# so set keep threshold to one and parse log for now
28+
tee -o $::env(OBJECTS_DIR)/1_keep.txt keep_hierarchy -min_cost 1
29+
set f [open $::env(OBJECTS_DIR)/1_keep.txt r]
30+
set keep_hierarchy [read $f]
31+
close $f
32+
set f [open $::env(REPORTS_DIR)/1_keep.txt w]
33+
foreach line [split $keep_hierarchy \n] {
34+
if {[regexp {Keeping (\S+) \(estimated size above threshold: (\d+) >} $line _ cell size]} {
35+
puts $f "$cell $size"
36+
}
37+
}
38+
close $f
39+
# clear change and reapply it with the threshold
40+
setattr -unset A:keep_hierarchy=1
2541
keep_hierarchy -min_cost $ungroup_threshold
2642
} else {
2743
keep_hierarchy

0 commit comments

Comments
 (0)