Skip to content

Commit

Permalink
Support bitstream setting for SOC clock (#1714)
Browse files Browse the repository at this point in the history
  • Loading branch information
chungshien-chai authored Oct 29, 2024
1 parent b2ad5a5 commit 52f827e
Show file tree
Hide file tree
Showing 12 changed files with 7,429 additions and 1,320 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ set(VERSION_MINOR 0)
# Add the spdlog directory to the include path
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/spdlog/include ${CMAKE_CURRENT_SOURCE_DIR}/third_party/exprtk ${CMAKE_CURRENT_SOURCE_DIR}/third_party/scope_guard)

set(VERSION_PATCH 434)
set(VERSION_PATCH 435)


option(
Expand Down
42 changes: 28 additions & 14 deletions src/Configuration/ModelConfig/ModelConfig_BITSTREAM_SETTING_XML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ namespace FOEDAG {

struct PIN_TABLE_INFO {
PIN_TABLE_INFO() {}
PIN_TABLE_INFO(uint32_t i) : fabric_clk_index(i) {}
PIN_TABLE_INFO(uint32_t i, bool s) : fabric_clk_index(i), is_soc(s) {}
uint32_t fabric_clk_index = 0;
bool is_soc = false;
uint32_t x = 0;
uint32_t y = 0;
std::string type = "";
Expand Down Expand Up @@ -61,7 +62,14 @@ void ModelConfig_BITSREAM_SETTINGS_XML::gen(
CFG_ASSERT(words[0] == "set_core_clk");
CFG_ASSERT(location_map.find(words[1]) == location_map.end());
uint32_t index = (uint32_t)(CFG_convert_string_to_u64(words[2]));
location_map[words[1]] = PIN_TABLE_INFO(index);
location_map[words[1]] = PIN_TABLE_INFO(index, false);
} else if (line.size() > 0 && line.find("set_soc_clk") == 0) {
std::vector<std::string> words = CFG_split_string(line, " ", 0, false);
CFG_ASSERT(words.size() == 3);
CFG_ASSERT(words[0] == "set_soc_clk");
CFG_ASSERT(location_map.find(words[1]) == location_map.end());
uint32_t index = (uint32_t)(CFG_convert_string_to_u64(words[2]));
location_map[words[1]] = PIN_TABLE_INFO(index, true);
}
}
design.close();
Expand All @@ -71,12 +79,16 @@ void ModelConfig_BITSREAM_SETTINGS_XML::gen(
while (std::getline(pin, line)) {
CFG_get_rid_trailing_whitespace(line);
std::vector<std::string> words = CFG_split_string(line, ",");
if (words.size() >= 11 && words[2].size() > 0) {
auto iter = location_map.find(words[2]);
if (iter != location_map.end()) {
iter->second.x = (uint32_t)(CFG_convert_string_to_u64(words[9]));
iter->second.y = (uint32_t)(CFG_convert_string_to_u64(words[10]));
}
std::map<std::string, PIN_TABLE_INFO>::iterator iter;
if (words.size() >= 14 &&
((words[2].size() > 0 &&
(iter = location_map.find(words[2])) != location_map.end() &&
!iter->second.is_soc) ||
(words[13].size() > 0 &&
(iter = location_map.find(words[13])) != location_map.end() &&
iter->second.is_soc))) {
iter->second.x = (uint32_t)(CFG_convert_string_to_u64(words[9]));
iter->second.y = (uint32_t)(CFG_convert_string_to_u64(words[10]));
}
}
pin.close();
Expand Down Expand Up @@ -117,9 +129,10 @@ void ModelConfig_BITSREAM_SETTINGS_XML::gen(
}
if (iter.second.type.size()) {
oxml << CFG_print(
" <!-- Location: %s, Value: %d, X: %d, Y: %d -->\n",
iter.first.c_str(), iter.second.fabric_clk_index,
iter.second.x, iter.second.y)
" <!-- Location: %s, SOC: %d, Value: %d, X: %d, Y: %d "
"-->\n",
iter.first.c_str(), iter.second.is_soc,
iter.second.fabric_clk_index, iter.second.x, iter.second.y)
.c_str();
for (int i = 0; i < 4; i++) {
oxml << CFG_print(
Expand All @@ -132,10 +145,11 @@ void ModelConfig_BITSREAM_SETTINGS_XML::gen(
}
} else {
oxml << CFG_print(
" <!-- Unknown location: %s, Value: %d, X: %d, Y: %d "
" <!-- Unknown location: %s, SOC: %d, Value: %d, X: %d, "
"Y: %d "
"-->\n",
iter.first.c_str(), iter.second.fabric_clk_index,
iter.second.x, iter.second.y)
iter.first.c_str(), iter.second.is_soc,
iter.second.fabric_clk_index, iter.second.x, iter.second.y)
.c_str();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ class ModelConfig_BITSTREAM_SETTING_XML : public ::testing::Test {
};

TEST_F(ModelConfig_BITSTREAM_SETTING_XML, gen_bitstream_setting_xml) {
// The device is 62x44
// The size is 64x46
// Make it 64x45 so that we cannot find some use case, and have negative
// coverage
std::string current_dir = COMPILER_TCL_COMMON_GET_CURRENT_DIR();
std::string cmd = CFG_print(
"model_config gen_bitstream_setting_xml -is_unittest -device_size 24x6 "
"model_config gen_bitstream_setting_xml -is_unittest -device_size 64x45 "
"-design %s/design_edit.sdc -pin %s/Pin_Table.csv "
"%s/empty_bitstream_setting.xml bitstream_setting.xml",
current_dir.c_str(), current_dir.c_str(), current_dir.c_str());
Expand Down
Loading

0 comments on commit 52f827e

Please sign in to comment.