Merge branch 'master' of https://github.com/YosysHQ/prjtrellis into facade
diff --git a/.github/archlinux/PKGBUILD b/.github/archlinux/PKGBUILD
index d55c6f0..f94e14b 100644
--- a/.github/archlinux/PKGBUILD
+++ b/.github/archlinux/PKGBUILD
@@ -8,7 +8,7 @@
 pkgrel=1
 pkgdesc='Documentation and definitions for the Lattice ECP5 bit-stream format'
 arch=('x86_64')
-url='https://github.com/SymbiFlow/prjtrellis'
+url='https://github.com/YosysHQ/prjtrellis'
 license=('custom:ISC' 'MIT')
 depends=('boost-libs' "$_pkgname-db")
 makedepends=('git' 'cmake' 'boost' 'python-sphinx' 'python-sphinx_rtd_theme' 'python-recommonmark')
diff --git a/libtrellis/include/ChipConfig.hpp b/libtrellis/include/ChipConfig.hpp
index 59efe84..40973ed 100644
--- a/libtrellis/include/ChipConfig.hpp
+++ b/libtrellis/include/ChipConfig.hpp
@@ -28,6 +28,7 @@
     vector<string> metadata;
     map<string, TileConfig> tiles;
     vector<TileGroup> tilegroups;
+    map<string, string> sysconfig;
 
     // Block RAM initialisation (WIP)
     map<uint16_t, vector<uint16_t>> bram_data;
diff --git a/libtrellis/include/RoutingGraph.hpp b/libtrellis/include/RoutingGraph.hpp
index be23e77..f1c7f1e 100644
--- a/libtrellis/include/RoutingGraph.hpp
+++ b/libtrellis/include/RoutingGraph.hpp
@@ -26,9 +26,6 @@
     Location(int16_t x, int16_t y) : x(x), y(y)
     {};
 
-    Location(const Location &loc) : x(loc.x), y(loc.y)
-    {};
-
     bool operator==(const Location &other) const
     { return x == other.x && y == other.y; }
 
diff --git a/libtrellis/src/ChipConfig.cpp b/libtrellis/src/ChipConfig.cpp
index 0ffdf82..7472bcb 100644
--- a/libtrellis/src/ChipConfig.cpp
+++ b/libtrellis/src/ChipConfig.cpp
@@ -14,6 +14,8 @@
     ss << ".device " << chip_name << endl << endl;
     for (const auto &meta : metadata)
         ss << ".comment " << meta << endl;
+    for (const auto &sc : sysconfig)
+        ss << ".sysconfig " << sc.first << " " << sc.second << endl;
     ss << endl;
     for (const auto &tile : tiles) {
         if (!tile.second.empty()) {
@@ -67,6 +69,10 @@
             TileConfig tc;
             ss >> tc;
             cc.tiles[tilename] = tc;
+        } else if (verb == ".sysconfig") {
+            std::string key, value;
+            ss >> key >> value;
+            cc.sysconfig[key] = value;
         } else if (verb == ".bram_init") {
             uint16_t bram;
             ss >> bram;
diff --git a/libtrellis/tools/ecppack.cpp b/libtrellis/tools/ecppack.cpp
index 6bf2895..f6bf902 100644
--- a/libtrellis/tools/ecppack.cpp
+++ b/libtrellis/tools/ecppack.cpp
@@ -55,18 +55,26 @@
     pos.add("input", 1);
     options.add_options()("bit", po::value<std::string>(), "output bitstream file");
     pos.add("bit", 1);
+    options.add_options()("version", "show current version and exit");
 
     po::variables_map vm;
+
     try {
         po::parsed_options parsed = po::command_line_parser(argc, argv).options(options).positional(pos).run();
         po::store(parsed, vm);
+
+        if (vm.count("version")) {
+            cerr << "Project Trellis ecppack Version " << git_describe_str << endl;
+            return 0;
+        }
+
         po::notify(vm);
     }
-    catch (po::required_option &e) {
+    catch (po::required_option& e) {
         cerr << "Error: input file is mandatory." << endl << endl;
         goto help;
     }
-    catch (std::exception &e) {
+    catch (std::exception& e) {
         cerr << "Error: " << e.what() << endl << endl;
         goto help;
     }
@@ -127,6 +135,18 @@
 
     map<string, string> bitopts;
 
+    // Apply options passed from nextpnr via SYSCONFIG
+    if (cc.sysconfig.count("MCCLK_FREQ")) {
+        std::string freq = cc.sysconfig.at("MCCLK_FREQ");
+        if (freq == "62")
+            freq = "62.0";
+        bitopts["freq"] = freq;
+    }
+
+    if (cc.sysconfig.count("COMPRESS_CONFIG") && cc.sysconfig.at("COMPRESS_CONFIG") == "ON")
+        bitopts["compress"] = "yes";
+
+    // Override with command line options
     if (vm.count("freq"))
         bitopts["freq"] = vm["freq"].as<string>();
 
@@ -216,13 +236,8 @@
         // Create JTAG bitstream without SPI flash related settings, as these
         // seem to confuse the chip sometimes when configuring over JTAG
         if (!bitopts.empty() && !(bitopts.size() == 1 && bitopts.count("compress"))) {
-            bitopts.clear();
-            if (vm.count("background"))
-                bitopts["background"] = "yes";
-            if (vm.count("bootaddr"))
-                bitopts["multiboot"] = "yes";
-            if (vm.count("compress"))
-                bitopts["compress"] = "yes";
+            bitopts.erase("spimode");
+            bitopts.erase("freq");
             b = Bitstream::serialise_chip(c, bitopts);
         }