aboutsummaryrefslogtreecommitdiffstats
path: root/ecp5
diff options
context:
space:
mode:
Diffstat (limited to 'ecp5')
-rw-r--r--ecp5/arch.cc8
-rw-r--r--ecp5/arch.h7
-rw-r--r--ecp5/main.cc231
-rw-r--r--ecp5/project.cc55
4 files changed, 124 insertions, 177 deletions
diff --git a/ecp5/arch.cc b/ecp5/arch.cc
index 23db8ae5..4358fdaf 100644
--- a/ecp5/arch.cc
+++ b/ecp5/arch.cc
@@ -330,7 +330,6 @@ BelId Arch::getPioByFunctionName(const std::string &name) const
}
std::vector<IdString> Arch::getBelPins(BelId bel) const
-
{
std::vector<IdString> ret;
NPNR_ASSERT(bel != BelId());
@@ -454,9 +453,10 @@ bool Arch::getCellDelay(const CellInfo *cell, IdString fromPort, IdString toPort
return false;
}
-IdString Arch::getPortClock(const CellInfo *cell, IdString port) const { return IdString(); }
-
-bool Arch::isClockPort(const CellInfo *cell, IdString port) const { return false; }
+TimingPortClass Arch::getPortTimingClass(const CellInfo *cell, IdString port, IdString &clockPort) const
+{
+ return TMG_IGNORE;
+}
std::vector<std::pair<std::string, std::string>> Arch::getTilesAtLocation(int row, int col)
{
diff --git a/ecp5/arch.h b/ecp5/arch.h
index b6cc313f..3e2f203b 100644
--- a/ecp5/arch.h
+++ b/ecp5/arch.h
@@ -414,6 +414,7 @@ struct Arch : BaseCtx
std::string getChipName() const;
IdString archId() const { return id("ecp5"); }
+ ArchArgs archArgs() const { return args; }
IdString archArgsToId(ArchArgs args) const;
// -------------------------------------------------
@@ -824,10 +825,8 @@ struct Arch : BaseCtx
// Get the delay through a cell from one port to another, returning false
// if no path exists
bool getCellDelay(const CellInfo *cell, IdString fromPort, IdString toPort, DelayInfo &delay) const;
- // Get the associated clock to a port, or empty if the port is combinational
- IdString getPortClock(const CellInfo *cell, IdString port) const;
- // Return true if a port is a clock
- bool isClockPort(const CellInfo *cell, IdString port) const;
+ // Get the port class, also setting clockPort if applicable
+ TimingPortClass getPortTimingClass(const CellInfo *cell, IdString port, IdString &clockPort) const;
// Return true if a port is a net
bool isGlobalNet(const NetInfo *net) const;
diff --git a/ecp5/main.cc b/ecp5/main.cc
index ecbe747d..5ad5a9bf 100644
--- a/ecp5/main.cc
+++ b/ecp5/main.cc
@@ -19,191 +19,84 @@
#ifdef MAIN_EXECUTABLE
-#ifndef NO_GUI
-#include <QApplication>
-#include "application.h"
-#include "mainwindow.h"
-#endif
-#ifndef NO_PYTHON
-#include "pybindings.h"
-#endif
-#include <boost/filesystem/convenience.hpp>
-#include <boost/program_options.hpp>
#include <fstream>
-#include <iostream>
-
-#include "log.h"
-#include "nextpnr.h"
-#include "version.h"
-
#include "bitstream.h"
+#include "command.h"
#include "design_utils.h"
-#include "jsonparse.h"
+#include "log.h"
#include "timing.h"
USING_NEXTPNR_NAMESPACE
-int main(int argc, char *argv[])
+class ECP5CommandHandler : public CommandHandler
{
- try {
-
- namespace po = boost::program_options;
- int rc = 0;
-
- log_files.push_back(stdout);
-
- po::options_description options("Allowed options");
- options.add_options()("help,h", "show help");
- options.add_options()("verbose,v", "verbose output");
- options.add_options()("force,f", "keep running after errors");
-#ifndef NO_GUI
- options.add_options()("gui", "start gui");
-#endif
- options.add_options()("test", "check architecture database integrity");
-
- options.add_options()("25k", "set device type to LFE5U-25F");
- options.add_options()("45k", "set device type to LFE5U-45F");
- options.add_options()("85k", "set device type to LFE5U-85F");
-
- options.add_options()("package", po::value<std::string>(), "select device package (defaults to CABGA381)");
-
- options.add_options()("json", po::value<std::string>(), "JSON design file to ingest");
- options.add_options()("seed", po::value<int>(), "seed value for random number generator");
-
- options.add_options()("basecfg", po::value<std::string>(), "base chip configuration in Trellis text format");
- options.add_options()("textcfg", po::value<std::string>(), "textual configuration in Trellis format to write");
-
- po::positional_options_description pos;
-#ifndef NO_PYTHON
- options.add_options()("run", po::value<std::vector<std::string>>(), "python file to execute");
- pos.add("run", -1);
-#endif
- options.add_options()("version,V", "show version");
-
- po::variables_map vm;
- try {
- po::parsed_options parsed = po::command_line_parser(argc, argv).options(options).positional(pos).run();
-
- po::store(parsed, vm);
-
- po::notify(vm);
- }
-
- catch (std::exception &e) {
- std::cout << e.what() << "\n";
- return 1;
- }
-
- if (vm.count("help") || argc == 1) {
- std::cout << boost::filesystem::basename(argv[0])
- << " -- Next Generation Place and Route (git "
- "sha1 " GIT_COMMIT_HASH_STR ")\n";
- std::cout << "\n";
- std::cout << options << "\n";
- return argc != 1;
- }
+ public:
+ ECP5CommandHandler(int argc, char **argv);
+ virtual ~ECP5CommandHandler(){};
+ std::unique_ptr<Context> createContext() override;
+ void setupArchContext(Context *ctx) override{};
+ void validate() override;
+ void customBitstream(Context *ctx) override;
- if (vm.count("version")) {
- std::cout << boost::filesystem::basename(argv[0])
- << " -- Next Generation Place and Route (git "
- "sha1 " GIT_COMMIT_HASH_STR ")\n";
- return 1;
- }
+ protected:
+ po::options_description getArchOptions();
+};
- ArchArgs args;
- args.type = ArchArgs::LFE5U_45F;
+ECP5CommandHandler::ECP5CommandHandler(int argc, char **argv) : CommandHandler(argc, argv) {}
- if (vm.count("25k"))
- args.type = ArchArgs::LFE5U_25F;
- if (vm.count("45k"))
- args.type = ArchArgs::LFE5U_45F;
- if (vm.count("85k"))
- args.type = ArchArgs::LFE5U_85F;
- if (vm.count("package"))
- args.package = vm["package"].as<std::string>();
- else
- args.package = "CABGA381";
- args.speed = 6;
- std::unique_ptr<Context> ctx = std::unique_ptr<Context>(new Context(args));
-
- if (vm.count("verbose")) {
- ctx->verbose = true;
- }
-
- if (vm.count("force")) {
- ctx->force = true;
- }
-
- if (vm.count("seed")) {
- ctx->rngseed(vm["seed"].as<int>());
- }
-
- ctx->timing_driven = true;
- if (vm.count("no-tmdriv"))
- ctx->timing_driven = false;
-
- if (vm.count("test"))
- ctx->archcheck();
-
-#ifndef NO_GUI
- if (vm.count("gui")) {
- Application a(argc, argv);
- MainWindow w(std::move(ctx), args);
- w.show();
-
- return a.exec();
- }
-#endif
- if (vm.count("json")) {
- std::string filename = vm["json"].as<std::string>();
- std::ifstream f(filename);
- if (!parse_json_file(f, filename, ctx.get()))
- log_error("Loading design failed.\n");
-
- if (!ctx->pack() && !ctx->force)
- log_error("Packing design failed.\n");
- if (vm.count("freq"))
- ctx->target_freq = vm["freq"].as<double>() * 1e6;
- assign_budget(ctx.get());
- ctx->check();
- print_utilisation(ctx.get());
-
- if (!ctx->place() && !ctx->force)
- log_error("Placing design failed.\n");
- ctx->check();
- if (!ctx->route() && !ctx->force)
- log_error("Routing design failed.\n");
+po::options_description ECP5CommandHandler::getArchOptions()
+{
+ po::options_description specific("Architecture specific options");
+ specific.add_options()("25k", "set device type to LFE5U-25F");
+ specific.add_options()("45k", "set device type to LFE5U-45F");
+ specific.add_options()("85k", "set device type to LFE5U-85F");
+ specific.add_options()("package", po::value<std::string>(), "select device package (defaults to CABGA381)");
+ specific.add_options()("basecfg", po::value<std::string>(), "base chip configuration in Trellis text format");
+ specific.add_options()("textcfg", po::value<std::string>(), "textual configuration in Trellis format to write");
+ return specific;
+}
+void ECP5CommandHandler::validate()
+{
+ if ((vm.count("25k") + vm.count("45k") + vm.count("85k")) > 1)
+ log_error("Only one device type can be set\n");
+}
- std::string basecfg;
- if (vm.count("basecfg"))
- basecfg = vm["basecfg"].as<std::string>();
+void ECP5CommandHandler::customBitstream(Context *ctx)
+{
+ std::string basecfg;
+ if (vm.count("basecfg"))
+ basecfg = vm["basecfg"].as<std::string>();
- std::string textcfg;
- if (vm.count("textcfg"))
- textcfg = vm["textcfg"].as<std::string>();
- write_bitstream(ctx.get(), basecfg, textcfg);
- }
+ std::string textcfg;
+ if (vm.count("textcfg"))
+ textcfg = vm["textcfg"].as<std::string>();
-#ifndef NO_PYTHON
- if (vm.count("run")) {
- init_python(argv[0], true);
- python_export_global("ctx", ctx);
+ write_bitstream(ctx, basecfg, textcfg);
+}
- std::vector<std::string> files = vm["run"].as<std::vector<std::string>>();
- for (auto filename : files)
- execute_python_file(filename.c_str());
+std::unique_ptr<Context> ECP5CommandHandler::createContext()
+{
+ chipArgs.type = ArchArgs::LFE5U_45F;
+
+ if (vm.count("25k"))
+ chipArgs.type = ArchArgs::LFE5U_25F;
+ if (vm.count("45k"))
+ chipArgs.type = ArchArgs::LFE5U_45F;
+ if (vm.count("85k"))
+ chipArgs.type = ArchArgs::LFE5U_85F;
+ if (vm.count("package"))
+ chipArgs.package = vm["package"].as<std::string>();
+ else
+ chipArgs.package = "CABGA381";
+ chipArgs.speed = 6;
+
+ return std::unique_ptr<Context>(new Context(chipArgs));
+}
- deinit_python();
- }
-#endif
- return rc;
- } catch (log_execution_error_exception) {
-#if defined(_MSC_VER)
- _exit(EXIT_FAILURE);
-#else
- _Exit(EXIT_FAILURE);
-#endif
- }
+int main(int argc, char *argv[])
+{
+ ECP5CommandHandler handler(argc, argv);
+ return handler.exec();
}
#endif
diff --git a/ecp5/project.cc b/ecp5/project.cc
new file mode 100644
index 00000000..6c1f6a94
--- /dev/null
+++ b/ecp5/project.cc
@@ -0,0 +1,55 @@
+/*
+ * nextpnr -- Next Generation Place and Route
+ *
+ * Copyright (C) 2018 Miodrag Milanovic <miodrag@symbioticeda.com>
+ *
+ * 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 "project.h"
+#include <boost/filesystem/convenience.hpp>
+#include <boost/property_tree/json_parser.hpp>
+#include <fstream>
+#include "log.h"
+
+NEXTPNR_NAMESPACE_BEGIN
+
+void ProjectHandler::saveArch(Context *ctx, pt::ptree &root)
+{
+ root.put("project.arch.package", ctx->archArgs().package);
+ root.put("project.arch.speed", ctx->archArgs().speed);
+}
+
+std::unique_ptr<Context> ProjectHandler::createContext(pt::ptree &root)
+{
+ ArchArgs chipArgs;
+ std::string arch_type = root.get<std::string>("project.arch.type");
+ if (arch_type == "25k") {
+ chipArgs.type = ArchArgs::LFE5U_25F;
+ }
+ if (arch_type == "45k") {
+ chipArgs.type = ArchArgs::LFE5U_45F;
+ }
+ if (arch_type == "85k") {
+ chipArgs.type = ArchArgs::LFE5U_85F;
+ }
+ chipArgs.package = root.get<std::string>("project.arch.package");
+ chipArgs.speed = root.get<int>("project.arch.speed");
+
+ return std::unique_ptr<Context>(new Context(chipArgs));
+}
+
+void ProjectHandler::loadArch(Context *ctx, pt::ptree &root, std::string path) {}
+
+NEXTPNR_NAMESPACE_END