99#include " read_netlist.h"
1010
1111
12- // The name suffix of the new block (if exists)
12+ // The name suffix of the new block (if exists)
13+ // This suffex is useful in preventing duplicate high-level cluster block names
1314const char * name_suffix = " _m" ;
1415
1516/* ****************** Static Functions ********************/
16- // static void set_atom_pin_mapping(const ClusteredNetlist& clb_nlist, const AtomBlockId atom_blk, const AtomPortId atom_port, const t_pb_graph_pin* gpin);
1717static void load_atom_index_for_pb_pin (t_pb_routes& pb_route, int ipin);
1818static void load_internal_to_block_net_nums (const t_logical_block_type_ptr type, t_pb_routes& pb_route);
19- // static bool count_children_pbs(const t_pb* pb);
2019static void fix_atom_pin_mapping (const AtomBlockId blk);
2120
2221static void fix_cluster_pins_after_moving (const ClusterBlockId clb_index);
@@ -41,6 +40,7 @@ static void update_cluster_pb_stats(const t_pack_molecule* molecule,
4140 int molecule_size,
4241 ClusterBlockId clb_index,
4342 bool is_added);
43+
4444/* **************** API functions ***********************/
4545ClusterBlockId atom_to_cluster (const AtomBlockId& atom) {
4646 auto & atom_ctx = g_vpr_ctx.atom ();
@@ -65,19 +65,18 @@ void remove_mol_from_cluster(const t_pack_molecule* molecule,
6565 t_lb_router_data*& router_data) {
6666 auto & helper_ctx = g_vpr_ctx.mutable_cl_helper ();
6767
68- // re-build router_data structure for this cluster
69- if (!router_data_ready)
70- router_data = lb_load_router_data (helper_ctx.lb_type_rr_graphs , old_clb, old_clb_atoms);
71-
72- // remove atom from router_data
7368 for (int i_atom = 0 ; i_atom < molecule_size; i_atom++) {
7469 if (molecule->atom_block_ids [i_atom]) {
75- remove_atom_from_target (router_data, molecule->atom_block_ids [i_atom]);
7670 auto it = old_clb_atoms->find (molecule->atom_block_ids [i_atom]);
7771 if (it != old_clb_atoms->end ())
7872 old_clb_atoms->erase (molecule->atom_block_ids [i_atom]);
7973 }
8074 }
75+
76+ // re-build router_data structure for this cluster
77+ if (!router_data_ready)
78+ router_data = lb_load_router_data (helper_ctx.lb_type_rr_graphs , old_clb, old_clb_atoms);
79+
8180 update_cluster_pb_stats (molecule, molecule_size, old_clb, false );
8281}
8382
@@ -87,7 +86,7 @@ void commit_mol_move(const ClusterBlockId& old_clb,
8786 bool new_clb_created) {
8887 auto & device_ctx = g_vpr_ctx.device ();
8988
90- // Place the new cluster if this function called during placement (after the initial placement is done)
89+ // place the new cluster if this function called during placement (after the initial placement is done)
9190 if (!during_packing && new_clb_created) {
9291 int imacro;
9392 g_vpr_ctx.mutable_placement ().block_locs .resize (g_vpr_ctx.placement ().block_locs .size () + 1 );
@@ -100,6 +99,7 @@ void commit_mol_move(const ClusterBlockId& old_clb,
10099t_lb_router_data* lb_load_router_data (std::vector<t_lb_type_rr_node>* lb_type_rr_graphs, const ClusterBlockId& clb_index, const std::unordered_set<AtomBlockId>* clb_atoms) {
101100 // build data structures used by intra-logic block router
102101 auto & cluster_ctx = g_vpr_ctx.clustering ();
102+ auto & atom_ctx = g_vpr_ctx.atom ();
103103 auto block_type = cluster_ctx.clb_nlist .block_type (clb_index);
104104 t_lb_router_data* router_data = alloc_and_load_router_data (&lb_type_rr_graphs[block_type->index ], block_type);
105105
@@ -109,14 +109,19 @@ t_lb_router_data* lb_load_router_data(std::vector<t_lb_type_rr_node>* lb_type_rr
109109
110110 for (auto atom_id : *clb_atoms) {
111111 add_atom_as_target (router_data, atom_id);
112+ const t_pb* pb = atom_ctx.lookup .atom_pb (atom_id);
113+ while (pb) {
114+ set_reset_pb_modes (router_data, pb, true );
115+ pb = pb->parent_pb ;
116+ }
112117 }
113118 return (router_data);
114119}
115120
116121bool start_new_cluster_for_mol (t_pack_molecule* molecule,
117122 const t_logical_block_type_ptr& type,
118- const int mode,
119- const int feasible_block_array_size,
123+ const int & mode,
124+ const int & feasible_block_array_size,
120125 bool enable_pin_feasibility_filter,
121126 ClusterBlockId clb_index,
122127 bool during_packing,
@@ -148,10 +153,11 @@ bool start_new_cluster_for_mol(t_pack_molecule* molecule,
148153
149154 e_block_pack_status pack_result = e_block_pack_status::BLK_STATUS_UNDEFINED;
150155 pb->mode = mode;
151- reset_cluster_placement_stats (&(helper_ctx.cluster_placement_stats [type->index ]));
156+ t_cluster_placement_stats* cluster_placement_stats = &(helper_ctx.cluster_placement_stats [type->index ]);
157+ reset_cluster_placement_stats (cluster_placement_stats);
152158 set_mode_cluster_placement_stats (pb->pb_graph_node , mode);
153159
154- pack_result = try_pack_molecule (&(helper_ctx. cluster_placement_stats [type-> index ]) ,
160+ pack_result = try_pack_molecule (cluster_placement_stats,
155161 molecule,
156162 helper_ctx.primitives_list ,
157163 pb,
@@ -178,6 +184,8 @@ bool start_new_cluster_for_mol(t_pack_molecule* molecule,
178184 pb->name = vtr::strdup (new_name.c_str ());
179185 clb_index = cluster_ctx.clb_nlist .create_block (new_name.c_str (), pb, type);
180186 helper_ctx.total_clb_num ++;
187+ int molecule_size = get_array_size_of_molecule (molecule);
188+ update_cluster_pb_stats (molecule, molecule_size, clb_index, true );
181189
182190 // If you are still in packing, update the clustering data. Otherwise, update the clustered netlist.
183191 if (during_packing) {
@@ -200,10 +208,9 @@ bool start_new_cluster_for_mol(t_pack_molecule* molecule,
200208
201209bool pack_mol_in_existing_cluster (t_pack_molecule* molecule,
202210 int molecule_size,
203- const ClusterBlockId new_clb,
211+ const ClusterBlockId& new_clb,
204212 std::unordered_set<AtomBlockId>* new_clb_atoms,
205213 bool during_packing,
206- bool is_swap,
207214 t_clustering_data& clustering_data,
208215 t_lb_router_data*& router_data) {
209216 auto & helper_ctx = g_vpr_ctx.mutable_cl_helper ();
@@ -222,8 +229,7 @@ bool pack_mol_in_existing_cluster(t_pack_molecule* molecule,
222229 return false ;
223230
224231 // re-build router_data structure for this cluster
225- if (!is_swap)
226- router_data = lb_load_router_data (helper_ctx.lb_type_rr_graphs , new_clb, new_clb_atoms);
232+ router_data = lb_load_router_data (helper_ctx.lb_type_rr_graphs , new_clb, new_clb_atoms);
227233
228234 pack_result = try_pack_molecule (&(helper_ctx.cluster_placement_stats [block_type->index ]),
229235 molecule,
@@ -262,11 +268,9 @@ bool pack_mol_in_existing_cluster(t_pack_molecule* molecule,
262268 update_cluster_pb_stats (molecule, molecule_size, new_clb, true );
263269 }
264270
265- if (!is_swap) {
266- // Free clustering router data
267- free_router_data (router_data);
268- router_data = nullptr ;
269- }
271+ // Free clustering router data
272+ free_router_data (router_data);
273+ router_data = nullptr ;
270274
271275 return (pack_result == e_block_pack_status::BLK_PASSED);
272276}
@@ -735,4 +739,4 @@ static void update_cluster_pb_stats(const t_pack_molecule* molecule,
735739 cur_pb = cur_pb->parent_pb ;
736740 }
737741 }
738- }
742+ }
0 commit comments