@@ -228,6 +228,77 @@ class ClusteredNetlist : public Netlist<ClusterBlockId, ClusterPortId, ClusterPi
228228 // /@brief Sets the flag in net_is_global_ = state
229229 void set_net_is_global (ClusterNetId net_id, bool state);
230230
231+ /* *
232+ * @brief Given a name of a block and vector of possible cluster blocks
233+ * that are candidates to match the block name, go through
234+ * the vector of cluster blocks and return the id of the block
235+ * where the block name matches the provided name.
236+ *
237+ * Given a string pattern representing a block name and a vector of
238+ * poissble cluster blocks that are candidates to match to the block
239+ * name pattern, go through the vector of cluster blocks and return
240+ * the id of the block where the block name matches to the provided
241+ * input pattern.
242+ *
243+ */
244+
245+ /* *
246+ * @brief The intented use is to find the block id of a
247+ * hard block without knowing its name in the netlist. Instead
248+ * a pattern can be created that we know the block's name will
249+ * match to. Generally, we expect the pattern to be constructed
250+ * using the block's module name in the HDL design, since we can
251+ * expect the netlist name of the block to include the module
252+ * name within it.
253+ *
254+ * For example, suppose a RAM block was named in the netlist as
255+ * "top|alu|test_ram|out". The user instantiated the ram module
256+ * in the HDL design as "test_ram". So instead of going through
257+ * the netlist and finding the ram block's full name, this
258+ * function can be used by just providing the string pattern as
259+ * ".*test_ram.*". We know that the module name should be somewhere
260+ * within the string, so the pattern we provide says that the netlist
261+ * name of the block contains arbritary characters then the module
262+ * name and then some other arbritary characters after.
263+ * This pattern will then be used to match to the block in the
264+ * netlist. The matched cluster block id is returned, and if no
265+ * block matched to the input string then an invalid block id
266+ * is returned.
267+ *
268+ * The function
269+ * here additionally requires a vector of possible cluster blocks
270+ * that can match to the input pattern. This vector can be the
271+ * entire netlist or a subset. For example, if the intended use
272+ * is to find hard blocks, it is quite inefficient
273+ * to go through all the blocks to find a matching one. Instead, a
274+ * a filtered vector can be passed that is a subset of the entire
275+ * netlist and can only contain blocks of a certain logical block
276+ * type (blocks that can be placed on a specific hard block).
277+ * The idea here is that the filtered vector should be
278+ * considereably smaller that a vector of every block in the netlist
279+ * and this should help improve run time.
280+ *
281+ * This function runs in linear time (O(N)) as it goes over the
282+ * vector of 'cluster_block_candidates'. 'cluster_block_candidates'
283+ * could be the whole netlist or a subset as explained above.
284+ * Additionally, if there are multiple
285+ * blocks that match to the provided input pattern, then the
286+ * first block found is returned.
287+ *
288+ *
289+ * @param name_pattern A regex string pattern that can be used to match to
290+ * a clustered block name within the netlist.
291+ * @param cluster_block_candidates A vector of clustered block ids that
292+ * represent a subset of the clustered
293+ * netlist. The blocks in this vector
294+ * will be used to compare and match
295+ * to the input string pattern.
296+ * @return A cluster block id representing a unique cluster block that
297+ * matched to the input string pattern.
298+ *
299+ */
300+ ClusterBlockId find_block_by_name_fragment (const std::string& name_pattern, const std::vector<ClusterBlockId>& cluster_block_candidates) const ;
301+
231302 private: // Private Members
232303 /*
233304 * Netlist compression/optimization
0 commit comments