Skip to content

Commit

Permalink
Accurately set the mode for control signal
Browse files Browse the repository at this point in the history
  • Loading branch information
chungshien-chai committed Sep 4, 2024
1 parent 9998b63 commit 264debd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
28 changes: 18 additions & 10 deletions design_edit/src/primitives_extractor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2735,8 +2735,10 @@ void PRIMITIVES_EXTRACTOR::write_sdc(const std::string& file,
mode = stringf("MODE_%s", pin->mode.c_str());
}
mode = stringf("%s_%c_%s", mode.c_str(), ab, pin->is_input ? "RX" : "TX");
if (m_location_mode.find(pin->location) == m_location_mode.end()) {
m_location_mode[pin->location] = mode;
std::string location_key =
stringf("%s:%s", pin->is_input ? "I" : "O", pin->location.c_str());
if (m_location_mode.find(location_key) == m_location_mode.end()) {
m_location_mode[location_key] = mode;
}
if (pin->skip_reason.size()) {
POST_MSG(4, "Skip this because \'%s\'", pin->skip_reason.c_str());
Expand Down Expand Up @@ -2803,9 +2805,9 @@ void PRIMITIVES_EXTRACTOR::write_sdc(const std::string& file,
std::string linked_object = inst->linked_object();
std::string location = inst->get_location_with_priority();
for (auto iter : db->control_signal_map) {
write_sdc_internal_control_signal(sdc_entries, wrapped_instances,
inst->module, linked_object, location,
iter.first, iter.second);
write_sdc_internal_control_signal(
sdc_entries, wrapped_instances, inst->module, linked_object,
location, iter.first, iter.second, db->is_in_dir());
}
}
}
Expand Down Expand Up @@ -2839,8 +2841,11 @@ void PRIMITIVES_EXTRACTOR::write_sdc(const std::string& file,
std::string clk_net = inst->connections.at(core_clk);
entry->comments.push_back(stringf("# Net: %s", clk_net.c_str()));
if (clk_net.size() > 0) {
std::string location_key =
stringf("%s:%s", inst->primitive->db->is_in_dir() ? "I" : "O",
location.c_str());
if (location.size() > 0 &&
m_location_mode.find(location) != m_location_mode.end()) {
m_location_mode.find(location_key) != m_location_mode.end()) {
uint32_t index = 0;
for (auto& fabric_clk : m_fabric_clocks) {
if (std::find(fabric_clk->gearboxes.begin(),
Expand Down Expand Up @@ -2905,7 +2910,8 @@ void PRIMITIVES_EXTRACTOR::write_sdc_internal_control_signal(
std::vector<SDC_ENTRY*>& sdc_entries,
const nlohmann::json& wrapped_instances, const std::string& module,
const std::string& linked_object, const std::string& location,
const std::string& port, const std::string& internal_signal) {
const std::string& port, const std::string& internal_signal,
bool is_in_dir) {
bool input = true;
std::string internal_signal_name = "";
if (internal_signal.find("in:") == 0) {
Expand Down Expand Up @@ -2934,7 +2940,9 @@ void PRIMITIVES_EXTRACTOR::write_sdc_internal_control_signal(
#endif
// If the mode is available, then the location had been parsed correctly in
// the first place
if (m_location_mode.find(location) != m_location_mode.end()) {
std::string location_key =
stringf("%s:%s", is_in_dir ? "I" : "O", location.c_str());
if (m_location_mode.find(location_key) != m_location_mode.end()) {
PIN_PARSER pin;
log_assert(validate_location(location, pin));
std::vector<std::string> wrapped_nets;
Expand Down Expand Up @@ -3038,8 +3046,8 @@ void PRIMITIVES_EXTRACTOR::write_sdc_internal_control_signal(
std::string set_io = stringf("%sset_io", skip.c_str());
entry->assignments.push_back(
SDC_ASSIGNMENT(set_io, wrapped_net, assigned_location, "-mode",
m_location_mode.at(location), "-internal_pin",
final_internal_signal));
m_location_mode.at(location_key),
"-internal_pin", final_internal_signal));
} else {
post_sdc_comment(
entry, 4, "Fail",
Expand Down
3 changes: 2 additions & 1 deletion design_edit/src/primitives_extractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ class PRIMITIVES_EXTRACTOR {
std::vector<SDC_ENTRY*>& sdc_entries,
const nlohmann::json& wrapped_instances, const std::string& module,
const std::string& linked_object, const std::string& location,
const std::string& port, const std::string& internal_signal);
const std::string& port, const std::string& internal_signal,
bool is_in_dir);
bool validate_location(const std::string& location, PIN_PARSER& pin);
std::string get_assigned_location(SDC_ENTRY*& entry, const std::string& rule,
const std::string& location,
Expand Down

0 comments on commit 264debd

Please sign in to comment.