Skip to content

Commit 5f1939c

Browse files
committed
[vpr][utils] move StringToken under vtr util
1 parent 9cf3775 commit 5f1939c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+347
-395
lines changed

libs/libarchfpga/src/arch_check.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ bool check_leaf_pb_model_timing_consistency(const t_pb_type* pb_type, const t_ar
168168

169169
//Annotations always put the pin in the input_pins field
170170
VTR_ASSERT(annotation.input_pins);
171-
for (const std::string& input_pin : vtr::split(annotation.input_pins)) {
171+
for (const std::string& input_pin : vtr::StringToken(annotation.input_pins).split(" \t\n")) {
172172
InstPort annot_port(input_pin);
173-
for (const std::string& clock : vtr::split(annotation.clock)) {
173+
for (const std::string& clock : vtr::StringToken(annotation.clock).split(" \t\n")) {
174174
InstPort annot_clock(clock);
175175

176176
//Find the model port
@@ -210,9 +210,9 @@ bool check_leaf_pb_model_timing_consistency(const t_pb_type* pb_type, const t_ar
210210
} else if (annotation.input_pins && annotation.output_pins) {
211211
//Combinational annotation
212212
VTR_ASSERT_MSG(!annotation.clock, "Combinational annotations should have no clock");
213-
for (const std::string& input_pin : vtr::split(annotation.input_pins)) {
213+
for (const std::string& input_pin : vtr::StringToken(annotation.input_pins).split(" \t\n")) {
214214
InstPort annot_in(input_pin);
215-
for (const std::string& output_pin : vtr::split(annotation.output_pins)) {
215+
for (const std::string& output_pin : vtr::StringToken(annotation.output_pins).split(" \t\n")) {
216216
InstPort annot_out(output_pin);
217217

218218
//Find the input model port

libs/libarchfpga/src/arch_util.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const char* get_arch_file_name() {
3939
}
4040

4141
InstPort::InstPort(const std::string& str) {
42-
std::vector<std::string> inst_port = vtr::split(str, ".");
42+
std::vector<std::string> inst_port = vtr::StringToken(str).split(".");
4343

4444
if (inst_port.size() == 1) {
4545
instance_ = name_index();
@@ -701,9 +701,8 @@ void ProcessMemoryClass(t_pb_type* mem_pb_type) {
701701

702702
mem_pb_type->modes[0].num_interconnect = mem_pb_type->num_ports * num_pb;
703703

704-
std::stringstream ss;
705-
ss << "Memory pb_type " << mem_pb_type->name << " has no interconnect";
706-
VTR_ASSERT_MSG(mem_pb_type->modes[0].num_interconnect > 0, ss.str().c_str());
704+
std::string error_msg = (std::stringstream() << "Memory pb_type " << mem_pb_type->name << " has no interconnect").str();
705+
VTR_ASSERT_MSG(mem_pb_type->modes[0].num_interconnect > 0, error_msg.c_str());
707706
mem_pb_type->modes[0].interconnect = new t_interconnect[mem_pb_type->modes[0].num_interconnect];
708707

709708
for (i = 0; i < mem_pb_type->modes[0].num_interconnect; i++) {
@@ -1052,9 +1051,9 @@ bool has_sequential_annotation(const t_pb_type* pb_type, const t_model_ports* po
10521051

10531052
bool has_combinational_annotation(const t_pb_type* pb_type, std::string_view in_port, std::string_view out_port) {
10541053
for (const t_pin_to_pin_annotation& annotation : pb_type->annotations) {
1055-
for (const auto& annot_in_str : vtr::split(annotation.input_pins)) {
1054+
for (const auto& annot_in_str : vtr::StringToken(annotation.input_pins).split(" \t\n")) {
10561055
InstPort in_pins(annot_in_str);
1057-
for (const auto& annot_out_str : vtr::split(annotation.output_pins)) {
1056+
for (const auto& annot_out_str : vtr::StringToken(annotation.output_pins).split(" \t\n")) {
10581057
InstPort out_pins(annot_out_str);
10591058
if (in_pins.port_name() == in_port && out_pins.port_name() == out_port) {
10601059
for (const auto& [key, val] : annotation.annotation_entries) {

libs/libarchfpga/src/parse_switchblocks.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ t_wire_switchpoints parse_wireconn_from_to_node(pugi::xml_node node, const pugiu
201201
wire_switchpoints.segment_name = get_attribute(node, "type", loc_data).value();
202202

203203
auto points_str = get_attribute(node, "switchpoint", loc_data).value();
204-
for (const auto& point_str : vtr::split(points_str, ",")) {
204+
for (const auto& point_str : vtr::StringToken(points_str).split(",")) {
205205
int switchpoint = vtr::atoi(point_str);
206206
wire_switchpoints.switchpoints.push_back(switchpoint);
207207
}
@@ -229,7 +229,7 @@ static void parse_switchpoint_order(const char* order, SwitchPointOrder& switchp
229229
/* parses the wire types specified in the comma-separated 'ch' char array into the vector wire_points_vec.
230230
* Spaces are trimmed off */
231231
static void parse_comma_separated_wire_types(const char* ch, std::vector<t_wire_switchpoints>& wire_switchpoints) {
232-
auto types = vtr::split(ch, ",");
232+
auto types = vtr::StringToken(ch).split(",");
233233

234234
if (types.empty()) {
235235
archfpga_throw(__FILE__, __LINE__, "parse_comma_separated_wire_types: found empty wireconn wire type entry\n");
@@ -245,7 +245,7 @@ static void parse_comma_separated_wire_types(const char* ch, std::vector<t_wire_
245245

246246
/* parses the wirepoints specified in the comma-separated 'ch' char array into the vector wire_points_vec */
247247
static void parse_comma_separated_wire_points(const char* ch, std::vector<t_wire_switchpoints>& wire_switchpoints) {
248-
auto points = vtr::split(ch, ",");
248+
auto points = vtr::StringToken(ch).split(",");
249249
if (points.empty()) {
250250
archfpga_throw(__FILE__, __LINE__, "parse_comma_separated_wire_points: found empty wireconn wire point entry\n");
251251
}

libs/libarchfpga/src/physical_types.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2374,19 +2374,20 @@ struct t_arch {
23742374
std::vector<t_lut_cell> lut_cells;
23752375
std::unordered_map<std::string, std::vector<t_lut_element>> lut_elements;
23762376

2377-
//The name of the switch used for the input connection block (i.e. to
2378-
//connect routing tracks to block pins). tracks can be connected to
2377+
// The name of the switch used for the input connection block (i.e. to
2378+
// connect routing tracks to block pins). tracks can be connected to
23792379
// ipins through the same die or from other dice, each of these
2380-
//types of connections requires a different switch, all names should correspond to a switch in Switches.
2380+
// types of connections requires a different switch, all names should correspond to a switch in Switches.
23812381
std::vector<std::string> ipin_cblock_switch_name;
23822382

23832383
std::vector<t_grid_def> grid_layouts; //Set of potential device layouts
23842384

2385-
//the layout that is chosen to be used with command line options
2386-
//It is used to generate custom SB for a specific locations within the device
2387-
//If the layout is not specified in the command line options, this variable will be set to "auto"
2385+
// the layout that is chosen to be used with command line options
2386+
// It is used to generate custom SB for a specific locations within the device
2387+
// If the layout is not specified in the command line options, this variable will be set to "auto"
23882388
std::string device_layout;
23892389

2390+
/// VIB grid layouts
23902391
std::vector<t_vib_grid_def> vib_grid_layouts;
23912392

23922393
t_clock_arch_spec clock_arch; // Clock related data types

libs/libarchfpga/src/read_fpga_interchange_arch.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,14 +1845,14 @@ struct ArchReader {
18451845
auto site_pins = site.getBelPins();
18461846

18471847
std::string endpoint = direction == BACKWARD ? ic->input_string : ic->output_string;
1848-
auto ic_endpoints = vtr::split(endpoint, " ");
1848+
auto ic_endpoints = vtr::StringToken(endpoint).split(" ");
18491849

18501850
std::unordered_map<t_interconnect*, std::set<std::string>> pps_map;
18511851

18521852
bool is_backward = direction == BACKWARD;
18531853

18541854
for (auto ep : ic_endpoints) {
1855-
auto parts = vtr::split(ep, ".");
1855+
auto parts = vtr::StringToken(ep).split(".");
18561856
auto bel = parts[0];
18571857
auto pin = parts[1];
18581858

@@ -1889,7 +1889,7 @@ struct ArchReader {
18891889
std::string ic_to_find = bel + "." + pin_name;
18901890

18911891
bool found = false;
1892-
for (auto out : vtr::split(is_backward ? other_ic->output_string : other_ic->input_string, " "))
1892+
for (auto out : vtr::StringToken(is_backward ? other_ic->output_string : other_ic->input_string).split(" "))
18931893
found |= out == ic_to_find;
18941894

18951895
if (found) {
@@ -1911,7 +1911,7 @@ struct ArchReader {
19111911
t_interconnect* other_ic = &mode->interconnect[iic];
19121912

19131913
bool found = false;
1914-
for (auto other_ep : vtr::split(is_backward ? other_ic->output_string : other_ic->input_string, " ")) {
1914+
for (auto other_ep : vtr::StringToken(is_backward ? other_ic->output_string : other_ic->input_string).split(" ")) {
19151915
found |= other_ep == ep;
19161916
}
19171917

libs/libarchfpga/src/read_xml_arch_file.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2531,7 +2531,7 @@ static void process_model_ports(pugi::xml_node port_group, t_model& model, std::
25312531
model_port->clock = std::string(attr.value());
25322532

25332533
} else if (attr.name() == std::string("combinational_sink_ports")) {
2534-
model_port->combinational_sink_ports = vtr::split(attr.value());
2534+
model_port->combinational_sink_ports = vtr::StringToken(attr.value()).split(" \t\n");
25352535

25362536
} else {
25372537
bad_attribute(attr, port, loc_data);
@@ -3579,7 +3579,7 @@ static void process_pin_locations(pugi::xml_node Locations,
35793579
seen_sides.insert(side_offset);
35803580

35813581
/* Go through lists of pins */
3582-
const std::vector<std::string> Tokens = vtr::split(Cur.child_value());
3582+
const std::vector<std::string> Tokens = vtr::StringToken(Cur.child_value()).split(" \t\n");
35833583
int Count = (int)Tokens.size();
35843584
if (Count > 0) {
35853585
for (int pin = 0; pin < Count; ++pin) {
@@ -5257,7 +5257,7 @@ static void process_first_stage(pugi::xml_node Stage_node, std::vector<t_physica
52575257
pugi::xml_node SubElem = get_first_child(Node, "from", loc_data);
52585258
int from_num = count_children(Node, "from", loc_data);
52595259
for (int i_from = 0; i_from < from_num; i_from++) {
5260-
std::vector<std::string> from_tokens = vtr::split(SubElem.child_value());
5260+
std::vector<std::string> from_tokens = vtr::StringToken(SubElem.child_value()).split(" \t\n");
52615261
first_stage_mux.from_tokens.push_back(from_tokens);
52625262
SubElem = SubElem.next_sibling(SubElem.name());
52635263
}
@@ -5281,14 +5281,14 @@ static void process_second_stage(pugi::xml_node Stage_node, std::vector<t_physic
52815281
pugi::xml_node SubElem = get_first_child(Node, "to", loc_data);
52825282
int to_num = count_children(Node, "to", loc_data);
52835283
VTR_ASSERT(to_num == 1);
5284-
std::vector<std::string> to_tokens = vtr::split(SubElem.child_value());
5284+
std::vector<std::string> to_tokens = vtr::StringToken(SubElem.child_value()).split(" \t\n");
52855285
VTR_ASSERT(to_tokens.size() == 1);
52865286
second_stage_mux.to_tokens = to_tokens;
52875287

52885288
SubElem = get_first_child(Node, "from", loc_data);
52895289
int from_num = count_children(Node, "from", loc_data);
52905290
for (int i_from = 0; i_from < from_num; i_from++) {
5291-
std::vector<std::string> from_tokens = vtr::split(SubElem.child_value());
5291+
std::vector<std::string> from_tokens = vtr::StringToken(SubElem.child_value()).split(" \t\n");
52925292
second_stage_mux.from_tokens.push_back(from_tokens);
52935293
SubElem = SubElem.next_sibling(SubElem.name());
52945294
}

libs/librrgraph/src/base/get_parallel_segs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
std::vector<t_segment_inf> get_parallel_segs(const std::vector<t_segment_inf>& segment_inf,
44
t_unified_to_parallel_seg_index& seg_index_map,
55
enum e_parallel_axis parallel_axis,
6-
bool keep_original_index) {
6+
bool keep_original_index /* = false */) {
77
std::vector<t_segment_inf> result;
88
for (size_t i = 0; i < segment_inf.size(); ++i) {
99
if (segment_inf[i].parallel_axis == parallel_axis || segment_inf[i].parallel_axis == BOTH_AXIS) {
1010
result.push_back(segment_inf[i]);
1111
if (!keep_original_index) {
12-
result[result.size() - 1].seg_index = i;
12+
result.back().seg_index = i;
1313
}
1414
seg_index_map.insert(std::make_pair(i, std::make_pair(result.size() - 1, parallel_axis)));
1515
}

libs/librrgraph/src/base/get_parallel_segs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @param seg_index_map Map from unified to axis-specific segment indices.
1515
* @param parallel_axis Axis to filter segments by.
1616
* @param keep_original_index Whether to keep the original index of the segment. Currently,
17-
* it is only set to true when building the tileable rr_graph.
17+
* it is only set to true when building the tileable rr_graph.
1818
* @return Filtered list of segments for the given axis.
1919
*/
2020
std::vector<t_segment_inf> get_parallel_segs(const std::vector<t_segment_inf>& segment_inf,

libs/librrgraph/src/base/rr_graph_builder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "vtr_log.h"
33
#include "rr_graph_builder.h"
44
#include "vtr_time.h"
5-
#include "vtr_tokenizer.h"
5+
#include "vtr_util.h"
66
#include <queue>
77
#include <random>
88

libs/librrgraph/src/base/rr_graph_view.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ std::vector<RREdgeId> RRGraphView::node_non_configurable_in_edges(RRNodeId node)
6262
return ret_edges;
6363
}
6464

65-
std::vector<RREdgeId> RRGraphView::find_edges(const RRNodeId& src_node, const RRNodeId& des_node) const {
65+
std::vector<RREdgeId> RRGraphView::find_edges(RRNodeId src_node, RRNodeId des_node) const {
6666
std::vector<RREdgeId> edge_list;
6767
for (auto iedge : node_out_edges(src_node)) {
6868
if (edge_sink_node(RREdgeId(iedge)) == des_node) {

0 commit comments

Comments
 (0)