Skip to content

Commit b433a8a

Browse files
committed
[vpr][route][crr] remove excel usages throught crr code
1 parent 58265c6 commit b433a8a

File tree

6 files changed

+28
-79
lines changed

6 files changed

+28
-79
lines changed

vpr/src/route/rr_graph_generation/tileable_rr_graph/crr_generator/crr_common.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
#include "rr_graph_fwd.h"
99
#include "rr_node_types.h"
1010
namespace crrgenerator {
11-
12-
// Constants
13-
// Number of empty rows and columns in the Excel file
11+
// Number of empty rows and columns in the switch template file
1412
constexpr int NUM_EMPTY_ROWS = 5;
1513
constexpr int NUM_EMPTY_COLS = 4;
1614

vpr/src/route/rr_graph_generation/tileable_rr_graph/crr_generator/crr_connection_builder.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ CRRConnectionBuilder::CRRConnectionBuilder(const RRGraphView& rr_graph,
3333
void CRRConnectionBuilder::initialize(
3434
int fpga_grid_x,
3535
int fpga_grid_y,
36-
bool is_annotated_excel) {
36+
bool is_annotated) {
3737

3838
fpga_grid_x_ = fpga_grid_x;
3939
fpga_grid_y_ = fpga_grid_y;
40-
is_annotated_excel_ = is_annotated_excel;
40+
is_annotated_ = is_annotated;
4141

4242
// Total locations is the number of locations on the FPGA grid minus the 4
4343
// corner locations.
@@ -495,7 +495,7 @@ int CRRConnectionBuilder::get_connection_delay_ps(const std::string& cell_value,
495495
lower_case_sink_node_type.end(),
496496
lower_case_sink_node_type.begin(), ::tolower);
497497

498-
if (is_integer(cell_value) && is_annotated_excel_) {
498+
if (is_integer(cell_value) && is_annotated_) {
499499
// TODO: This is a temporary solution. We need to have an API call to get
500500
// the switch id from delay.
501501
if (cell_value == "0") {

vpr/src/route/rr_graph_generation/tileable_rr_graph/crr_generator/crr_connection_builder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class CRRConnectionBuilder {
3232
*/
3333
void initialize(int fpga_grid_x,
3434
int fpga_grid_y,
35-
bool is_annotated_excel);
35+
bool is_annotated);
3636

3737
/**
3838
* @brief Get connections for a tile
@@ -77,7 +77,7 @@ class CRRConnectionBuilder {
7777
// Info from config
7878
int fpga_grid_x_;
7979
int fpga_grid_y_;
80-
bool is_annotated_excel_;
80+
bool is_annotated_;
8181

8282
// Dependencies
8383
const RRGraphView& rr_graph_;

vpr/src/route/rr_graph_generation/tileable_rr_graph/crr_generator/crr_switch_block_manager.cpp

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ SwitchBlockManager::SwitchBlockManager() = default;
1616

1717
void SwitchBlockManager::initialize(const std::string& sb_maps_file,
1818
const std::string& sb_annotated_dir,
19-
const bool is_annotated_excel) {
19+
const bool is_annotated) {
2020
VTR_LOG("Initializing SwitchBlockManager with maps file: %s\n", sb_maps_file.c_str());
2121

2222
annotated_dir_ = sb_annotated_dir;
@@ -38,13 +38,13 @@ void SwitchBlockManager::initialize(const std::string& sb_maps_file,
3838
for (const auto& item : sb_maps) {
3939
std::string pattern = item.first.as<std::string>();
4040

41-
std::string excel_file = item.second.as<std::string>();
41+
std::string sw_template_file = item.second.as<std::string>();
4242
if (item.second.IsNull()) {
43-
excel_file = "";
43+
sw_template_file = "";
4444
}
4545

46-
std::string full_path = std::filesystem::path(annotated_dir_) / excel_file;
47-
if (excel_file.empty()) {
46+
std::string full_path = std::filesystem::path(annotated_dir_) / sw_template_file;
47+
if (sw_template_file.empty()) {
4848
full_path = "";
4949
}
5050

@@ -62,7 +62,7 @@ void SwitchBlockManager::initialize(const std::string& sb_maps_file,
6262
for (const auto& full_path : unique_files) {
6363
if (std::filesystem::exists(full_path)) {
6464
try {
65-
VTR_LOG_DEBUG("Attempting to read Excel file: %s\n", full_path.c_str());
65+
VTR_LOG_DEBUG("Attempting to read switch template file: %s\n", full_path.c_str());
6666
DataFrame df = processor_.read_csv(full_path);
6767
df = processor_.process_dataframe(std::move(df), NUM_EMPTY_ROWS,
6868
NUM_EMPTY_COLS);
@@ -71,10 +71,10 @@ void SwitchBlockManager::initialize(const std::string& sb_maps_file,
7171
file_cache_[full_path].connections,
7272
std::filesystem::path(full_path).filename().string().c_str());
7373
} catch (const std::exception& e) {
74-
VTR_LOG_ERROR("Failed to read required Excel file '%s': %s\n", full_path.c_str(), e.what());
74+
VTR_LOG_ERROR("Failed to read required switch template file '%s': %s\n", full_path.c_str(), e.what());
7575
}
7676
} else {
77-
VTR_LOG_ERROR("Required Excel file not found: %s\n", full_path.c_str());
77+
VTR_LOG_ERROR("Required switch template file not found: %s\n", full_path.c_str());
7878
}
7979
}
8080

@@ -85,8 +85,6 @@ void SwitchBlockManager::initialize(const std::string& sb_maps_file,
8585
}
8686
}
8787

88-
update_and_set_global_switch_delays(is_annotated_excel);
89-
9088
print_statistics();
9189
} catch (const YAML::Exception& e) {
9290
VTR_LOG_ERROR("Failed to parse YAML file %s: %s\n", sb_maps_file.c_str(), e.what());
@@ -135,31 +133,11 @@ std::string SwitchBlockManager::find_matching_pattern(const std::string& sw_name
135133
return "";
136134
}
137135

138-
void SwitchBlockManager::update_and_set_global_switch_delays(const bool is_annotated_excel) {
139-
if (is_annotated_excel) {
140-
int switch_delay_max_ps = std::numeric_limits<int>::min();
141-
int switch_delay_min_ps = std::numeric_limits<int>::max();
142-
for (const auto& [pattern, df] : dataframes_) {
143-
processor_.update_switch_delays(*df, switch_delay_max_ps,
144-
switch_delay_min_ps);
145-
}
146-
147-
switch_delay_max_ps_ = switch_delay_max_ps;
148-
switch_delay_min_ps_ = switch_delay_min_ps;
149-
} else {
150-
switch_delay_max_ps_ = 1000;
151-
switch_delay_min_ps_ = 1;
152-
}
153-
154-
VTR_LOG("Global switch delay range updated: %d - %d\n", switch_delay_min_ps_, switch_delay_max_ps_);
155-
}
156-
157136
void SwitchBlockManager::print_statistics() const {
158137
VTR_LOG("=== CRR Generator Switch Block Manager Statistics ===\n");
159138
VTR_LOG("Patterns loaded: %zu\n", dataframes_.size());
160-
VTR_LOG("Unique Excel files: %zu\n", file_cache_.size());
139+
VTR_LOG("Unique switch template files: %zu\n", file_cache_.size());
161140
VTR_LOG("Total connections: %zu\n", get_total_connections());
162-
VTR_LOG("Switch delay range: %d - %d\n", switch_delay_min_ps_, switch_delay_max_ps_);
163141

164142
// Print file details
165143
for (const auto& [file, df] : file_cache_) {

vpr/src/route/rr_graph_generation/tileable_rr_graph/crr_generator/crr_switch_block_manager.h

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
namespace crrgenerator {
1111

1212
/**
13-
* @brief Manages switch block configurations and Excel file processing
13+
* @brief Manages switch block configurations and switch template file processing
1414
*
15-
* This class handles reading YAML configuration files, processing Excel files
15+
* This class handles reading YAML configuration files, processing switch template files
1616
* containing switch block data, and managing switch block patterns.
1717
*/
1818
class SwitchBlockManager {
@@ -22,12 +22,12 @@ class SwitchBlockManager {
2222
/**
2323
* @brief Initialize the manager with configuration file
2424
* @param sb_maps_file Path to the YAML configuration file
25-
* @param sb_annotated_dir Directory containing Excel files
26-
* @param is_annotated_excel Whether the switches are annotated in Excel
25+
* @param sb_annotated_dir Directory containing switch template files
26+
* @param is_annotated Whether the switches are annotated in switch template files
2727
*/
2828
void initialize(const std::string& sb_maps_file,
2929
const std::string& sb_annotated_dir,
30-
const bool is_annotated_excel);
30+
const bool is_annotated);
3131

3232
/**
3333
* @brief Get the switch template file name for a given pattern
@@ -73,18 +73,6 @@ class SwitchBlockManager {
7373
*/
7474
size_t get_total_connections() const;
7575

76-
/**
77-
* @brief Get the maximum switch delay in picoseconds
78-
* @return Maximum switch delay in picoseconds
79-
*/
80-
int get_max_switch_delay_ps() const { return switch_delay_max_ps_; }
81-
82-
/**
83-
* @brief Get the minimum switch delay in picoseconds
84-
* @return Minimum switch delay in picoseconds
85-
*/
86-
int get_min_switch_delay_ps() const { return switch_delay_min_ps_; }
87-
8876
private:
8977
/**
9078
* @brief Ordered list of switch block patterns
@@ -98,26 +86,11 @@ class SwitchBlockManager {
9886
std::unordered_map<std::string, DataFrame*> dataframes_;
9987
std::unordered_map<std::string, DataFrame> file_cache_;
10088

101-
// Global switch delay range
102-
int switch_delay_max_ps_;
103-
int switch_delay_min_ps_;
104-
10589
DataFrameProcessor processor_;
10690
std::string annotated_dir_;
10791

108-
// File processing
109-
void load_excel_file(const std::string& pattern,
110-
const std::string& excel_file);
111-
112-
/**
113-
* @brief Update global switch delay ranges based on all loaded DataFrames
114-
* @param is_annotated_excel Whether the switches are annotated in Excel
115-
*/
116-
void update_and_set_global_switch_delays(const bool is_annotated_excel);
117-
11892
// Validation
11993
void validate_yaml_structure(const YAML::Node& root);
120-
void validate_excel_files();
12194
};
12295

12396
} // namespace crrgenerator

vpr/src/route/rr_graph_generation/tileable_rr_graph/crr_generator/data_frame_processor.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ struct Cell {
4545
};
4646

4747
/**
48-
* @brief Simple dataframe implementation for processing Excel data
48+
* @brief Simple dataframe implementation for processing switch template data
4949
*
50-
* This class provides pandas-like functionality for processing Excel files
50+
* This class provides pandas-like functionality for processing switch template files
5151
* containing switch block configuration data.
5252
*/
5353
class DataFrame {
@@ -150,19 +150,19 @@ class DataFrame {
150150
};
151151

152152
/**
153-
* @brief Processes Excel files and converts them to DataFrames
153+
* @brief Processes switch template files and converts them to DataFrames
154154
*
155-
* This class handles reading Excel files and performing the cell merging
155+
* This class handles reading switch template files and performing the cell merging
156156
* operations similar to the Python pandas functionality.
157157
*/
158158
class DataFrameProcessor {
159159
public:
160160
DataFrameProcessor() = default;
161161

162162
/**
163-
* @brief Read Excel file and create DataFrame
164-
* @param filename Path to Excel file
165-
* @return DataFrame containing the Excel data
163+
* @brief Read switch template file and create DataFrame
164+
* @param filename Path to switch template file
165+
* @return DataFrame containing the switch template data
166166
* @throws FileException if file cannot be read
167167
*/
168168
DataFrame read_csv(const std::string& filename);
@@ -187,7 +187,7 @@ class DataFrameProcessor {
187187
void update_switch_delays(const DataFrame& df, int& switch_delay_max_ps, int& switch_delay_min_ps);
188188

189189
private:
190-
// Excel parsing helpers
190+
// switch template parsing helpers
191191
Cell parse_csv_cell(const std::string& value);
192192
size_t count_csv_columns(const std::string& line);
193193
std::vector<std::string> parse_csv_line(const std::string& line);

0 commit comments

Comments
 (0)