Skip to content

Commit 9306f6d

Browse files
committed
fix some issues of the new correlationRC structure:
1) Drop the wirelength columns of the nets .csv along with the CORRELATE_DRT_WIRELENGTH handling, as nothing consumes them. 2) Name the data in the header of each .csv and check it, so that swapped and mismatched input files are caught for both of them. 3) Only report zero parasitics when there are any and only read the nets file when a plot was requested. 4) Document that the .csv files are not regenerated on their own. Signed-off-by: Arthur Koucher <arthurkoucher@precisioninno.com>
1 parent 045539b commit 9306f6d

6 files changed

Lines changed: 61 additions & 59 deletions

File tree

‎docs/tutorials/SetRC.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ directory. For example, ./results/asap7/ibex/base/6_segments_rc.csv and
3838
RC values, while the nets data is used to plot the difference between the
3939
global route estimates and the extracted parasitics.
4040

41+
Note that the CSV files are not regenerated on their own after the design is
42+
run again, so delete them to write the RC data of the new run.
43+
4144
```
4245
% make DESIGN_CONFIG=./designs/asap7/ibex/config.mk correlate_rc
4346
```

‎flow/util/correlateRC.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
# The plots come after the commands so that a plot with no data does not
3838
# withhold them.
39-
if args.nets_rc_file:
39+
if args.plot_cap or args.plot_res:
4040
nets = read_nets_rc(args.nets_rc_file)
4141

4242
if args.plot_cap:

‎flow/util/correlateRCHelper.py‎

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
from sklearn.linear_model import LinearRegression
77
import matplotlib.pyplot as plt
88

9-
# Auxiliary variables to catch swapped input .csv files.
10-
SEGMENTS_COLUMNS = 6
11-
NETS_MIN_COLUMNS = 7
9+
# The header of each .csv names its data and lists the layer stack it was
10+
# written for, so it catches both swapped and mismatched input files.
11+
NETS_HEADER = "# Net RC: "
12+
SEGMENTS_HEADER = "# Segment RC: "
13+
14+
ROW_COLUMNS = 6
1215

1316
# The .csv data comes from ODB which stores capacitance in fF.
1417
CAP_FF_TO_F = 1e-15
@@ -88,19 +91,31 @@ def resolve_units(args):
8891

8992
def read_nets_rc(file_names):
9093
nets = []
94+
header_line = None
9195

9296
for file_name in file_names:
9397
print(f"Reading {file_name}.")
9498
with open(file_name) as file:
9599
for line in file:
100+
if line.startswith(NETS_HEADER):
101+
if header_line is not None and header_line != line:
102+
print("Layer stack inconsistent.", file=stderr)
103+
exit(1)
104+
header_line = line
105+
continue
106+
96107
line = line.strip()
97108

98109
if not line or line.startswith("#"):
99110
continue
100111

112+
if header_line is None:
113+
print("No net RC header found in the data.", file=stderr)
114+
exit(1)
115+
101116
tokens = line.split(",")
102117

103-
if len(tokens) < NETS_MIN_COLUMNS:
118+
if len(tokens) != ROW_COLUMNS:
104119
print(f"Malformed net RC line: {line}", file=stderr)
105120
exit(1)
106121

@@ -140,31 +155,34 @@ def read_segments_rc(file_names):
140155
)
141156
layer_net_type_length = defaultdict(lambda: defaultdict(float))
142157
routing_layers = []
143-
routing_layers_line = None
158+
header_line = None
144159

145160
for file_name in file_names:
146161
print(f"Reading {file_name}.")
147162
with open(file_name) as file:
148163
for line in file:
149-
if line.startswith("# routing layers: "):
150-
if routing_layers_line is None:
151-
routing_layers = (
152-
line.removeprefix("# routing layers: ").strip().split(" ")
153-
)
154-
routing_layers_line = line
155-
elif routing_layers_line != line:
164+
if line.startswith(SEGMENTS_HEADER):
165+
if header_line is not None and header_line != line:
156166
print("Layer stack inconsistent.", file=stderr)
157167
exit(1)
168+
header_line = line
169+
routing_layers = (
170+
line.removeprefix(SEGMENTS_HEADER).strip().split(" ")
171+
)
158172
continue
159173

160174
line = line.strip()
161175

162176
if not line or line.startswith("#"):
163177
continue
164178

179+
if header_line is None:
180+
print("No segment RC header found in the data.", file=stderr)
181+
exit(1)
182+
165183
tokens = line.split(",")
166184

167-
if len(tokens) != SEGMENTS_COLUMNS:
185+
if len(tokens) != ROW_COLUMNS:
168186
print(f"Malformed segment RC line: {line}", file=stderr)
169187
exit(1)
170188

@@ -177,10 +195,6 @@ def read_segments_rc(file_names):
177195
layer_segments[layer]["capacitances"].append(float(tokens[5]))
178196
layer_net_type_length[layer][net_type] += length
179197

180-
if not routing_layers:
181-
print("No routing layers header found in the segment RC data.", file=stderr)
182-
exit(1)
183-
184198
if not layer_segments:
185199
print("No segment RC data found.", file=stderr)
186200
exit(1)
@@ -192,7 +206,8 @@ def read_segments_rc(file_names):
192206
for value in segments[key]
193207
if value == 0.0
194208
)
195-
print(f"Found {count} segments with zero {name}.")
209+
if count > 0:
210+
print(f"Found {count} segments with zero {name}.")
196211

197212
return routing_layers, layer_segments, layer_net_type_length
198213

‎flow/util/utils.mk‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,13 @@ $(RESULTS_DIR)/6_nets_rc.csv $(RESULTS_DIR)/6_segments_rc.csv &:
9191
$(RUN_CMD) --log $(LOG_DIR)/6_write_rc.log --tee -- $(OPENROAD_CMD) $(UTILS_DIR)/write_rc.tcl
9292

9393
.PHONY: correlate_rc
94-
correlate_rc: $(RESULTS_DIR)/6_nets_rc.csv $(RESULTS_DIR)/6_segments_rc.csv
94+
correlate_rc: $(RESULTS_DIR)/6_segments_rc.csv
9595
$(PYTHON_EXE) $(UTILS_DIR)/correlateRC.py \
96-
-nets_rc_file $(RESULTS_DIR)/6_nets_rc.csv \
9796
-segments_rc_file $(RESULTS_DIR)/6_segments_rc.csv
9897

9998
# TODO Make always wants to redo designs with this rule, regardless of which variations are tried.
99+
# $(MAKE) DESIGN_CONFIG=$$config write_rc; \
100+
#$(foreach config,$(wildcard designs/$(PLATFORM)/*/config.mk),$(MAKE) DESIGN_CONFIG=$(config) write_rc; )
100101
.PHONY: correlate_platform_rc
101102
correlate_platform_rc:
102103
for config in designs/$(PLATFORM)/*/config.mk; do \
@@ -106,7 +107,6 @@ correlate_platform_rc:
106107
results/$(PLATFORM)/$$design/base/6_segments_rc.csv; \
107108
done
108109
$(PYTHON_EXE) $(UTILS_DIR)/correlateRC.py \
109-
-nets_rc_file $$(find results/$(PLATFORM)/*/base -name 6_nets_rc.csv) \
110110
-segments_rc_file $$(find results/$(PLATFORM)/*/base -name 6_segments_rc.csv)
111111

112112
# Run test using gnu parallel

‎flow/util/write_rc.tcl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fetch_nets_rc rcx_nets_rc
1212

1313
write_nets_rc_csv $::env(RESULTS_DIR)/6_nets_rc.csv grt_nets_rc rcx_nets_rc
1414

15-
# Use RCX to compute and ODB API's to fetch segments' parasitics.
15+
# Use RCX to compute and ODB APIs to fetch segments' parasitics.
1616
# We set up RCX parameters to avoid any parasitics segment merging.
1717
extract_parasitics -ext_model_file $::env(RCX_RULES) -max_res 0 -no_merge_via_res
1818
fetch_segments_rc segments_rc

‎flow/util/write_rc_helper.tcl‎

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@ proc write_nets_rc_csv { filename grt_var rcx_var } {
2828
set tech [ord::get_db_tech]
2929
set stream [open $filename "w"]
3030

31-
puts -nonewline $stream "# stack:"
31+
# First, write a header naming the data and listing the layer stack.
32+
puts -nonewline $stream "# Net RC:"
3233
foreach layer [$tech getLayers] {
33-
set routing [expr [$layer getRoutingLevel] != 0]
34-
set is_routing([$layer getNumber]) $routing
3534
puts -nonewline $stream " [$layer getName]"
36-
if { $routing } {
35+
if { [$layer getRoutingLevel] != 0 } {
3736
puts -nonewline $stream "(routing)"
3837
} else {
3938
# insert via resistance information
@@ -43,44 +42,28 @@ proc write_nets_rc_csv { filename grt_var rcx_var } {
4342
}
4443
}
4544
}
46-
puts $stream ""
4745

48-
set use_drt_data [env_var_exists_and_non_empty CORRELATE_DRT_WIRELENGTH]
46+
puts $stream ""
4947

48+
# Then, write the parasitics data of each net.
5049
foreach net [get_nets *] {
5150
set db_net [sta::sta_to_db_net $net]
5251
set type [$db_net getSigType]
53-
if {
54-
([string equal $type "CLOCK"] || [string equal $type "SIGNAL"]) &&
55-
(!$use_drt_data || [$db_net getWire] ne "NULL")
56-
} {
57-
set net_name [get_full_name $net]
58-
lassign $grt_net_name_to_rc($net_name) grt_net_res grt_net_cap
59-
lassign $rcx_net_name_to_rc($net_name) rcx_net_res rcx_net_cap
60-
set net_type [expr { [string equal $type "CLOCK"] ? "clock" : "signal" }]
61-
puts -nonewline $stream "$net_name,$net_type,"
62-
puts -nonewline $stream [concat \
63-
[format "%.3e" $grt_net_res] "," [format "%.3e" $grt_net_cap] "," \
64-
[format "%.3e" $rcx_net_res] "," [format "%.3e" $rcx_net_cap]]
65-
66-
if { $use_drt_data } {
67-
set layer_lengths [drt::route_layer_lengths [$db_net getWire]]
68-
} else {
69-
set layer_lengths [grt::route_layer_lengths $db_net]
70-
}
7152

72-
for { set layer 0 } { $layer < [$tech getLayerCount] } { incr layer } {
73-
set length [lindex $layer_lengths $layer]
74-
if { $is_routing($layer) } {
75-
puts -nonewline $stream ",[ord::dbu_to_microns $length]"
76-
} else {
77-
puts -nonewline $stream ",$length"
78-
}
79-
}
80-
81-
puts $stream ""
53+
if { !([string equal $type "CLOCK"] || [string equal $type "SIGNAL"]) } {
54+
continue
8255
}
56+
57+
set net_name [get_full_name $net]
58+
set net_type [expr { $type eq "CLOCK" ? "clock" : "signal" }]
59+
60+
lassign $grt_net_name_to_rc($net_name) grt_net_res grt_net_cap
61+
lassign $rcx_net_name_to_rc($net_name) rcx_net_res rcx_net_cap
62+
63+
puts $stream [format "%s,%s,%.3e,%.3e,%.3e,%.3e" \
64+
$net_name $net_type $grt_net_res $grt_net_cap $rcx_net_res $rcx_net_cap]
8365
}
66+
8467
close $stream
8568
}
8669

@@ -147,8 +130,9 @@ proc write_segments_rc_csv { filename net_to_segments_var } {
147130

148131
set stream [open $filename "w"]
149132

150-
# First, write a header listing the routing layers in stack order.
151-
puts -nonewline $stream "# routing layers:"
133+
# First, write a header naming the data and listing the routing layers in
134+
# stack order.
135+
puts -nonewline $stream "# Segment RC:"
152136
foreach layer [[ord::get_db_tech] getLayers] {
153137
if { [$layer getRoutingLevel] != 0 } {
154138
puts -nonewline $stream " [$layer getName]"

0 commit comments

Comments
 (0)