Skip to content

Commit

Permalink
add rr_graph and router_lookahead support in vpr commandline
Browse files Browse the repository at this point in the history
  • Loading branch information
coolbreeze413 committed Nov 5, 2024
1 parent 6dac906 commit 363f85f
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 6 deletions.
15 changes: 15 additions & 0 deletions src/Compiler/CompilerOpenFPGA_ql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3144,6 +3144,21 @@ std::string CompilerOpenFPGA_ql::BaseVprCommand() {

QLDeviceTarget device_target = QLDeviceManager::getInstance()->getCurrentDeviceTarget();

// use rr_graph and router_lookahead files, if available in the device data:
std::filesystem::path rr_graph_file_path =
QLDeviceManager::getInstance()->deviceVPRRRGraphFile();

std::filesystem::path router_lookahead_file_path =
QLDeviceManager::getInstance()->deviceVPRRouterLookaheadFile();

if(!rr_graph_file_path.empty() && !router_lookahead_file_path.empty()) {
vpr_options += " --read_rr_graph " +
rr_graph_file_path.string() +
" --read_router_lookahead " +
router_lookahead_file_path.string();
}


m_architectureFile =
QLDeviceManager::getInstance()->deviceVPRArchitectureFile();
if(m_architectureFile.empty()) {
Expand Down
91 changes: 87 additions & 4 deletions src/Compiler/QLDeviceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1770,6 +1770,18 @@ int QLDeviceManager::encryptDevice(std::string family, std::string foundry, std:
source_device_data_file_list_to_copy.push_back(dir_entry.path().string());
}

// include rr_graph.bin and router_lookahead.bin files for copy
if (std::regex_match(dir_entry.path().filename().string(),
std::regex(".*rr_graph\\.bin",
std::regex::icase))) {
source_device_data_file_list_to_copy.push_back(dir_entry.path().string());
}
if (std::regex_match(dir_entry.path().filename().string(),
std::regex(".*router_lookahead\\.bin",
std::regex::icase))) {
source_device_data_file_list_to_copy.push_back(dir_entry.path().string());
}

// we want xml files for encryption
if (std::regex_match(dir_entry.path().filename().string(),
std::regex(".+\\.xml",
Expand All @@ -1785,6 +1797,13 @@ int QLDeviceManager::encryptDevice(std::string family, std::string foundry, std:
source_device_data_file_list_to_encrypt.push_back(dir_entry.path().string());
}

// we want capnp files for encryption (router_lookahead.capnp)
if (std::regex_match(dir_entry.path().filename().string(),
std::regex(".+\\.capnp",
std::regex::icase))) {
source_device_data_file_list_to_encrypt.push_back(dir_entry.path().string());
}

// include pin_table csv files for copy
if (std::regex_match(dir_entry.path().filename().string(),
std::regex(".*pin_table\\.csv",
Expand Down Expand Up @@ -3357,17 +3376,83 @@ std::filesystem::path QLDeviceManager::deviceOpenFPGAIOMapFile(QLDeviceTarget de

std::filesystem::path QLDeviceManager::deviceVPRRRGraphFile(QLDeviceTarget device_target) {

CompilerOpenFPGA_ql* compiler = static_cast<CompilerOpenFPGA_ql*>(GlobalSession->GetCompiler());

std::filesystem::path empty_path;
return empty_path;
std::filesystem::path vpr_rr_graph_file_path;

if( !isDeviceTargetValid(device_target) ) {
device_target = this->device_target;
}

// use the device specific rr_graph file, and note that we will have bin files (should we support xml?)

// use config.json if it exists
std::filesystem::path device_target_config_json_filepath = deviceTypeDirPath(device_target) / std::string("config.json");
if(FileUtils::FileExists(device_target_config_json_filepath)) {

std::ifstream device_target_config_json_ifstream(device_target_config_json_filepath.string());
json device_target_config_json = json::parse(device_target_config_json_ifstream);
// get json value
std::string json_value;
if( device_target_config_json.contains("CORNER_RRGRAPH_BIN") ) {

json_value = device_target_config_json["CORNER_RRGRAPH_BIN"].get<std::string>();
}
// check for unencrypted file
vpr_rr_graph_file_path =
deviceVariantDirPath(device_target) / json_value;
if(!FileUtils::FileExists(vpr_rr_graph_file_path)) {

compiler->Message("Cannot find device vpr rr_graph file: " + vpr_rr_graph_file_path.string());
vpr_rr_graph_file_path.clear();
}
}

// std::cout << "[zyxw]" << "using vpr rr_graph file: " << vpr_rr_graph_file_path.string() << std::endl;

return vpr_rr_graph_file_path;
}


std::filesystem::path QLDeviceManager::deviceVPRRouterLookaheadFile(QLDeviceTarget device_target) {

CompilerOpenFPGA_ql* compiler = static_cast<CompilerOpenFPGA_ql*>(GlobalSession->GetCompiler());

std::filesystem::path empty_path;
return empty_path;
std::filesystem::path vpr_router_lookahead_file_path;

if( !isDeviceTargetValid(device_target) ) {
device_target = this->device_target;
}

// use the device specific router_lookahead file, and note that we will have bin files (should we support xml?)

// use config.json if it exists
std::filesystem::path device_target_config_json_filepath = deviceTypeDirPath(device_target) / std::string("config.json");
if(FileUtils::FileExists(device_target_config_json_filepath)) {

std::ifstream device_target_config_json_ifstream(device_target_config_json_filepath.string());
json device_target_config_json = json::parse(device_target_config_json_ifstream);
// get json value
std::string json_value;
if( device_target_config_json.contains("CORNER_ROUTER_LOOKAHEAD_BIN") ) {

json_value = device_target_config_json["CORNER_ROUTER_LOOKAHEAD_BIN"].get<std::string>();
}

vpr_router_lookahead_file_path =
deviceVariantDirPath(device_target) / json_value;
if(!FileUtils::FileExists(vpr_router_lookahead_file_path)) {

compiler->Message("Cannot find device vpr router_lookahead file: " + vpr_router_lookahead_file_path.string());
vpr_router_lookahead_file_path.clear();
}
}

// std::cout << "[zyxw]" << "using vpr router_lookahead file: " << vpr_router_lookahead_file_path.string() << std::endl;

return vpr_router_lookahead_file_path;
}


Expand All @@ -3376,15 +3461,13 @@ std::vector<std::string> QLDeviceManager::deviceCorners(QLDeviceTarget device_ta

std::vector<std::string> corners;
return corners;

}


std::vector<std::filesystem::path> QLDeviceManager::deviceCornerPowerDataFiles(QLDeviceTarget device_target) {

std::vector<std::filesystem::path> corner_power_data_filepaths;
return corner_power_data_filepaths;

}

} // namespace FOEDAG
4 changes: 2 additions & 2 deletions src/Compiler/QLDeviceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ class QLDeviceManager : public QObject {
std::filesystem::path deviceOpenFPGAPinTableFile(QLDeviceTarget device_target = QLDeviceTarget());
std::filesystem::path deviceOpenFPGAIOMapFile(QLDeviceTarget device_target = QLDeviceTarget());

std::filesystem::path deviceVPRRRGraphFile(QLDeviceTarget device_target);
std::filesystem::path deviceVPRRouterLookaheadFile(QLDeviceTarget device_target);
std::filesystem::path deviceVPRRRGraphFile(QLDeviceTarget device_target = QLDeviceTarget());
std::filesystem::path deviceVPRRouterLookaheadFile(QLDeviceTarget device_target = QLDeviceTarget());

// future use (not file access APIs, but used together with them)
std::vector<std::string> deviceCorners(QLDeviceTarget device_target);
Expand Down

0 comments on commit 363f85f

Please sign in to comment.