SDC: Add set_false_path command
Signed-off-by: Tomasz Michalak <tmichalak@antmicro.com>
diff --git a/sdc-plugin/clocks.h b/sdc-plugin/clocks.h
index ff02bd5..f5b491c 100644
--- a/sdc-plugin/clocks.h
+++ b/sdc-plugin/clocks.h
@@ -71,6 +71,9 @@
void Propagate(BufferPropagation* pass);
void Propagate(ClockDividerPropagation* pass);
void WriteSdc(std::ostream& file);
+ const std::vector<Clock> GetClocks() {
+ return clocks_;
+ }
private:
std::vector<Clock> clocks_;
diff --git a/sdc-plugin/sdc.cc b/sdc-plugin/sdc.cc
index 4233d01..5f8cad1 100644
--- a/sdc-plugin/sdc.cc
+++ b/sdc-plugin/sdc.cc
@@ -21,6 +21,8 @@
#include "kernel/register.h"
#include "kernel/rtlil.h"
#include "propagation.h"
+#include "set_false_path.h"
+#include "sdc_writer.h"
USING_YOSYS_NAMESPACE
@@ -57,8 +59,8 @@
};
struct WriteSdcCmd : public Backend {
- WriteSdcCmd(Clocks& clocks)
- : Backend("sdc", "Write SDC file"), clocks_(clocks) {}
+ WriteSdcCmd(Clocks& clocks, SdcWriter& sdc_writer)
+ : Backend("sdc", "Write SDC file"), clocks_(clocks), sdc_writer_(sdc_writer) {}
void help() override {
log("\n");
@@ -75,10 +77,11 @@
}
log("\nWriting out clock constraints file(SDC)\n");
extra_args(f, filename, args, 1);
- clocks_.WriteSdc(*f);
+ sdc_writer_.WriteSdc(clocks_, *f);
}
Clocks& clocks_;
+ SdcWriter& sdc_writer_;
};
struct CreateClockCmd : public Pass {
@@ -246,10 +249,11 @@
class SdcPlugin {
public:
SdcPlugin()
- : write_sdc_cmd_(clocks_),
+ : write_sdc_cmd_(clocks_, sdc_writer_),
create_clock_cmd_(clocks_),
get_clocks_cmd_(clocks_),
- propagate_clocks_cmd_(clocks_) {
+ propagate_clocks_cmd_(clocks_),
+ set_false_path_cmd_(sdc_writer_) {
log("Loaded SDC plugin\n");
}
@@ -258,9 +262,11 @@
CreateClockCmd create_clock_cmd_;
GetClocksCmd get_clocks_cmd_;
PropagateClocksCmd propagate_clocks_cmd_;
+ SetFalsePath set_false_path_cmd_;
private:
Clocks clocks_;
+ SdcWriter sdc_writer_;
} SdcPlugin;
PRIVATE_NAMESPACE_END
diff --git a/sdc-plugin/set_false_path.cc b/sdc-plugin/set_false_path.cc
new file mode 100644
index 0000000..72bb41c
--- /dev/null
+++ b/sdc-plugin/set_false_path.cc
@@ -0,0 +1,90 @@
+/*
+ * yosys -- Yosys Open SYnthesis Suite
+ *
+ * Copyright (C) 2020 The Symbiflow Authors
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#include "set_false_path.h"
+#include <regex>
+#include "kernel/log.h"
+#include "sdc_writer.h"
+
+USING_YOSYS_NAMESPACE
+
+void SetFalsePath::help() {
+ // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|
+ log("\n");
+ log(" set_false_path [-quiet] [-from <net_name>] [-to <net_name>] \n");
+ log("\n");
+ log("Set false path on the specified net\n");
+ log("\n");
+ log("Print the output to stdout too. This is useful when all Yosys is "
+ "executed.\n");
+ log("\n");
+ log(" -quiet\n");
+ log(" Don't print the result of the execution to stdout.\n");
+ log("\n");
+ log(" -from\n");
+ log(" List of start points or clocks.\n");
+ log("\n");
+ log(" -to\n");
+ log(" List of end points or clocks.\n");
+ log("\n");
+}
+
+void SetFalsePath::execute(std::vector<std::string> args,
+ RTLIL::Design* design) {
+ RTLIL::Module* top_module = design->top_module();
+ if (top_module == nullptr) {
+ log_cmd_error("No top module detected\n");
+ }
+
+ size_t argidx;
+ bool is_quiet = false;
+ std::string from_pin;
+ std::string to_pin;
+
+ // Parse command arguments
+ for (argidx = 1; argidx < args.size(); argidx++) {
+ std::string arg = args[argidx];
+ if (arg == "-quiet") {
+ is_quiet = true;
+ continue;
+ }
+
+ if (arg == "-from" and argidx + 1 < args.size()) {
+ from_pin = args[++argidx];
+ log("From: %s\n", from_pin.c_str());
+ continue;
+ }
+
+ if (arg == "-to" and argidx + 1 < args.size()) {
+ to_pin = args[++argidx];
+ log("To: %s\n", to_pin.c_str());
+ continue;
+ }
+
+ if (arg.size() > 0 and arg[0] == '-') {
+ log_cmd_error("Unknown option %s.\n", arg.c_str());
+ }
+
+ break;
+ }
+ if (!is_quiet) {
+ std::string msg = (from_pin.empty()) ? "" : "-from " + from_pin;
+ msg += (to_pin.empty()) ? "" : " -to " + to_pin;
+ log("Adding false path %s\n", msg.c_str());
+ }
+ sdc_writer_.AddFalsePath(FalsePath{.from_pin = from_pin, .to_pin = to_pin});
+}
diff --git a/sdc-plugin/set_false_path.h b/sdc-plugin/set_false_path.h
new file mode 100644
index 0000000..47bf08a
--- /dev/null
+++ b/sdc-plugin/set_false_path.h
@@ -0,0 +1,39 @@
+/*
+ * yosys -- Yosys Open SYnthesis Suite
+ *
+ * Copyright (C) 2020 The Symbiflow Authors
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef _SET_FALSE_PATH_H_
+#define _SET_FALSE_PATH_H_
+
+#include "kernel/register.h"
+#include "kernel/rtlil.h"
+#include "sdc_writer.h"
+
+USING_YOSYS_NAMESPACE
+
+struct SetFalsePath : public Pass {
+ SetFalsePath(SdcWriter& sdc_writer)
+ : Pass("set_false_path", "Set false path on net"),
+ sdc_writer_(sdc_writer) {}
+
+ void help() override;
+
+ void execute(std::vector<std::string> args, RTLIL::Design* design) override;
+
+ SdcWriter& sdc_writer_;
+};
+
+#endif //_SET_FALSE_PATH_H_