Skip to content

Commit

Permalink
fix bug in router cost function
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulk29 committed Jan 2, 2024
1 parent b9b33e6 commit 6ccab18
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
16 changes: 4 additions & 12 deletions libs/atoll/src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,15 +710,11 @@ impl<L: AtollLayer + Clone> RoutingState<L> {
///
/// Important: the two coordinates must be adjacent.
fn cost(&self, src: GridCoord, dst: GridCoord, net: NetId) -> usize {
if src.layer == dst.layer {
if self.is_routed_for_net(src, net) && self.is_routed_for_net(dst, net) {
if self[src] == self[dst] {
0
} else {
1
}
if self.is_routed_for_net(src, net) && self.is_routed_for_net(dst, net) {
if self[src] == self[dst] {
0
} else {
4
1
}
} else {
4
Expand Down Expand Up @@ -814,7 +810,6 @@ impl<L: AtollLayer + Clone> RoutingState<L> {
let up = self
.grid
.point_to_grid(pp, next_layer, RoundingMode::Up, RoundingMode::Up);
println!("coord = {coord:?}, pp = {pp:?}, dn = {dn:?}, up = {up:?}");
assert_eq!(dn.coord(!interp_dir), coord.coord(!interp_dir) as i64);
assert_eq!(up.coord(!interp_dir), coord.coord(!interp_dir) as i64);
assert!(dn.x >= 0 && dn.y >= 0);
Expand All @@ -826,7 +821,6 @@ impl<L: AtollLayer + Clone> RoutingState<L> {
y: dn.y as usize,
};
if self.is_available_for_net(next, net) {
println!("via up");
successors.push((next, self.cost(coord, next, net)));
}
}
Expand All @@ -843,7 +837,6 @@ impl<L: AtollLayer + Clone> RoutingState<L> {
let up = self
.grid
.point_to_grid(pp, next_layer, RoundingMode::Up, RoundingMode::Up);
println!("coord = {coord:?}, pp = {pp:?}, dn = {dn:?}, up = {up:?}, interp dir = {interp_dir:?}");
assert_eq!(dn.coord(!interp_dir), coord.coord(!interp_dir) as i64);
assert_eq!(up.coord(!interp_dir), coord.coord(!interp_dir) as i64);
assert!(dn.x >= 0 && dn.y >= 0);
Expand All @@ -855,7 +848,6 @@ impl<L: AtollLayer + Clone> RoutingState<L> {
y: dn.y as usize,
};
if self.is_available_for_net(next, net) {
println!("via down");
successors.push((next, self.cost(coord, next, net)));
}
}
Expand Down
5 changes: 3 additions & 2 deletions libs/atoll/src/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ impl Router for GreedyBfsRouter {
mut state: RoutingState<PdkLayer>,
mut to_connect: Vec<Vec<NetId>>,
) -> Vec<Path> {
println!("state = {state:?}, to_connect = {to_connect:?}");
// build roots map
let mut roots = HashMap::new();
for seq in to_connect.iter() {
Expand Down Expand Up @@ -85,14 +84,16 @@ impl Router for GreedyBfsRouter {

spt.remove(&locs[0]);
let path = build_path(nearest_loc, &spt);
if path.len() <= 1 {
panic!("node was unreachable");
}
for coord in path.iter() {
state[*coord] = PointState::Routed { net: group[0] };
}
paths.push(path);
}
}

println!("paths = {paths:?}");
paths
}
}
Expand Down

0 comments on commit 6ccab18

Please sign in to comment.