@@ -117,6 +117,14 @@ static AtomBlockId get_driving_block(const AtomBlockId block_id,
117
117
const t_pack_pattern_connections& connections,
118
118
const AtomNetlist& atom_nlist);
119
119
120
+ /* *
121
+ * @brief Get an unordered set of all pb_types in the given pack pattern
122
+ *
123
+ * @param pack_pattern Pack pattern to get pb_types from
124
+ * @return std::unordered_set<t_pb_type*> Set of pb_types in the pack pattern
125
+ */
126
+ static std::unordered_set<t_pb_type*> get_pattern_blocks (const t_pack_patterns* pack_pattern);
127
+
120
128
static void print_chain_starting_points (t_pack_patterns* chain_pattern);
121
129
122
130
/* ****************************************/
@@ -1172,6 +1180,47 @@ static AtomBlockId get_driving_block(const AtomBlockId block_id,
1172
1180
return AtomBlockId::INVALID ();
1173
1181
}
1174
1182
1183
+ static std::unordered_set<t_pb_type*> get_pattern_blocks (const t_pack_patterns* pack_pattern) {
1184
+ std::unordered_set<t_pb_type*> pattern_blocks;
1185
+
1186
+ auto connections = pack_pattern->root_block ->connections ;
1187
+ if (connections == nullptr ) {
1188
+ return pattern_blocks;
1189
+ }
1190
+ std::unordered_set<t_pb_graph_pin*> visited_from_pins;
1191
+ std::unordered_set<t_pb_graph_pin*> visited_to_pins;
1192
+ std::queue<t_pack_pattern_block*> pack_pattern_blocks;
1193
+ pack_pattern_blocks.push (connections->from_block );
1194
+ /* * Start from the root block of the pack pattern and add the connected block to the queue */
1195
+ while (!pack_pattern_blocks.empty ()) {
1196
+ auto current_pattern_block = pack_pattern_blocks.front ();
1197
+ pack_pattern_blocks.pop ();
1198
+ auto current_connenction = current_pattern_block->connections ;
1199
+ /* * Iterate through all the connections of the current pattern block to
1200
+ * add the connected block to the queue
1201
+ */
1202
+ while (current_connenction != nullptr ) {
1203
+ if (visited_from_pins.count (current_connenction->from_pin )) {
1204
+ if (visited_to_pins.count (current_connenction->to_pin )) {
1205
+ /* We've already seen this connection */
1206
+ current_connenction = current_connenction->next ;
1207
+ continue ;
1208
+ }
1209
+ }
1210
+ /* * To avoid visiting the same connection twice, since it is both stored in from_pin and to_pin,
1211
+ * add the from_pin and to_pin to the visited sets
1212
+ */
1213
+ visited_from_pins.insert (current_connenction->from_pin );
1214
+ visited_to_pins.insert (current_connenction->to_pin );
1215
+ /* * The from_pin block belongs to the pattern block */
1216
+ pattern_blocks.insert (current_connenction->from_pin ->port ->parent_pb_type );
1217
+ pack_pattern_blocks.push (current_connenction->to_block );
1218
+ current_connenction = current_connenction->next ;
1219
+ }
1220
+ }
1221
+ return pattern_blocks;
1222
+ }
1223
+
1175
1224
static void print_pack_molecules (const char * fname,
1176
1225
const std::vector<t_pack_patterns>& list_of_pack_patterns,
1177
1226
const int num_pack_patterns,
0 commit comments