Skip to content

Commit e2f6387

Browse files
committed
wip
1 parent 326ed14 commit e2f6387

File tree

3 files changed

+65
-7
lines changed

3 files changed

+65
-7
lines changed

flow/scripts/plot_keep.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@ def load_data(filename):
1818
return data
1919

2020

21-
def plot_data(x, y):
21+
def plot_data(x, y, labels):
22+
# add a label along with each data point
2223
plt.scatter(x, y)
23-
plt.xlabel("Yosys gate equivalents")
24-
plt.ylabel("OpenROAD area (um^2)")
24+
for i, label in enumerate(labels):
25+
plt.annotate(label, (x[i], y[i]))
26+
plt.xlabel("Yosys coarse gate equivalents")
27+
plt.ylabel("Yosys fine synthesis gate equivalents")
28+
# plt.ylabel("OpenROAD area (um^2)")
2529
plt.show()
2630

2731

@@ -33,9 +37,13 @@ def main():
3337
data2 = load_data(sys.argv[2])
3438
keys = set(data1.keys()) & set(data2.keys())
3539
max_value = 3000
36-
x = [data1[key] for key in keys if data1[key] < max_value and data2[key] < max_value]
37-
y = [data2[key] for key in keys if data1[key] < max_value and data2[key] < max_value]
38-
plot_data(x, y)
40+
#keys = [key for key in keys if data1[key] > max_value and data2[key] < 1000]
41+
#print(keys)
42+
x = [data1[key] for key in keys]
43+
y = [data2[key] for key in keys]
44+
#print(list(zip(keys, x, y)))
45+
# label = [key for key in keys]
46+
plot_data(x, y, keys)
3947

4048

4149
if __name__ == "__main__":

flow/scripts/report_gates.tcl

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
source $::env(SCRIPTS_DIR)/yosys_load.tcl
2+
3+
proc convert_liberty_areas {} {
4+
cellmatch -derive_luts =A:liberty_cell
5+
# find a reference nand2 gate
6+
set found_cell ""
7+
set found_cell_area ""
8+
# iterate over all cells with a nand2 signature
9+
foreach cell [tee -q -s result.string select -list-mod =*/a:lut=4'b0111 %m] {
10+
if {! [rtlil::has_attr -mod $cell area]} {
11+
puts "Cell $cell missing area information"
12+
continue
13+
}
14+
set area [rtlil::get_attr -string -mod $cell area]
15+
if {$found_cell == "" || [expr $area < $found_cell_area]} {
16+
set found_cell $cell
17+
set found_cell_area $area
18+
}
19+
}
20+
if {$found_cell == ""} {
21+
error "reference nand2 cell not found"
22+
}
23+
24+
# convert the area on all Liberty cells to a gate number equivalent
25+
foreach box [tee -q -s result.string select -list-mod =A:area =A:liberty_cell %i] {
26+
set area [rtlil::get_attr -mod -string $box area]
27+
set gate_eq [expr int($area / $found_cell_area)]
28+
rtlil::set_attr -mod -uint $box gate_cost_equivalent $gate_eq
29+
}
30+
}
31+
32+
convert_liberty_areas
33+
34+
setattr -unset A:keep_hierarchy=1
35+
36+
# Don't know how to enumerate gate equivalents for cells in the design
37+
# so set keep threshold to one and parse log for now
38+
tee -o $::env(OBJECTS_DIR)/1_gates.txt keep_hierarchy -min_cost 1
39+
set f [open $::env(OBJECTS_DIR)/1_gates.txt r]
40+
set keep_hierarchy [read $f]
41+
close $f
42+
set f [open $::env(REPORTS_DIR)/1_gates.txt w]
43+
foreach line [split $keep_hierarchy \n] {
44+
if {[regexp {Keeping (\S+) \(estimated size above threshold: (\d+) >} $line _ cell size]} {
45+
puts $f "$cell $size"
46+
}
47+
}
48+
close $f

flow/scripts/synth.tcl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ if {![env_var_equals SYNTH_HIERARCHICAL 1]} {
1515
} else {
1616
# Perform standard coarse-level synthesis script,
1717
# defer flattening until we have decided what hierarchy to keep
18-
synth -run :fine
18+
procs
19+
memory -nomap
1920

2021
if {[env_var_exists_and_non_empty MAX_UNGROUP_SIZE]} {
2122
set ungroup_threshold $::env(MAX_UNGROUP_SIZE)
@@ -36,6 +37,7 @@ if {![env_var_equals SYNTH_HIERARCHICAL 1]} {
3637
}
3738
}
3839
close $f
40+
exit 1
3941
# clear change and reapply it with the threshold
4042
setattr -unset A:keep_hierarchy=1
4143
keep_hierarchy -min_cost $ungroup_threshold

0 commit comments

Comments
 (0)