Skip to content

Commit

Permalink
Support new core clock flow (#1673)
Browse files Browse the repository at this point in the history
* Support new core clock flow

* Incremented patch version

* Support directional

---------

Co-authored-by: chungshien-chai <chungshien-chai@users.noreply.github.com>
  • Loading branch information
chungshien-chai and chungshien-chai authored Aug 19, 2024
1 parent 05eb41d commit d35f0f0
Show file tree
Hide file tree
Showing 26 changed files with 2,315 additions and 1,100 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 415)
set(VERSION_PATCH 416)


option(
Expand Down
7 changes: 6 additions & 1 deletion src/Configuration/ModelConfig/ModelConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ class ModelConfig_DEVICE {
CFG_ASSERT(attributes.is_object());
CFG_ASSERT(attributes.size());
std::map<std::string, std::string> object;
if (attributes.contains("__comment__")) {
attributes.erase("__comment__");
CFG_ASSERT(attributes.size());
}
for (auto& str :
std::vector<std::string>({"__location__", "__optional__"})) {
if (attributes.contains(str)) {
Expand Down Expand Up @@ -628,7 +632,8 @@ class ModelConfig_DEVICE {
mapped_block_name = CFG_replace_string(
mapped_block_name, CFG_print("__{[%d]}__", i), block_names[i]);
}
CFG_ASSERT(is_valid_block(mapped_block_name) || optional);
CFG_ASSERT_MSG(is_valid_block(mapped_block_name) || optional,
"%s is invalid block name", mapped_block_name.c_str());
if (is_valid_block(mapped_block_name)) {
optional = false;
}
Expand Down
424 changes: 347 additions & 77 deletions src/Configuration/ModelConfig/ModelConfig_IO.cpp

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion src/Configuration/ModelConfig/ModelConfig_IO.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class ModelConfig_IO {
void python_file(bool is_unittest);
void read_resources();
void validate_instances(nlohmann::json& instances);
void validate_instance(nlohmann::json& instance, bool is_final = false);
void validate_instance(const nlohmann::json& instance, bool is_final = false);
void merge_property_instances(nlohmann::json property_instances);
void merge_property_instance(nlohmann::json& netlist_instance,
nlohmann::json property_instances);
Expand All @@ -107,6 +107,8 @@ class ModelConfig_IO {
const std::string& port);
void allocate_pll_fclk_routing(nlohmann::json& instance,
const std::string& port);
void allocate_root_bank_clkmux();
void allocate_root_bank_clkmux(nlohmann::json& instance, bool is_pll);
void set_clkbuf_config_attributes();
void set_clkbuf_config_attribute(nlohmann::json& instance);
void allocate_pll();
Expand Down Expand Up @@ -180,6 +182,9 @@ class ModelConfig_IO {
const std::string& gearbox_location);
PIN_INFO get_pin_info(const std::string& name);
uint32_t fclk_use_pll_resource(const std::string& name);
nlohmann::json get_combined_results(nlohmann::json& rules,
std::string targeted_result,
const std::string& instance_key);
/*
Functions to check sibling rules
*/
Expand Down Expand Up @@ -224,6 +229,7 @@ class ModelConfig_IO {
std::map<std::string, std::string> m_global_args;
ModelConfig_IO_RESOURCE* m_resource = nullptr;
std::vector<ModelConfig_IO_MSG*> m_messages;
const nlohmann::json* m_current_instance = nullptr;
};

} // namespace FOEDAG
Expand Down
24 changes: 24 additions & 0 deletions src/Configuration/ModelConfig/ModelConfig_IO_resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,28 @@ bool ModelConfig_IO_RESOURCE::use_resource(const std::string& resource,
CFG_string_toupper(r));
}

/*
Entry function to try to use the resource
*/
std::pair<bool, std::string> ModelConfig_IO_RESOURCE::use_root_bank_clkmux(
const std::string& module, const std::string& location,
PIN_INFO& pin_info) {
std::pair<bool, std::string> status;
if (m_root_bank_clkmuxes.find(pin_info.root_bank_mux_location) !=
m_root_bank_clkmuxes.end()) {
status = std::make_pair(
false,
CFG_print(
"%s is already used by %s", pin_info.root_bank_mux_location.c_str(),
m_root_bank_clkmuxes.at(pin_info.root_bank_mux_location).c_str()));
} else {
m_root_bank_clkmuxes[pin_info.root_bank_mux_location] =
CFG_print("module %s (location: %s)", module.c_str(), location.c_str());
status = std::make_pair(true, pin_info.root_bank_mux_location);
}
return status;
}

/*
Fail-safe mechanism
*/
Expand All @@ -193,6 +215,7 @@ void ModelConfig_IO_RESOURCE::backup() {
item->backup();
}
}
m_backup_root_bank_clkmuxes = m_root_bank_clkmuxes;
}

/*
Expand All @@ -204,6 +227,7 @@ void ModelConfig_IO_RESOURCE::restore() {
item->restore();
}
}
m_root_bank_clkmuxes = m_backup_root_bank_clkmuxes;
}

} // namespace FOEDAG
21 changes: 19 additions & 2 deletions src/Configuration/ModelConfig/ModelConfig_IO_resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,31 @@ namespace FOEDAG {

struct PIN_INFO {
PIN_INFO(const std::string& in0, uint32_t in1, bool in2, uint32_t in3,
uint32_t in4, uint32_t in5)
uint32_t in4, uint32_t in5, const std::string& in6,
const std::string& in7, uint32_t in8, uint32_t in9)
: type(in0),
bank(in1),
is_clock(in2),
index(in3),
pair_index(in4),
ab_io(in5) {}
ab_io(in5),
ab_name(in6),
root_bank_mux_location(in7),
root_bank_mux_core_input_index(in8),
root_mux_input_index(in9) {
CFG_ASSERT((type == "BOOT_CLOCK" && ab_name.size() == 0) ||
ab_name.size() == 1);
}
const std::string type = "";
const uint32_t bank = 0;
const bool is_clock = false;
const uint32_t index = 0;
const uint32_t pair_index = 0;
const uint32_t ab_io = 0;
const std::string ab_name = "";
const std::string root_bank_mux_location = "";
const uint32_t root_bank_mux_core_input_index = 0;
const uint32_t root_mux_input_index = 0;
};

struct ModelConfig_IO_MODEL {
Expand Down Expand Up @@ -81,10 +93,15 @@ struct ModelConfig_IO_RESOURCE {
const std::string& type);
bool use_resource(const std::string& resource,
const std::string& instantiator, const std::string& name);
std::pair<bool, std::string> use_root_bank_clkmux(const std::string& module,
const std::string& location,
PIN_INFO& pin_info);
// Fail-safe mechanism
void backup();
void restore();
std::map<std::string, std::vector<const ModelConfig_IO_MODEL*>*> m_resources;
std::map<std::string, std::string> m_root_bank_clkmuxes;
std::map<std::string, std::string> m_backup_root_bank_clkmuxes;
std::string m_msg = "";
};

Expand Down
27 changes: 12 additions & 15 deletions tests/unittest/ModelConfig/apis/config_attributes.mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,11 @@
"pll_PLLEN" : "__pll_enable__"
}
},
"PLL.ROOT_MUX0" : {
"PLL.MUX0" : {
"rules" : {
"__connectivity__" : "CLK_OUT",
"__index__" : "__argIndex{default:0}__",
"OUT0_ROUTE_TO_FABRIC_CLK" : "__arg0__"
},
"results" : {
"__define__" : "parse_pll_root_mux",
"__location__" : "u_GBOX_HP_40X2.u_gbox_clkmux_52x1_left___arg0__",
"ROOT_MUX_SEL" : "__pll_root_mux_sel__"
}
},
"PLL.ROOT_MUX1" : {
Expand Down Expand Up @@ -328,19 +323,11 @@
"CLK_BUF.ROOT_BANK_CLKMUX" : {
"rules" : {
"ROUTE_TO_FABRIC_CLK" : "__arg0__"
},
"results" : {
"__location__" : "__{[0]}__.u_gbox_root_bank_clkmux___bank__",
"CLK_BUF" : "ROOT_BANK_SRC==__AB__ --#MUX=__ROOT_BANK_MUX__"
}
},
"CLK_BUF.ROOT_MUX" : {
"rules" : {
"ROUTE_TO_FABRIC_CLK" : "__arg0__"
},
"results" : {
"__location__" : "u_GBOX_HP_40X2.u_gbox_clkmux_52x1_left___arg0__",
"ROOT_MUX_SEL" : "__ROOT_MUX__"
}
}
},
Expand All @@ -352,6 +339,10 @@
" index = 0",
" pair_index = 0",
" ab_io = 0",
" ab_name = ''",
" root_bank_mux_location = ''",
" root_bank_mux_core_input_index = 0",
" root_mux_input_index = 0",
" if name.find('BOOT_CLOCK#') == 0:",
" type = 'BOOT_CLOCK'",
" index = int(name[11:])",
Expand All @@ -365,7 +356,13 @@
" index = int(m.group(4))",
" pair_index = int(m.group(5))",
" ab_io = 0 if (pair_index < 10) else 1",
" return [type, bank, is_clock, index, pair_index, ab_io]",
" ab_name = '%c' % (ord('A') + ab_io)",
" root_name = 'u_GBOX_HP_40X2' if type == 'HP' else ('u_GBOX_HV_40X2_VL' if type == 'HVL' else 'u_GBOX_HV_40X2_VR')",
" root_bank_mux_location = '%s.u_gbox_root_bank_clkmux_%d' % (root_name, bank)",
" root_bank_mux_core_input_index = index - (20 * ab_io)",
" root_mux_input_index = 0 if type == 'HP' else (8 if type == 'HVL' else 16)",
" root_mux_input_index += ((2 * bank) + ab_io)",
" return [type, bank, is_clock, index, pair_index, ab_io, ab_name, root_bank_mux_location, root_bank_mux_core_input_index, root_mux_input_index]",
"def fclk_use_pll_resource(fclk) :",
" pll_resource = 0",
" if fclk.find('hvl_fclk_') == 0 :",
Expand Down
Loading

0 comments on commit d35f0f0

Please sign in to comment.