Skip to content

Commit e45b456

Browse files
committed
Merge branch 'temp_tokens_' of https://github.com/verilog-to-routing/vtr-verilog-to-routing into subtile_pin_loc
2 parents 5a2a886 + ad8986f commit e45b456

File tree

5 files changed

+264
-350
lines changed

5 files changed

+264
-350
lines changed

libs/libarchfpga/src/read_xml_arch_file.cpp

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ static void load_pin_loc(pugi::xml_node Locations,
704704
for (int width = 0; width < type->width; ++width) {
705705
for (int height = 0; height < type->height; ++height) {
706706
for (e_side side : TOTAL_2D_SIDES) {
707-
for (auto token : pin_locs->assignments[sub_tile_index][width][height][layer][side]) {
707+
for (const std::string& token : pin_locs->assignments[sub_tile_index][width][height][layer][side]) {
708708
auto pin_range = process_pin_string<t_sub_tile*>(Locations,
709709
&sub_tile,
710710
token.c_str(),
@@ -763,39 +763,35 @@ static std::pair<int, int> process_instance_string(pugi::xml_node Locations,
763763
t_sub_tile& sub_tile,
764764
const char* pin_loc_string,
765765
const pugiutil::loc_data& loc_data) {
766-
int num_tokens;
767-
t_token* tokens = get_tokens_from_string(pin_loc_string, &num_tokens);
766+
Tokens tokens(pin_loc_string);
768767

769768
int token_index = 0;
770769
t_token token = tokens[token_index];
771770

772-
if (token.type != TOKEN_STRING || std::string(token.data) != sub_tile.name) {
771+
if (token.type != e_token_type::STRING || std::string(token.data) != sub_tile.name) {
773772
archfpga_throw(loc_data.filename_c_str(), loc_data.line(Locations),
774773
vtr::string_fmt("Wrong physical type name of the port: %s\n", pin_loc_string).c_str());
775774
}
776775

777776
token_index++;
778-
token = tokens[token_index];
779777

780778
int first_inst = 0;
781779
int last_inst = sub_tile.capacity.total() - 1;
782780

783781
// If there is a dot, such as io.input[0:3], it indicates the full range of the capacity, the default value should be returned
784-
if (token.type == TOKEN_DOT) {
785-
free_tokens(tokens, num_tokens);
782+
if (token.type == e_token_type::DOT) {
786783
return std::make_pair(first_inst, last_inst);
787784
}
788785

789786
// If the string contains index for capacity range, e.g., io[3:3].in[0:5], we skip the capacity range here.
790-
if (token.type != TOKEN_OPEN_SQUARE_BRACKET) {
787+
if (token.type != e_token_type::OPEN_SQUARE_BRACKET) {
791788
archfpga_throw(loc_data.filename_c_str(), loc_data.line(Locations),
792789
vtr::string_fmt("No open square bracket present: %s\n", pin_loc_string).c_str());
793790
}
794791

795792
token_index++;
796-
token = tokens[token_index];
797793

798-
if (token.type != TOKEN_INT) {
794+
if (tokens[token_index].type != e_token_type::INT) {
799795
archfpga_throw(loc_data.filename_c_str(), loc_data.line(Locations),
800796
vtr::string_fmt("No integer to indicate least significant instance index: %s\n", pin_loc_string).c_str());
801797
}
@@ -806,27 +802,26 @@ static std::pair<int, int> process_instance_string(pugi::xml_node Locations,
806802
token = tokens[token_index];
807803

808804
// Single pin is specified
809-
if (token.type != TOKEN_COLON) {
810-
if (token.type != TOKEN_CLOSE_SQUARE_BRACKET) {
805+
if (token.type != e_token_type::COLON) {
806+
if (token.type != e_token_type::CLOSE_SQUARE_BRACKET) {
811807
archfpga_throw(loc_data.filename_c_str(), loc_data.line(Locations),
812808
vtr::string_fmt("No closing bracket: %s\n", pin_loc_string).c_str());
813809
}
814810

815811
token_index++;
816812

817-
if (token_index != num_tokens) {
813+
if (token_index != tokens.size()) {
818814
archfpga_throw(loc_data.filename_c_str(), loc_data.line(Locations),
819815
vtr::string_fmt("instance of pin location should be completed, but more tokens are present: %s\n", pin_loc_string).c_str());
820816
}
821817

822-
free_tokens(tokens, num_tokens);
823818
return std::make_pair(first_inst, first_inst);
824819
}
825820

826821
token_index++;
827822
token = tokens[token_index];
828823

829-
if (token.type != TOKEN_INT) {
824+
if (token.type != e_token_type::INT) {
830825
archfpga_throw(loc_data.filename_c_str(), loc_data.line(Locations),
831826
vtr::string_fmt("No integer to indicate most significant instance index: %s\n", pin_loc_string).c_str());
832827
}
@@ -836,7 +831,7 @@ static std::pair<int, int> process_instance_string(pugi::xml_node Locations,
836831
token_index++;
837832
token = tokens[token_index];
838833

839-
if (token.type != TOKEN_CLOSE_SQUARE_BRACKET) {
834+
if (token.type != e_token_type::CLOSE_SQUARE_BRACKET) {
840835
archfpga_throw(loc_data.filename_c_str(), loc_data.line(Locations),
841836
vtr::string_fmt("No closed square bracket: %s\n", pin_loc_string).c_str());
842837
}
@@ -845,7 +840,6 @@ static std::pair<int, int> process_instance_string(pugi::xml_node Locations,
845840
std::swap(first_inst, last_inst);
846841
}
847842

848-
free_tokens(tokens, num_tokens);
849843
return std::make_pair(first_inst, last_inst);
850844
}
851845

@@ -854,13 +848,11 @@ static std::pair<int, int> process_pin_string(pugi::xml_node Locations,
854848
T type,
855849
const char* pin_loc_string,
856850
const pugiutil::loc_data& loc_data) {
857-
int num_tokens;
858-
t_token* tokens = get_tokens_from_string(pin_loc_string, &num_tokens);
851+
Tokens tokens(pin_loc_string);
859852

860-
int token_index = 0;
861-
auto token = tokens[token_index];
853+
size_t token_index = 0;
862854

863-
if (token.type != TOKEN_STRING || token.data != type->name) {
855+
if (tokens[token_index].type != e_token_type::STRING || tokens[token_index].data != type->name) {
864856
archfpga_throw(loc_data.filename_c_str(), loc_data.line(Locations),
865857
vtr::string_fmt("Wrong physical type name of the port: %s\n", pin_loc_string).c_str());
866858
}
@@ -928,50 +920,46 @@ static std::pair<int, int> process_pin_string(pugi::xml_node Locations,
928920
vtr::string_fmt("No integer to indicate least significant pin index: %s\n", pin_loc_string).c_str());
929921
}
930922

931-
int first_pin = vtr::atoi(token.data);
923+
int first_pin = vtr::atoi(tokens[token_index].data);
932924

933925
token_index++;
934-
token = tokens[token_index];
935926

936927
// Single pin is specified
937-
if (token.type != TOKEN_COLON) {
938-
if (token.type != TOKEN_CLOSE_SQUARE_BRACKET) {
928+
if (tokens[token_index].type != e_token_type::COLON) {
929+
if (tokens[token_index].type != e_token_type::CLOSE_SQUARE_BRACKET) {
939930
archfpga_throw(loc_data.filename_c_str(), loc_data.line(Locations),
940931
vtr::string_fmt("No closing bracket: %s\n", pin_loc_string).c_str());
941932
}
942933

943934
token_index++;
944935

945-
if (token_index != num_tokens) {
936+
if (token_index != tokens.size()) {
946937
archfpga_throw(loc_data.filename_c_str(), loc_data.line(Locations),
947938
vtr::string_fmt("pin location should be completed, but more tokens are present: %s\n", pin_loc_string).c_str());
948939
}
949940

950-
free_tokens(tokens, num_tokens);
951941
return std::make_pair(abs_first_pin_idx + first_pin, abs_first_pin_idx + first_pin + 1);
952942
}
953943

954944
token_index++;
955-
token = tokens[token_index];
956945

957-
if (token.type != TOKEN_INT) {
946+
if (tokens[token_index].type != e_token_type::INT) {
958947
archfpga_throw(loc_data.filename_c_str(), loc_data.line(Locations),
959948
vtr::string_fmt("No integer to indicate most significant pin index: %s\n", pin_loc_string).c_str());
960949
}
961950

962-
int last_pin = vtr::atoi(token.data);
951+
int last_pin = vtr::atoi(tokens[token_index].data);
963952

964953
token_index++;
965-
token = tokens[token_index];
966954

967-
if (token.type != TOKEN_CLOSE_SQUARE_BRACKET) {
955+
if (tokens[token_index].type != e_token_type::CLOSE_SQUARE_BRACKET) {
968956
archfpga_throw(loc_data.filename_c_str(), loc_data.line(Locations),
969957
vtr::string_fmt("No closed square bracket: %s\n", pin_loc_string).c_str());
970958
}
971959

972960
token_index++;
973961

974-
if (token_index != num_tokens) {
962+
if (token_index != tokens.size()) {
975963
archfpga_throw(loc_data.filename_c_str(), loc_data.line(Locations),
976964
vtr::string_fmt("pin location should be completed, but more tokens are present: %s\n", pin_loc_string).c_str());
977965
}
@@ -980,7 +968,6 @@ static std::pair<int, int> process_pin_string(pugi::xml_node Locations,
980968
std::swap(first_pin, last_pin);
981969
}
982970

983-
free_tokens(tokens, num_tokens);
984971
return std::make_pair(abs_first_pin_idx + first_pin, abs_first_pin_idx + last_pin + 1);
985972
}
986973

0 commit comments

Comments
 (0)