diff --git a/common/command.cc b/common/command.cc index 46d6d014..43707c83 100644 --- a/common/command.cc +++ b/common/command.cc @@ -149,8 +149,6 @@ po::options_description CommandHandler::getGeneralOptions() general.add_options()("freq", po::value(), "set target frequency for design in MHz"); general.add_options()("timing-allow-fail", "allow timing to fail in design"); general.add_options()("no-tmdriv", "disable timing-driven placement"); - general.add_options()("save", po::value(), "project file to write"); - general.add_options()("load", po::value(), "project file to read"); return general; } @@ -254,8 +252,6 @@ int CommandHandler::executeMain(std::unique_ptr ctx) customAfterLoad(w.getContext()); w.notifyChangeContext(); w.updateLoaded(); - } else if (vm.count("load")) { - w.projectLoad(vm["load"].as()); } else w.notifyChangeContext(); } catch (log_execution_error_exception) { @@ -286,7 +282,7 @@ int CommandHandler::executeMain(std::unique_ptr ctx) execute_python_file(filename.c_str()); } else #endif - if (vm.count("json") || vm.count("load")) { + if (vm.count("json")) { bool do_pack = vm.count("pack-only")!=0 || vm.count("no-pack")==0; bool do_place = vm.count("pack-only")==0 && vm.count("no-place")==0; bool do_route = vm.count("pack-only")==0 && vm.count("no-route")==0; @@ -323,9 +319,6 @@ int CommandHandler::executeMain(std::unique_ptr ctx) if (!write_json_file(f, filename, ctx.get())) log_error("Saving design failed.\n"); } - if (vm.count("save")) { - project.save(ctx.get(), vm["save"].as()); - } #ifndef NO_PYTHON deinit_python(); @@ -361,12 +354,7 @@ int CommandHandler::exec() if (executeBeforeContext()) return 0; - std::unique_ptr ctx; - if (vm.count("load") && vm.count("gui") == 0) { - ctx = project.load(vm["load"].as()); - } else { - ctx = createContext(); - } + std::unique_ptr ctx = createContext(); settings = std::unique_ptr(new Settings(ctx.get())); setupContext(ctx.get()); setupArchContext(ctx.get()); diff --git a/common/command.h b/common/command.h index d0f1d328..c3274197 100644 --- a/common/command.h +++ b/common/command.h @@ -23,7 +23,7 @@ #include #include "nextpnr.h" -#include "project.h" +//#include "project.h" #include "settings.h" NEXTPNR_NAMESPACE_BEGIN @@ -66,7 +66,7 @@ class CommandHandler po::positional_options_description pos; int argc; char **argv; - ProjectHandler project; + //ProjectHandler project; std::ofstream logfile; }; diff --git a/common/project.cc b/common/project.cc deleted file mode 100644 index 3b4e67e4..00000000 --- a/common/project.cc +++ /dev/null @@ -1,146 +0,0 @@ -/* - * nextpnr -- Next Generation Place and Route - * - * Copyright (C) 2018 Miodrag Milanovic - * - * 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 -#include -#include -#include -#include "jsonparse.h" -#include "log.h" - -NEXTPNR_NAMESPACE_BEGIN - -boost::filesystem::path make_relative(boost::filesystem::path child, boost::filesystem::path parent) -{ - boost::filesystem::path::const_iterator parentIter = parent.begin(); - boost::filesystem::path::const_iterator childIter = child.begin(); - - while (parentIter != parent.end() && childIter != child.end() && (*childIter) == (*parentIter)) { - ++childIter; - ++parentIter; - } - - boost::filesystem::path finalPath; - while (parentIter != parent.end()) { - finalPath /= ".."; - ++parentIter; - } - - while (childIter != child.end()) { - finalPath /= *childIter; - ++childIter; - } - - return finalPath; -} - -void ProjectHandler::save(Context *ctx, std::string filename) -{ - try { - boost::filesystem::path proj(filename); - std::ofstream f(filename); - pt::ptree root; - - log_info("Saving project %s...\n", filename.c_str()); - log_break(); - - root.put("project.version", 1); - root.put("project.name", boost::filesystem::basename(filename)); - root.put("project.arch.name", ctx->archId().c_str(ctx)); - root.put("project.arch.type", ctx->archArgsToId(ctx->archArgs()).c_str(ctx)); - std::string fn = ctx->settings[ctx->id("input/json")]; - root.put("project.input.json", make_relative(fn, proj.parent_path()).string()); - root.put("project.params.freq", int(ctx->target_freq / 1e6)); - root.put("project.params.seed", ctx->rngstate); - saveArch(ctx, root, proj.parent_path().string()); - for (auto const &item : ctx->settings) { - std::string path = "project.settings."; - path += item.first.c_str(ctx); - std::replace(path.begin(), path.end(), '/', '.'); - root.put(path, item.second.str); - } - pt::write_json(f, root); - } catch (...) { - log_error("Error saving project file.\n"); - } -} - -void addSettings(Context *ctx, std::string path, pt::ptree sub) -{ - for (pt::ptree::value_type &v : sub) { - const std::string &key = v.first; - const boost::property_tree::ptree &subtree = v.second; - if (subtree.empty()) { - Property p; - p.setString(subtree.get_value().c_str()); - ctx->settings.emplace(ctx->id(path + key), p); - } else { - addSettings(ctx, path + key + "/", subtree); - } - } -} - -std::unique_ptr ProjectHandler::load(std::string filename) -{ - std::unique_ptr ctx; - try { - pt::ptree root; - boost::filesystem::path proj(filename); - pt::read_json(filename, root); - log_info("Loading project %s...\n", filename.c_str()); - log_break(); - - int version = root.get("project.version"); - if (version != 1) - log_error("Wrong project format version.\n"); - - ctx = createContext(root); - - std::string arch_name = root.get("project.arch.name"); - if (arch_name != ctx->archId().c_str(ctx.get())) - log_error("Unsuported project architecture.\n"); - - auto project = root.get_child("project"); - auto input = project.get_child("input"); - std::string fn = input.get("json"); - boost::filesystem::path json = proj.parent_path() / fn; - std::ifstream f(json.string()); - if (!parse_json_file(f, fn, ctx.get())) - log_error("Loading design failed.\n"); - - if (project.count("params")) { - auto params = project.get_child("params"); - if (params.count("freq")) - ctx->target_freq = params.get("freq") * 1e6; - if (params.count("seed")) - ctx->rngseed(params.get("seed")); - } - if (project.count("settings")) { - addSettings(ctx.get(), "", project.get_child("settings")); - } - - loadArch(ctx.get(), root, proj.parent_path().string()); - } catch (...) { - log_error("Error loading project file.\n"); - } - return ctx; -} - -NEXTPNR_NAMESPACE_END diff --git a/common/project.h b/common/project.h deleted file mode 100644 index 03b4b7b5..00000000 --- a/common/project.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * nextpnr -- Next Generation Place and Route - * - * Copyright (C) 2018 Miodrag Milanovic - * - * 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 PROJECT_H -#define PROJECT_H - -#include -#include -#include "nextpnr.h" - -NEXTPNR_NAMESPACE_BEGIN - -namespace pt = boost::property_tree; - -struct ProjectHandler -{ - void save(Context *ctx, std::string filename); - std::unique_ptr load(std::string filename); - // implemented per arch - void saveArch(Context *ctx, pt::ptree &root, std::string path); - std::unique_ptr createContext(pt::ptree &root); - void loadArch(Context *ctx, pt::ptree &root, std::string path); -}; - -boost::filesystem::path make_relative(boost::filesystem::path child, boost::filesystem::path parent); - -NEXTPNR_NAMESPACE_END - -#endif // PROJECT_H diff --git a/ecp5/project.cc b/ecp5/project.cc deleted file mode 100644 index 43318b1c..00000000 --- a/ecp5/project.cc +++ /dev/null @@ -1,55 +0,0 @@ -/* - * nextpnr -- Next Generation Place and Route - * - * Copyright (C) 2018 Miodrag Milanovic - * - * 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 -#include -#include -#include "log.h" - -NEXTPNR_NAMESPACE_BEGIN - -void ProjectHandler::saveArch(Context *ctx, pt::ptree &root, std::string path) -{ - root.put("project.arch.package", ctx->archArgs().package); - root.put("project.arch.speed", ctx->archArgs().speed); -} - -std::unique_ptr ProjectHandler::createContext(pt::ptree &root) -{ - ArchArgs chipArgs; - std::string arch_type = root.get("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("project.arch.package"); - chipArgs.speed = ArchArgs::SpeedGrade(root.get("project.arch.speed")); - - return std::unique_ptr(new Context(chipArgs)); -} - -void ProjectHandler::loadArch(Context *ctx, pt::ptree &root, std::string path) {} - -NEXTPNR_NAMESPACE_END diff --git a/generic/project.cc b/generic/project.cc deleted file mode 100644 index 342fcac3..00000000 --- a/generic/project.cc +++ /dev/null @@ -1,37 +0,0 @@ -/* - * nextpnr -- Next Generation Place and Route - * - * Copyright (C) 2018 Miodrag Milanovic - * - * 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 -#include -#include "log.h" - -NEXTPNR_NAMESPACE_BEGIN - -void ProjectHandler::saveArch(Context *ctx, pt::ptree &root, std::string path) {} - -std::unique_ptr ProjectHandler::createContext(pt::ptree &root) -{ - ArchArgs chipArgs; - return std::unique_ptr(new Context(chipArgs)); -} - -void ProjectHandler::loadArch(Context *ctx, pt::ptree &root, std::string path) {} - -NEXTPNR_NAMESPACE_END diff --git a/gui/basewindow.cc b/gui/basewindow.cc index 346efb88..afc80694 100644 --- a/gui/basewindow.cc +++ b/gui/basewindow.cc @@ -31,7 +31,6 @@ #include "jsonparse.h" #include "log.h" #include "mainwindow.h" -#include "project.h" #include "pythontab.h" static void initBasenameResource() { Q_INIT_RESOURCE(base); } @@ -130,25 +129,6 @@ void BaseMainWindow::writeInfo(std::string text) { console->info(text); } void BaseMainWindow::createMenusAndBars() { // File menu / project toolbar actions - actionNew = new QAction("New", this); - actionNew->setIcon(QIcon(":/icons/resources/new.png")); - actionNew->setShortcuts(QKeySequence::New); - actionNew->setStatusTip("New project file"); - connect(actionNew, &QAction::triggered, this, &BaseMainWindow::new_proj); - - actionOpen = new QAction("Open", this); - actionOpen->setIcon(QIcon(":/icons/resources/open.png")); - actionOpen->setShortcuts(QKeySequence::Open); - actionOpen->setStatusTip("Open an existing project file"); - connect(actionOpen, &QAction::triggered, this, &BaseMainWindow::open_proj); - - actionSave = new QAction("Save", this); - actionSave->setIcon(QIcon(":/icons/resources/save.png")); - actionSave->setShortcuts(QKeySequence::Save); - actionSave->setStatusTip("Save existing project to disk"); - actionSave->setEnabled(false); - connect(actionSave, &QAction::triggered, this, &BaseMainWindow::save_proj); - QAction *actionExit = new QAction("Exit", this); actionExit->setIcon(QIcon(":/icons/resources/exit.png")); actionExit->setShortcuts(QKeySequence::Quit); @@ -243,10 +223,6 @@ void BaseMainWindow::createMenusAndBars() menuBar->addAction(menuHelp->menuAction()); // Add File menu actions - menuFile->addAction(actionNew); - menuFile->addAction(actionOpen); - menuFile->addAction(actionSave); - menuFile->addSeparator(); menuFile->addAction(actionExit); // Add Design menu actions @@ -261,13 +237,6 @@ void BaseMainWindow::createMenusAndBars() // Add Help menu actions menuHelp->addAction(actionAbout); - // Project toolbar - QToolBar *projectToolBar = new QToolBar("Project"); - addToolBar(Qt::TopToolBarArea, projectToolBar); - projectToolBar->addAction(actionNew); - projectToolBar->addAction(actionOpen); - projectToolBar->addAction(actionSave); - // Main action bar mainActionBar = new QToolBar("Main"); addToolBar(Qt::TopToolBarArea, mainActionBar); @@ -386,9 +355,6 @@ void BaseMainWindow::taskStarted() disableActions(); actionPause->setEnabled(true); actionStop->setEnabled(true); - - actionNew->setEnabled(false); - actionOpen->setEnabled(false); } void BaseMainWindow::taskPaused() @@ -396,9 +362,6 @@ void BaseMainWindow::taskPaused() disableActions(); actionPlay->setEnabled(true); actionStop->setEnabled(true); - - actionNew->setEnabled(false); - actionOpen->setEnabled(false); } void BaseMainWindow::budget() @@ -427,14 +390,6 @@ void BaseMainWindow::disableActions() actionPause->setEnabled(false); actionStop->setEnabled(false); - actionNew->setEnabled(true); - actionOpen->setEnabled(true); - - if (ctx->settings.find(ctx->id("input/json")) != ctx->settings.end()) - actionSave->setEnabled(true); - else - actionSave->setEnabled(false); - onDisableActions(); } @@ -446,24 +401,6 @@ void BaseMainWindow::updateLoaded() onProjectLoaded(); } -void BaseMainWindow::projectLoad(std::string filename) -{ - ProjectHandler proj; - disableActions(); - ctx = proj.load(filename); - Q_EMIT contextChanged(ctx.get()); - log_info("Loaded project %s...\n", filename.c_str()); - updateLoaded(); -} - -void BaseMainWindow::open_proj() -{ - QString fileName = QFileDialog::getOpenFileName(this, QString("Open Project"), QString(), QString("*.proj")); - if (!fileName.isEmpty()) { - projectLoad(fileName.toStdString()); - } -} - void BaseMainWindow::execute_python() { QString fileName = QFileDialog::getOpenFileName(this, QString("Execute Python"), QString(), QString("*.py")); @@ -473,18 +410,5 @@ void BaseMainWindow::execute_python() } void BaseMainWindow::notifyChangeContext() { Q_EMIT contextChanged(ctx.get()); } -void BaseMainWindow::save_proj() -{ - if (currentProj.empty()) { - QString fileName = QFileDialog::getSaveFileName(this, QString("Save Project"), QString(), QString("*.proj")); - if (fileName.isEmpty()) - return; - currentProj = fileName.toStdString(); - } - if (!currentProj.empty()) { - ProjectHandler proj; - proj.save(ctx.get(), currentProj); - } -} NEXTPNR_NAMESPACE_END diff --git a/gui/basewindow.h b/gui/basewindow.h index 0b2d3fbc..e165851f 100644 --- a/gui/basewindow.h +++ b/gui/basewindow.h @@ -49,7 +49,6 @@ class BaseMainWindow : public QMainWindow virtual ~BaseMainWindow(); Context *getContext() { return ctx.get(); } void updateLoaded(); - void projectLoad(std::string filename); void notifyChangeContext(); protected: @@ -71,9 +70,6 @@ class BaseMainWindow : public QMainWindow virtual void new_proj() = 0; - void open_proj(); - void save_proj(); - void open_json(); void budget(); void place(); @@ -115,10 +111,6 @@ class BaseMainWindow : public QMainWindow QToolBar *mainActionBar; QProgressBar *progressBar; - QAction *actionNew; - QAction *actionOpen; - QAction *actionSave; - QAction *actionLoadJSON; QAction *actionPack; QAction *actionAssignBudget; diff --git a/ice40/project.cc b/ice40/project.cc deleted file mode 100644 index bbd82fd7..00000000 --- a/ice40/project.cc +++ /dev/null @@ -1,76 +0,0 @@ -/* - * nextpnr -- Next Generation Place and Route - * - * Copyright (C) 2018 Miodrag Milanovic - * - * 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 -#include -#include "log.h" -#include "pcf.h" - -NEXTPNR_NAMESPACE_BEGIN - -void ProjectHandler::saveArch(Context *ctx, pt::ptree &root, std::string path) -{ - root.put("project.arch.package", ctx->archArgs().package); - if (ctx->settings.find(ctx->id("input/pcf")) != ctx->settings.end()) { - std::string fn = ctx->settings[ctx->id("input/pcf")]; - root.put("project.input.pcf", make_relative(fn, path).string()); - } -} - -std::unique_ptr ProjectHandler::createContext(pt::ptree &root) -{ - ArchArgs chipArgs; - std::string arch_type = root.get("project.arch.type"); - if (arch_type == "lp384") { - chipArgs.type = ArchArgs::LP384; - } - if (arch_type == "lp1k") { - chipArgs.type = ArchArgs::LP1K; - } - if (arch_type == "lp8k") { - chipArgs.type = ArchArgs::LP8K; - } - if (arch_type == "hx1k") { - chipArgs.type = ArchArgs::HX1K; - } - if (arch_type == "hx8k") { - chipArgs.type = ArchArgs::HX8K; - } - if (arch_type == "up5k") { - chipArgs.type = ArchArgs::UP5K; - } - if (arch_type == "u4k") { - chipArgs.type = ArchArgs::U4K; - } - chipArgs.package = root.get("project.arch.package"); - - return std::unique_ptr(new Context(chipArgs)); -} - -void ProjectHandler::loadArch(Context *ctx, pt::ptree &root, std::string path) -{ - auto input = root.get_child("project").get_child("input"); - boost::filesystem::path pcf = boost::filesystem::path(path) / input.get("pcf"); - std::ifstream f(pcf.string()); - if (!apply_pcf(ctx, input.get("pcf"), f)) - log_error("Loading PCF failed.\n"); -} - -NEXTPNR_NAMESPACE_END