SDC: Update SdcWriter class to write set_max_delay commands

Signed-off-by: Tomasz Michalak <tmichalak@antmicro.com>
diff --git a/sdc-plugin/Makefile b/sdc-plugin/Makefile
index 3089554..0c9461d 100644
--- a/sdc-plugin/Makefile
+++ b/sdc-plugin/Makefile
@@ -4,7 +4,7 @@
 LDLIBS = $(shell yosys-config --ldlibs)
 PLUGINS_DIR = $(shell yosys-config --datdir)/plugins
 
-OBJS = buffers.o clocks.o propagation.o sdc.o sdc_writer.o set_false_path.o
+OBJS = buffers.o clocks.o propagation.o sdc.o sdc_writer.o set_false_path.o set_max_delay.o
 
 sdc.so: $(OBJS)
 	$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared -o $@ $^ $(LDLIBS)
diff --git a/sdc-plugin/sdc.cc b/sdc-plugin/sdc.cc
index 5f8cad1..df09526 100644
--- a/sdc-plugin/sdc.cc
+++ b/sdc-plugin/sdc.cc
@@ -22,6 +22,7 @@
 #include "kernel/rtlil.h"
 #include "propagation.h"
 #include "set_false_path.h"
+#include "set_max_delay.h"
 #include "sdc_writer.h"
 
 USING_YOSYS_NAMESPACE
@@ -253,7 +254,8 @@
           create_clock_cmd_(clocks_),
           get_clocks_cmd_(clocks_),
           propagate_clocks_cmd_(clocks_),
-          set_false_path_cmd_(sdc_writer_) {
+          set_false_path_cmd_(sdc_writer_),
+          set_max_delay_cmd_(sdc_writer_) {
 	log("Loaded SDC plugin\n");
     }
 
@@ -263,6 +265,7 @@
     GetClocksCmd get_clocks_cmd_;
     PropagateClocksCmd propagate_clocks_cmd_;
     SetFalsePath set_false_path_cmd_;
+    SetMaxDelay set_max_delay_cmd_;
 
    private:
     Clocks clocks_;
diff --git a/sdc-plugin/sdc_writer.cc b/sdc-plugin/sdc_writer.cc
index daae7e2..3c106d3 100644
--- a/sdc-plugin/sdc_writer.cc
+++ b/sdc-plugin/sdc_writer.cc
@@ -23,9 +23,14 @@
     false_paths_.push_back(false_path);
 }
 
+void SdcWriter::SetMaxDelay(TimingPath timing_path) {
+    timing_paths_.push_back(timing_path);
+}
+
 void SdcWriter::WriteSdc(Clocks& clocks, std::ostream& file) {
     WriteClocks(clocks, file);
     WriteFalsePaths(file);
+    WriteMaxDelay(file);
 }
 
 void SdcWriter::WriteClocks(Clocks& clocks, std::ostream& file) {
@@ -61,3 +66,16 @@
 	file << std::endl;
     }
 }
+
+void SdcWriter::WriteMaxDelay(std::ostream& file) {
+    for (auto path : timing_paths_) {
+	file << "set_max_delay " << path.max_delay;
+	if (!path.from_pin.empty()) {
+	    file << " -from " << path.from_pin;
+	}
+	if (!path.to_pin.empty()) {
+	    file << " -to " << path.to_pin;
+	}
+	file << std::endl;
+    }
+}
diff --git a/sdc-plugin/sdc_writer.h b/sdc-plugin/sdc_writer.h
index f5f18b3..5620841 100644
--- a/sdc-plugin/sdc_writer.h
+++ b/sdc-plugin/sdc_writer.h
@@ -26,16 +26,25 @@
     std::string to_pin;
 };
 
+struct TimingPath {
+    std::string from_pin;
+    std::string to_pin;
+    float max_delay;
+};
+
 class SdcWriter {
    public:
     void AddFalsePath(FalsePath false_path);
+    void SetMaxDelay(TimingPath timing_path);
     void WriteSdc(Clocks& clocks, std::ostream& file);
 
    private:
     void WriteClocks(Clocks& clocks, std::ostream& file);
     void WriteFalsePaths(std::ostream& file);
+    void WriteMaxDelay(std::ostream& file);
 
     std::vector<FalsePath> false_paths_;
+    std::vector<TimingPath> timing_paths_;
 };
 
 #endif  // _SDC_WRITER_H_