SDC: Get clock wire name from SOURCE_PINS Signed-off-by: Tomasz Michalak <tmichalak@antmicro.com>
diff --git a/sdc-plugin/clocks.cc b/sdc-plugin/clocks.cc index 95ebaad..adcb6b1 100644 --- a/sdc-plugin/clocks.cc +++ b/sdc-plugin/clocks.cc
@@ -114,11 +114,18 @@ return WireName(clock_wire); } -std::string Clock::WireName(RTLIL::Wire* wire) { - if (!wire) { +std::string Clock::WireName(RTLIL::Wire* clock_wire) { + if (!clock_wire) { return std::string(); } - return AddEscaping(RTLIL::unescape_id(wire->name)); + return AddEscaping(RTLIL::unescape_id(clock_wire->name)); +} + +std::string Clock::SourcePinName(RTLIL::Wire* clock_wire) { + if (clock_wire->has_attribute(RTLIL::escape_id("SOURCE_PINS"))) { + return clock_wire->get_string_attribute(RTLIL::escape_id("SOURCE_PINS")); + } + return Name(clock_wire); } const std::map<std::string, RTLIL::Wire*> Clocks::GetClocks(
diff --git a/sdc-plugin/clocks.h b/sdc-plugin/clocks.h index 2bcdf75..846a2af 100644 --- a/sdc-plugin/clocks.h +++ b/sdc-plugin/clocks.h
@@ -46,6 +46,7 @@ static std::string AddEscaping(const std::string& name) { return std::regex_replace(name, std::regex{"\\$"}, "\\$"); } + static std::string SourcePinName(RTLIL::Wire* clock_wire); private: static std::pair<float, float> Waveform(RTLIL::Wire* clock_wire);
diff --git a/sdc-plugin/sdc_writer.cc b/sdc-plugin/sdc_writer.cc index 80c8e5e..6f7a760 100644 --- a/sdc-plugin/sdc_writer.cc +++ b/sdc-plugin/sdc_writer.cc
@@ -54,7 +54,7 @@ file << "create_clock -period " << Clock::Period(clock_wire); file << " -waveform {" << Clock::RisingEdge(clock_wire) << " " << Clock::FallingEdge(clock_wire) << "}"; - file << " " << Clock::WireName(clock_wire); + file << " " << Clock::SourcePinName(clock_wire); file << std::endl; } }