SDC: Refactor Clocks methods Signed-off-by: Tomasz Michalak <tmichalak@antmicro.com>
diff --git a/sdc-plugin/clocks.cc b/sdc-plugin/clocks.cc index 4870d28..6bf4eb1 100644 --- a/sdc-plugin/clocks.cc +++ b/sdc-plugin/clocks.cc
@@ -30,18 +30,13 @@ } void Clocks::AddClockWire(const std::string& name, RTLIL::Wire* wire, - float period) { - // Set default duty cycle 50% - AddClockWire(name, wire, period, 0, period / 2); -} - -void Clocks::AddClockWire(const std::string& name, RTLIL::Wire* wire, float period, float rising_edge, float falling_edge) { auto clock = clocks_.find(name); if (clock == clocks_.end()) { - clock = clocks_.emplace(std::make_pair(name, Clock(name))).first; + clocks_.emplace(std::make_pair(name, Clock(name, wire, period, rising_edge, falling_edge))); + } else { + clock->second.AddClockWire(wire, period, rising_edge, falling_edge); } - clock->second.AddClockWire(wire, period, rising_edge, falling_edge); } void Clocks::AddClockWire(const std::string& name, ClockWire& clock_wire) { @@ -148,7 +143,7 @@ Clock::Clock(const std::string& name, RTLIL::Wire* wire, float period, float rising_edge, float falling_edge) - : Clock(name) { + : name_(name) { AddClockWire(wire, period, rising_edge, falling_edge); }
diff --git a/sdc-plugin/clocks.h b/sdc-plugin/clocks.h index f0fe520..e17543e 100644 --- a/sdc-plugin/clocks.h +++ b/sdc-plugin/clocks.h
@@ -54,7 +54,6 @@ class Clock { public: - Clock(const std::string& name) : name_(name) {} Clock(const std::string& name, RTLIL::Wire* wire, float period, float rising_edge, float falling_edge); void AddClockWire(RTLIL::Wire* wire, float period, float rising_edge, @@ -72,7 +71,6 @@ void AddClockWires(const std::string& name, const std::vector<RTLIL::Wire*>& wires, float period, float rising_edge, float falling_edge); - void AddClockWire(const std::string& name, RTLIL::Wire* wire, float period); void AddClockWire(const std::string& name, RTLIL::Wire* wire, float period, float rising_edge, float falling_edge); void AddClockWire(const std::string& name, ClockWire& clock_wire);