Skip to content

Commit 52f827e

Browse files
Support bitstream setting for SOC clock (#1714)
1 parent b2ad5a5 commit 52f827e

12 files changed

+7429
-1320
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ set(VERSION_MINOR 0)
3939
# Add the spdlog directory to the include path
4040
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)
4141

42-
set(VERSION_PATCH 434)
42+
set(VERSION_PATCH 435)
4343

4444

4545
option(

src/Configuration/ModelConfig/ModelConfig_BITSTREAM_SETTING_XML.cpp

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ namespace FOEDAG {
2828

2929
struct PIN_TABLE_INFO {
3030
PIN_TABLE_INFO() {}
31-
PIN_TABLE_INFO(uint32_t i) : fabric_clk_index(i) {}
31+
PIN_TABLE_INFO(uint32_t i, bool s) : fabric_clk_index(i), is_soc(s) {}
3232
uint32_t fabric_clk_index = 0;
33+
bool is_soc = false;
3334
uint32_t x = 0;
3435
uint32_t y = 0;
3536
std::string type = "";
@@ -61,7 +62,14 @@ void ModelConfig_BITSREAM_SETTINGS_XML::gen(
6162
CFG_ASSERT(words[0] == "set_core_clk");
6263
CFG_ASSERT(location_map.find(words[1]) == location_map.end());
6364
uint32_t index = (uint32_t)(CFG_convert_string_to_u64(words[2]));
64-
location_map[words[1]] = PIN_TABLE_INFO(index);
65+
location_map[words[1]] = PIN_TABLE_INFO(index, false);
66+
} else if (line.size() > 0 && line.find("set_soc_clk") == 0) {
67+
std::vector<std::string> words = CFG_split_string(line, " ", 0, false);
68+
CFG_ASSERT(words.size() == 3);
69+
CFG_ASSERT(words[0] == "set_soc_clk");
70+
CFG_ASSERT(location_map.find(words[1]) == location_map.end());
71+
uint32_t index = (uint32_t)(CFG_convert_string_to_u64(words[2]));
72+
location_map[words[1]] = PIN_TABLE_INFO(index, true);
6573
}
6674
}
6775
design.close();
@@ -71,12 +79,16 @@ void ModelConfig_BITSREAM_SETTINGS_XML::gen(
7179
while (std::getline(pin, line)) {
7280
CFG_get_rid_trailing_whitespace(line);
7381
std::vector<std::string> words = CFG_split_string(line, ",");
74-
if (words.size() >= 11 && words[2].size() > 0) {
75-
auto iter = location_map.find(words[2]);
76-
if (iter != location_map.end()) {
77-
iter->second.x = (uint32_t)(CFG_convert_string_to_u64(words[9]));
78-
iter->second.y = (uint32_t)(CFG_convert_string_to_u64(words[10]));
79-
}
82+
std::map<std::string, PIN_TABLE_INFO>::iterator iter;
83+
if (words.size() >= 14 &&
84+
((words[2].size() > 0 &&
85+
(iter = location_map.find(words[2])) != location_map.end() &&
86+
!iter->second.is_soc) ||
87+
(words[13].size() > 0 &&
88+
(iter = location_map.find(words[13])) != location_map.end() &&
89+
iter->second.is_soc))) {
90+
iter->second.x = (uint32_t)(CFG_convert_string_to_u64(words[9]));
91+
iter->second.y = (uint32_t)(CFG_convert_string_to_u64(words[10]));
8092
}
8193
}
8294
pin.close();
@@ -117,9 +129,10 @@ void ModelConfig_BITSREAM_SETTINGS_XML::gen(
117129
}
118130
if (iter.second.type.size()) {
119131
oxml << CFG_print(
120-
" <!-- Location: %s, Value: %d, X: %d, Y: %d -->\n",
121-
iter.first.c_str(), iter.second.fabric_clk_index,
122-
iter.second.x, iter.second.y)
132+
" <!-- Location: %s, SOC: %d, Value: %d, X: %d, Y: %d "
133+
"-->\n",
134+
iter.first.c_str(), iter.second.is_soc,
135+
iter.second.fabric_clk_index, iter.second.x, iter.second.y)
123136
.c_str();
124137
for (int i = 0; i < 4; i++) {
125138
oxml << CFG_print(
@@ -132,10 +145,11 @@ void ModelConfig_BITSREAM_SETTINGS_XML::gen(
132145
}
133146
} else {
134147
oxml << CFG_print(
135-
" <!-- Unknown location: %s, Value: %d, X: %d, Y: %d "
148+
" <!-- Unknown location: %s, SOC: %d, Value: %d, X: %d, "
149+
"Y: %d "
136150
"-->\n",
137-
iter.first.c_str(), iter.second.fabric_clk_index,
138-
iter.second.x, iter.second.y)
151+
iter.first.c_str(), iter.second.is_soc,
152+
iter.second.fabric_clk_index, iter.second.x, iter.second.y)
139153
.c_str();
140154
}
141155
}

tests/unittest/ModelConfig/ModelConfig_BITSTREAM_SETTING_XML_test.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ class ModelConfig_BITSTREAM_SETTING_XML : public ::testing::Test {
3333
};
3434

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

0 commit comments

Comments
 (0)