Skip to content

Commit b95b2b8

Browse files
committed
handle hierarchical nets and mismatched RC data:
1) Fetch and write the nets data of hierarchical designs, which now also blocked the segments data as a single script writes both. 2) Error out on a segment whose layer is not in the header instead of dropping it silently, and inform when the nets and the segments data list different routing layers. 3) Warn instead of failing when no layer was fitted, inform that the nets file is only read to plot and report unknown units on stderr. Signed-off-by: Arthur Koucher <arthurkoucher@precisioninno.com>
1 parent 9306f6d commit b95b2b8

3 files changed

Lines changed: 36 additions & 17 deletions

File tree

‎flow/util/correlateRC.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,16 @@
3737
# The plots come after the commands so that a plot with no data does not
3838
# withhold them.
3939
if args.plot_cap or args.plot_res:
40-
nets = read_nets_rc(args.nets_rc_file)
40+
nets, nets_routing_layers = read_nets_rc(args.nets_rc_file)
41+
42+
if nets_routing_layers != routing_layers:
43+
print("[Warning] The nets and the segments data have different routing")
44+
print("layers, are the files from different platforms?")
4145

4246
if args.plot_cap:
4347
plot_grt_rcx_diff(nets, "cap", "Capacitance", cap_unit, cap_scale, 1e-12)
4448

4549
if args.plot_res:
4650
plot_grt_rcx_diff(nets, "res", "Resistance", res_unit, res_scale, 1e3)
51+
elif args.nets_rc_file:
52+
print("The nets RC data is only read to plot, so it was skipped.")

‎flow/util/correlateRCHelper.py‎

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def resolve_units(args):
7474
elif res_unit == "kohm":
7575
res_scale = 1e3
7676
else:
77-
print("Unknown resistance unit.")
77+
print("Unknown resistance unit.", file=stderr)
7878
exit(1)
7979

8080
cap_unit = args.cap_unit
@@ -83,29 +83,35 @@ def resolve_units(args):
8383
elif cap_unit == "pf":
8484
cap_scale = 1e-12
8585
else:
86-
print("Unknown capacitance unit.")
86+
print("Unknown capacitance unit.", file=stderr)
8787
exit(1)
8888

8989
return res_unit, res_scale, cap_unit, cap_scale
9090

9191

9292
def read_nets_rc(file_names):
9393
nets = []
94+
routing_layers = []
9495
header_line = None
9596

9697
for file_name in file_names:
9798
print(f"Reading {file_name}.")
9899
with open(file_name) as file:
99100
for line in file:
101+
line = line.strip()
102+
100103
if line.startswith(NETS_HEADER):
101104
if header_line is not None and header_line != line:
102105
print("Layer stack inconsistent.", file=stderr)
103106
exit(1)
104107
header_line = line
108+
routing_layers = [
109+
layer.removesuffix("(routing)")
110+
for layer in line.removeprefix(NETS_HEADER).split()
111+
if layer.endswith("(routing)")
112+
]
105113
continue
106114

107-
line = line.strip()
108-
109115
if not line or line.startswith("#"):
110116
continue
111117

@@ -146,7 +152,7 @@ def read_nets_rc(file_names):
146152
if count > 0:
147153
print(f"Found {count} nets with zero {name}.")
148154

149-
return nets
155+
return nets, routing_layers
150156

151157

152158
def read_segments_rc(file_names):
@@ -161,18 +167,16 @@ def read_segments_rc(file_names):
161167
print(f"Reading {file_name}.")
162168
with open(file_name) as file:
163169
for line in file:
170+
line = line.strip()
171+
164172
if line.startswith(SEGMENTS_HEADER):
165173
if header_line is not None and header_line != line:
166174
print("Layer stack inconsistent.", file=stderr)
167175
exit(1)
168176
header_line = line
169-
routing_layers = (
170-
line.removeprefix(SEGMENTS_HEADER).strip().split(" ")
171-
)
177+
routing_layers = line.removeprefix(SEGMENTS_HEADER).split()
172178
continue
173179

174-
line = line.strip()
175-
176180
if not line or line.startswith("#"):
177181
continue
178182

@@ -190,6 +194,10 @@ def read_segments_rc(file_names):
190194
layer = tokens[2]
191195
length = float(tokens[3])
192196

197+
if layer not in routing_layers:
198+
print(f"Layer {layer} is not in the header.", file=stderr)
199+
exit(1)
200+
193201
layer_segments[layer]["lengths"].append(length)
194202
layer_segments[layer]["resistances"].append(float(tokens[4]))
195203
layer_segments[layer]["capacitances"].append(float(tokens[5]))
@@ -322,9 +330,13 @@ def print_layer_rc(layer_models, res_scale, cap_scale):
322330

323331

324332
def print_wire_rc(layer_models, layer_net_type_length, res_scale, cap_scale):
325-
resistance, capacitance = wire_rc_fit(
326-
layer_models, layer_net_type_length, res_scale, cap_scale
327-
)
333+
result = wire_rc_fit(layer_models, layer_net_type_length, res_scale, cap_scale)
334+
335+
if result is None:
336+
print("[Warning] No layer was fitted.")
337+
return
338+
339+
resistance, capacitance = result
328340

329341
print(
330342
"set_wire_rc -resistance {:.5E} -capacitance {:.5E}".format(

‎flow/util/write_rc_helper.tcl‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
proc fetch_nets_rc { var_name } {
55
upvar 1 $var_name var
66

7-
foreach net [get_nets *] {
7+
foreach net [get_nets -hierarchical *] {
88
set net_name [get_full_name $net]
99
set wire_res [net_wire_res $net]
1010
set wire_cap [net_wire_cap $net]
@@ -28,7 +28,8 @@ 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-
# First, write a header naming the data and listing the layer stack.
31+
# First, write a header naming the data and listing the layer stack, which
32+
# is only read back as a fingerprint of the stack.
3233
puts -nonewline $stream "# Net RC:"
3334
foreach layer [$tech getLayers] {
3435
puts -nonewline $stream " [$layer getName]"
@@ -46,7 +47,7 @@ proc write_nets_rc_csv { filename grt_var rcx_var } {
4647
puts $stream ""
4748

4849
# Then, write the parasitics data of each net.
49-
foreach net [get_nets *] {
50+
foreach net [get_nets -hierarchical *] {
5051
set db_net [sta::sta_to_db_net $net]
5152
set type [$db_net getSigType]
5253

0 commit comments

Comments
 (0)