Add constant cost for all non-preferred edges

This commit is contained in:
Eren Dogan 2023-07-29 21:48:33 -07:00
parent 821c763a1e
commit d487f788e3
1 changed files with 5 additions and 7 deletions

View File

@ -63,14 +63,12 @@ class graph_node:
if other in self.neighbors:
is_vertical = self.center.x == other.center.x
layer_dist = self.center.distance(other.center)
# Edge is on non-preferred direction
# Double the cost if the edge is in non-preferred direction
if is_vertical != bool(self.center.z):
layer_dist *= 2
# Wire bends towards non-preferred direction
# NOTE: Adding a fixed cost prevents multiple dog-legs in
# non-preferred direction
if prev_node and self.get_direction(prev_node) != self.get_direction(other):
layer_dist += drc["grid"]
via_dist = abs(self.center.z - other.center.z) * 2
# Add a constant wire cost to prevent dog-legs
if prev_node and self.get_direction(prev_node) != self.get_direction(other):
layer_dist += drc["grid"]
via_dist = abs(self.center.z - other.center.z)
return layer_dist + via_dist
return float("inf")