def score_routing(self, routing, usage_matrix):
"""
For the given layout, and the routing, produce the score of the
routing.
The score is composed of its constituent nets' scores, and the
score of each net is based on the number of violations it has,
the number of vias and pins and the ratio of its actual length
and the lower bound on its length.
layout is the 3D matrix produced by the placer.
"""
alpha = 3
beta = 0.1
gamma = 1
net_scores = {}
net_num_violations = {}
# Score each net segment in the entire net
for net_name, d in routing.iteritems():
net_scores[net_name] = []
net_num_violations[net_name] = []
for i, segment in enumerate(d["segments"]):
routed_net = segment["net"]
# Violations
violation_matrix = segment["violation"]
violations = self.compute_net_violations(violation_matrix, usage_matrix)
net_num_violations[net_name].append(violations)
# Number of vias and pins
vias = 0
num_pins = 2
pins_vias = vias - num_pins
# Lower length bound
coord_a = segment["pins"][0]["route_coord"]
coord_b = segment["pins"][1]["route_coord"]
lower_length_bound = max(1, cityblock(coord_a, coord_b))
length_ratio = len(routed_net) / lower_length_bound
score = (alpha * violations) + (beta * pins_vias) + (gamma * length_ratio)
net_scores[net_name].append(score)
# print(routing)
# print(net_scores)
return net_scores, net_num_violations
评论列表
文章目录