|
1 | 1 | // SPDX-License-Identifier: BSD-3-Clause |
2 | 2 | // Copyright (c) 2021-2025, The OpenROAD Authors |
3 | 3 |
|
4 | | -% |
5 | | -{ |
| 4 | +%{ |
| 5 | +#include "ord/OpenRoad.hh" |
| 6 | +#include "mpl/rtl_mp.h" |
6 | 7 | #include "MplObserver.h" |
7 | 8 | #include "graphics.h" |
8 | | -#include "mpl/rtl_mp.h" |
9 | 9 | #include "odb/db.h" |
10 | | -#include "ord/OpenRoad.hh" |
11 | 10 |
|
12 | | - namespace ord { |
13 | | - // Defined in OpenRoad.i |
14 | | - mpl::MacroPlacer* getMacroPlacer(); |
15 | | - utl::Logger* getLogger(); |
16 | | - } // namespace ord |
| 11 | +namespace ord { |
| 12 | +// Defined in OpenRoad.i |
| 13 | +mpl::MacroPlacer* |
| 14 | +getMacroPlacer(); |
| 15 | +utl::Logger* getLogger(); |
| 16 | +} |
| 17 | + |
| 18 | +using utl::MPL; |
| 19 | +using ord::getMacroPlacer; |
| 20 | +%} |
| 21 | + |
| 22 | +%include "../../Exception.i" |
| 23 | +%include <std_string.i> |
| 24 | + |
| 25 | +%inline %{ |
| 26 | + |
| 27 | +namespace mpl { |
| 28 | + |
| 29 | +bool rtl_macro_placer_cmd(const int max_num_macro, |
| 30 | + const int min_num_macro, |
| 31 | + const int max_num_inst, |
| 32 | + const int min_num_inst, |
| 33 | + const float tolerance, |
| 34 | + const int max_num_level, |
| 35 | + const float coarsening_ratio, |
| 36 | + const int large_net_threshold, |
| 37 | + const float halo_width, |
| 38 | + const float halo_height, |
| 39 | + const float fence_lx, |
| 40 | + const float fence_ly, |
| 41 | + const float fence_ux, |
| 42 | + const float fence_uy, |
| 43 | + const float area_weight, |
| 44 | + const float outline_weight, |
| 45 | + const float wirelength_weight, |
| 46 | + const float guidance_weight, |
| 47 | + const float fence_weight, |
| 48 | + const float boundary_weight, |
| 49 | + const float notch_weight, |
| 50 | + const float macro_blockage_weight, |
| 51 | + const float target_util, |
| 52 | + const float target_dead_space, |
| 53 | + const float min_ar, |
| 54 | + const char* report_directory, |
| 55 | + const bool keep_clustering_data) { |
| 56 | + |
| 57 | + auto macro_placer = getMacroPlacer(); |
| 58 | + const int num_threads = ord::OpenRoad::openRoad()->getThreadCount(); |
| 59 | + auto block = ord::OpenRoad::openRoad()->getDb()->getChip()->getBlock(); |
| 60 | + odb::Rect global_fence = odb::Rect(block->micronsToDbu(fence_lx), |
| 61 | + block->micronsToDbu(fence_ly), |
| 62 | + block->micronsToDbu(fence_ux), |
| 63 | + block->micronsToDbu(fence_uy)); |
| 64 | + return macro_placer->place(num_threads, |
| 65 | + max_num_macro, |
| 66 | + min_num_macro, |
| 67 | + max_num_inst, |
| 68 | + min_num_inst, |
| 69 | + tolerance, |
| 70 | + max_num_level, |
| 71 | + coarsening_ratio, |
| 72 | + large_net_threshold, |
| 73 | + block->micronsToDbu(halo_width), |
| 74 | + block->micronsToDbu(halo_height), |
| 75 | + global_fence, |
| 76 | + area_weight, |
| 77 | + outline_weight, |
| 78 | + wirelength_weight, |
| 79 | + guidance_weight, |
| 80 | + fence_weight, |
| 81 | + boundary_weight, |
| 82 | + notch_weight, |
| 83 | + macro_blockage_weight, |
| 84 | + target_util, |
| 85 | + target_dead_space, |
| 86 | + min_ar, |
| 87 | + report_directory, |
| 88 | + keep_clustering_data); |
| 89 | +} |
| 90 | + |
| 91 | +void set_debug_cmd(odb::dbBlock* block, |
| 92 | + bool coarse, |
| 93 | + bool fine, |
| 94 | + bool show_bundled_nets, |
| 95 | + bool show_clusters_ids, |
| 96 | + bool skip_steps, |
| 97 | + bool only_final_result, |
| 98 | + int target_cluster_id) |
| 99 | +{ |
| 100 | + auto macro_placer = getMacroPlacer(); |
| 101 | + std::unique_ptr<MplObserver> graphics |
| 102 | + = std::make_unique<Graphics>(coarse, fine, block, ord::getLogger()); |
| 103 | + macro_placer->setDebug(graphics); |
| 104 | + macro_placer->setDebugShowBundledNets(show_bundled_nets); |
| 105 | + macro_placer->setDebugShowClustersIds(show_clusters_ids); |
| 106 | + macro_placer->setDebugSkipSteps(skip_steps); |
| 107 | + macro_placer->setDebugOnlyFinalResult(only_final_result); |
| 108 | + macro_placer->setDebugTargetClusterId(target_cluster_id); |
| 109 | +} |
| 110 | + |
| 111 | +void |
| 112 | +place_macro(odb::dbInst* inst, |
| 113 | + float x_origin, |
| 114 | + float y_origin, |
| 115 | + std::string orientation_string, |
| 116 | + bool exact, |
| 117 | + bool allow_overlap) |
| 118 | +{ |
| 119 | + odb::dbOrientType orientation(orientation_string.c_str()); |
17 | 120 |
|
18 | | - using ord::getMacroPlacer; |
19 | | - using utl::MPL; |
20 | | - % |
| 121 | + getMacroPlacer()->placeMacro( |
| 122 | + inst, x_origin, y_origin, orientation, exact, allow_overlap); |
| 123 | +} |
| 124 | + |
| 125 | +void |
| 126 | +add_guidance_region(odb::dbInst* macro, |
| 127 | + float x1, |
| 128 | + float y1, |
| 129 | + float x2, |
| 130 | + float y2) |
| 131 | +{ |
| 132 | + auto block = ord::OpenRoad::openRoad()->getDb()->getChip()->getBlock(); |
| 133 | + odb::Rect region = odb::Rect(block->micronsToDbu(x1), |
| 134 | + block->micronsToDbu(y1), |
| 135 | + block->micronsToDbu(x2), |
| 136 | + block->micronsToDbu(y2)); |
| 137 | + getMacroPlacer()->addGuidanceRegion(macro, region); |
21 | 138 | } |
22 | 139 |
|
23 | | -% include "../../Exception.i" % include<std_string.i> |
24 | 140 |
|
25 | | - % inline % |
| 141 | +void |
| 142 | +set_macro_placement_file(std::string file_name) |
26 | 143 | { |
27 | | - namespace mpl { |
28 | | - |
29 | | - bool rtl_macro_placer_cmd(const int max_num_macro, |
30 | | - const int min_num_macro, |
31 | | - const int max_num_inst, |
32 | | - const int min_num_inst, |
33 | | - const float tolerance, |
34 | | - const int max_num_level, |
35 | | - const float coarsening_ratio, |
36 | | - const int large_net_threshold, |
37 | | - const float halo_width, |
38 | | - const float halo_height, |
39 | | - const float fence_lx, |
40 | | - const float fence_ly, |
41 | | - const float fence_ux, |
42 | | - const float fence_uy, |
43 | | - const float area_weight, |
44 | | - const float outline_weight, |
45 | | - const float wirelength_weight, |
46 | | - const float guidance_weight, |
47 | | - const float fence_weight, |
48 | | - const float boundary_weight, |
49 | | - const float notch_weight, |
50 | | - const float macro_blockage_weight, |
51 | | - const float target_util, |
52 | | - const float target_dead_space, |
53 | | - const float min_ar, |
54 | | - const char* report_directory, |
55 | | - const bool keep_clustering_data) |
56 | | - { |
57 | | - auto macro_placer = getMacroPlacer(); |
58 | | - auto block = ord::OpenRoad::openRoad()->getDb()->getChip()->getBlock(); |
59 | | - odb::Rect global_fence = odb::Rect(block->micronsToDbu(fence_lx), |
60 | | - block->micronsToDbu(fence_ly), |
61 | | - block->micronsToDbu(fence_ux), |
62 | | - block->micronsToDbu(fence_uy)); |
63 | | - const int num_threads = ord::OpenRoad::openRoad()->getThreadCount(); |
64 | | - return macro_placer->place(num_threads, |
65 | | - max_num_macro, |
66 | | - min_num_macro, |
67 | | - max_num_inst, |
68 | | - min_num_inst, |
69 | | - tolerance, |
70 | | - max_num_level, |
71 | | - coarsening_ratio, |
72 | | - large_net_threshold, |
73 | | - block->micronsToDbu(halo_width), |
74 | | - block->micronsToDbu(halo_height), |
75 | | - global_fence, |
76 | | - area_weight, |
77 | | - outline_weight, |
78 | | - wirelength_weight, |
79 | | - guidance_weight, |
80 | | - fence_weight, |
81 | | - boundary_weight, |
82 | | - notch_weight, |
83 | | - macro_blockage_weight, |
84 | | - target_util, |
85 | | - target_dead_space, |
86 | | - min_ar, |
87 | | - report_directory, |
88 | | - keep_clustering_data); |
89 | | - } |
90 | | - |
91 | | - void set_debug_cmd(odb::dbBlock* block, |
92 | | - bool coarse, |
93 | | - bool fine, |
94 | | - bool show_bundled_nets, |
95 | | - bool show_clusters_ids, |
96 | | - bool skip_steps, |
97 | | - bool only_final_result, |
98 | | - int target_cluster_id) |
99 | | - { |
100 | | - auto macro_placer = getMacroPlacer(); |
101 | | - std::unique_ptr<MplObserver> graphics |
102 | | - = std::make_unique<Graphics>(coarse, fine, block, ord::getLogger()); |
103 | | - macro_placer->setDebug(graphics); |
104 | | - macro_placer->setDebugShowBundledNets(show_bundled_nets); |
105 | | - macro_placer->setDebugShowClustersIds(show_clusters_ids); |
106 | | - macro_placer->setDebugSkipSteps(skip_steps); |
107 | | - macro_placer->setDebugOnlyFinalResult(only_final_result); |
108 | | - macro_placer->setDebugTargetClusterId(target_cluster_id); |
109 | | - } |
110 | | - |
111 | | - void place_macro(odb::dbInst* inst, |
112 | | - float x_origin, |
113 | | - float y_origin, |
114 | | - std::string orientation_string, |
115 | | - bool exact, |
116 | | - bool allow_overlap) |
117 | | - { |
118 | | - odb::dbOrientType orientation(orientation_string.c_str()); |
119 | | - |
120 | | - getMacroPlacer()->placeMacro( |
121 | | - inst, x_origin, y_origin, orientation, exact, allow_overlap); |
122 | | - } |
123 | | - |
124 | | - void add_guidance_region(odb::dbInst* macro, |
125 | | - float x1, |
126 | | - float y1, |
127 | | - float x2, |
128 | | - float y2) |
129 | | - { |
130 | | - auto block = ord::OpenRoad::openRoad()->getDb()->getChip()->getBlock(); |
131 | | - odb::Rect region = odb::Rect(block->micronsToDbu(x1), |
132 | | - block->micronsToDbu(y1), |
133 | | - block->micronsToDbu(x2), |
134 | | - block->micronsToDbu(y2)); |
135 | | - getMacroPlacer()->addGuidanceRegion(macro, region); |
136 | | - } |
137 | | - |
138 | | - void set_macro_placement_file(std::string file_name) |
139 | | - { |
140 | | - getMacroPlacer()->setMacroPlacementFile(file_name); |
141 | | - } |
142 | | - |
143 | | - } // namespace mpl |
144 | | - |
145 | | - % |
146 | | -} // inline |
| 144 | + getMacroPlacer()->setMacroPlacementFile(file_name); |
| 145 | +} |
| 146 | + |
| 147 | +} // namespace |
| 148 | + |
| 149 | +%} // inline |
0 commit comments