@@ -33,6 +33,48 @@ double PartialPlacement::get_hpwl(const APNetlist& netlist) const {
33
33
return hpwl;
34
34
}
35
35
36
+ double PartialPlacement::estimate_post_placement_wirelength (const APNetlist& netlist) const {
37
+ // Go through each net and calculate the half-perimeter wirelength. Since
38
+ // we want to estimate the post-placement wirelength, we do not want the
39
+ // flat placement positions of the blocks. Instead we compute the HPWL over
40
+ // the tiles that the flat placement is placing the blocks over.
41
+ unsigned total_hpwl = 0 ;
42
+ for (APNetId net_id : netlist.nets ()) {
43
+ // Note: Other wirelength estimates in VTR ignore global nets; however
44
+ // it is not known if a net is global or not until packing is
45
+ // complete. For now, we just approximate post-placement wirelength
46
+ // using the HPWL (in tile space).
47
+ // TODO: The reason we do not know what nets are ignored / global is
48
+ // because the pin on the tile that the net connects to is what
49
+ // decides if a net is global / ignored for place and route. Since
50
+ // we have not packed anything yet, we do not know what pin each
51
+ // net will go to; however, we can probably get a good idea based
52
+ // on some properties of the net and the tile its going to / from.
53
+ // Should investigate this to get a better estimate of wirelength.
54
+ double min_x = std::numeric_limits<unsigned >::max ();
55
+ double max_x = std::numeric_limits<unsigned >::lowest ();
56
+ double min_y = std::numeric_limits<unsigned >::max ();
57
+ double max_y = std::numeric_limits<unsigned >::lowest ();
58
+ for (APPinId pin_id : netlist.net_pins (net_id)) {
59
+ APBlockId blk_id = netlist.pin_block (pin_id);
60
+ min_x = std::min (min_x, block_x_locs[blk_id]);
61
+ max_x = std::max (max_x, block_x_locs[blk_id]);
62
+ min_y = std::min (min_y, block_y_locs[blk_id]);
63
+ max_y = std::max (max_y, block_y_locs[blk_id]);
64
+ }
65
+ VTR_ASSERT_SAFE (max_x >= min_x && max_y >= min_y);
66
+
67
+ // Floor the positions to get the x and y coordinates of the tiles each
68
+ // block belongs to.
69
+ unsigned tile_dx = std::floor (max_x) - std::floor (min_x);
70
+ unsigned tile_dy = std::floor (max_y) - std::floor (min_y);
71
+
72
+ total_hpwl += tile_dx + tile_dy;
73
+ }
74
+
75
+ return total_hpwl;
76
+ }
77
+
36
78
bool PartialPlacement::verify_locs (const APNetlist& netlist,
37
79
size_t grid_width,
38
80
size_t grid_height) const {
0 commit comments