aboutsummaryrefslogtreecommitdiffstats
path: root/gui/ice40/mainwindow.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gui/ice40/mainwindow.cc')
-rw-r--r--gui/ice40/mainwindow.cc116
1 files changed, 52 insertions, 64 deletions
diff --git a/gui/ice40/mainwindow.cc b/gui/ice40/mainwindow.cc
index f423ee37..4b1f2c57 100644
--- a/gui/ice40/mainwindow.cc
+++ b/gui/ice40/mainwindow.cc
@@ -27,16 +27,14 @@
#include "design_utils.h"
#include "jsonparse.h"
#include "log.h"
-#include "pack.h"
#include "pcf.h"
-#include "place_sa.h"
-#include "route.h"
static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
NEXTPNR_NAMESPACE_BEGIN
-MainWindow::MainWindow(QWidget *parent) : BaseMainWindow(parent), timing_driven(false)
+MainWindow::MainWindow(std::unique_ptr<Context> context, ArchArgs args, QWidget *parent)
+ : BaseMainWindow(std::move(context), parent), timing_driven(false), chipArgs(args)
{
initMainResource();
@@ -62,6 +60,8 @@ MainWindow::MainWindow(QWidget *parent) : BaseMainWindow(parent), timing_driven(
connect(this, SIGNAL(contextChanged(Context *)), task, SIGNAL(contextChanged(Context *)));
createMenu();
+
+ Q_EMIT contextChanged(ctx.get());
}
MainWindow::~MainWindow() { delete task; }
@@ -72,60 +72,46 @@ void MainWindow::createMenu()
menuBar->addAction(menu_Design->menuAction());
actionLoadJSON = new QAction("Open JSON", this);
- QIcon iconLoadJSON;
- iconLoadJSON.addFile(QStringLiteral(":/icons/resources/open_json.png"));
- actionLoadJSON->setIcon(iconLoadJSON);
+ actionLoadJSON->setIcon(QIcon(":/icons/resources/open_json.png"));
actionLoadJSON->setStatusTip("Open an existing JSON file");
+ actionLoadJSON->setEnabled(true);
connect(actionLoadJSON, SIGNAL(triggered()), this, SLOT(open_json()));
- actionLoadJSON->setEnabled(false);
actionLoadPCF = new QAction("Open PCF", this);
- QIcon iconLoadPCF;
- iconLoadPCF.addFile(QStringLiteral(":/icons/resources/open_pcf.png"));
- actionLoadPCF->setIcon(iconLoadPCF);
+ actionLoadPCF->setIcon(QIcon(":/icons/resources/open_pcf.png"));
actionLoadPCF->setStatusTip("Open PCF file");
- connect(actionLoadPCF, SIGNAL(triggered()), this, SLOT(open_pcf()));
actionLoadPCF->setEnabled(false);
+ connect(actionLoadPCF, SIGNAL(triggered()), this, SLOT(open_pcf()));
actionPack = new QAction("Pack", this);
- QIcon iconPack;
- iconPack.addFile(QStringLiteral(":/icons/resources/pack.png"));
- actionPack->setIcon(iconPack);
+ actionPack->setIcon(QIcon(":/icons/resources/pack.png"));
actionPack->setStatusTip("Pack current design");
- connect(actionPack, SIGNAL(triggered()), task, SIGNAL(pack()));
actionPack->setEnabled(false);
+ connect(actionPack, SIGNAL(triggered()), task, SIGNAL(pack()));
actionAssignBudget = new QAction("Assign Budget", this);
- QIcon iconAssignBudget;
- iconAssignBudget.addFile(QStringLiteral(":/icons/resources/time_add.png"));
- actionAssignBudget->setIcon(iconAssignBudget);
+ actionAssignBudget->setIcon(QIcon(":/icons/resources/time_add.png"));
actionAssignBudget->setStatusTip("Assign time budget for current design");
- connect(actionAssignBudget, SIGNAL(triggered()), this, SLOT(budget()));
actionAssignBudget->setEnabled(false);
+ connect(actionAssignBudget, SIGNAL(triggered()), this, SLOT(budget()));
actionPlace = new QAction("Place", this);
- QIcon iconPlace;
- iconPlace.addFile(QStringLiteral(":/icons/resources/place.png"));
- actionPlace->setIcon(iconPlace);
+ actionPlace->setIcon(QIcon(":/icons/resources/place.png"));
actionPlace->setStatusTip("Place current design");
- connect(actionPlace, SIGNAL(triggered()), this, SLOT(place()));
actionPlace->setEnabled(false);
+ connect(actionPlace, SIGNAL(triggered()), this, SLOT(place()));
actionRoute = new QAction("Route", this);
- QIcon iconRoute;
- iconRoute.addFile(QStringLiteral(":/icons/resources/route.png"));
- actionRoute->setIcon(iconRoute);
+ actionRoute->setIcon(QIcon(":/icons/resources/route.png"));
actionRoute->setStatusTip("Route current design");
- connect(actionRoute, SIGNAL(triggered()), task, SIGNAL(route()));
actionRoute->setEnabled(false);
+ connect(actionRoute, SIGNAL(triggered()), task, SIGNAL(route()));
actionSaveAsc = new QAction("Save ASC", this);
- QIcon iconSaveAsc;
- iconSaveAsc.addFile(QStringLiteral(":/icons/resources/save_asc.png"));
- actionSaveAsc->setIcon(iconSaveAsc);
+ actionSaveAsc->setIcon(QIcon(":/icons/resources/save_asc.png"));
actionSaveAsc->setStatusTip("Save ASC file");
- connect(actionSaveAsc, SIGNAL(triggered()), this, SLOT(save_asc()));
actionSaveAsc->setEnabled(false);
+ connect(actionSaveAsc, SIGNAL(triggered()), this, SLOT(save_asc()));
QToolBar *taskFPGABar = new QToolBar();
addToolBar(Qt::TopToolBarArea, taskFPGABar);
@@ -147,28 +133,22 @@ void MainWindow::createMenu()
menu_Design->addAction(actionSaveAsc);
actionPlay = new QAction("Play", this);
- QIcon iconPlay;
- iconPlay.addFile(QStringLiteral(":/icons/resources/control_play.png"));
- actionPlay->setIcon(iconPlay);
+ actionPlay->setIcon(QIcon(":/icons/resources/control_play.png"));
actionPlay->setStatusTip("Continue running task");
- connect(actionPlay, SIGNAL(triggered()), task, SLOT(continue_thread()));
actionPlay->setEnabled(false);
+ connect(actionPlay, SIGNAL(triggered()), task, SLOT(continue_thread()));
actionPause = new QAction("Pause", this);
- QIcon iconPause;
- iconPause.addFile(QStringLiteral(":/icons/resources/control_pause.png"));
- actionPause->setIcon(iconPause);
+ actionPause->setIcon(QIcon(":/icons/resources/control_pause.png"));
actionPause->setStatusTip("Pause running task");
- connect(actionPause, SIGNAL(triggered()), task, SLOT(pause_thread()));
actionPause->setEnabled(false);
+ connect(actionPause, SIGNAL(triggered()), task, SLOT(pause_thread()));
actionStop = new QAction("Stop", this);
- QIcon iconStop;
- iconStop.addFile(QStringLiteral(":/icons/resources/control_stop.png"));
- actionStop->setIcon(iconStop);
+ actionStop->setIcon(QIcon(":/icons/resources/control_stop.png"));
actionStop->setStatusTip("Stop running task");
- connect(actionStop, SIGNAL(triggered()), task, SLOT(terminate_thread()));
actionStop->setEnabled(false);
+ connect(actionStop, SIGNAL(triggered()), task, SLOT(terminate_thread()));
QToolBar *taskToolBar = new QToolBar();
addToolBar(Qt::TopToolBarArea, taskToolBar);
@@ -220,12 +200,16 @@ QStringList getSupportedPackages(ArchArgs::ArchArgsTypes chip)
void MainWindow::new_proj()
{
QMap<QString, int> arch;
+#ifdef ICE40_HX1K_ONLY
+ arch.insert("Lattice HX1K", ArchArgs::HX1K);
+#else
arch.insert("Lattice LP384", ArchArgs::LP384);
arch.insert("Lattice LP1K", ArchArgs::LP1K);
arch.insert("Lattice HX1K", ArchArgs::HX1K);
arch.insert("Lattice UP5K", ArchArgs::UP5K);
arch.insert("Lattice LP8K", ArchArgs::LP8K);
arch.insert("Lattice HX8K", ArchArgs::HX8K);
+#endif
bool ok;
QString item = QInputDialog::getItem(this, "Select new context", "Chip:", arch.keys(), 0, false, &ok);
if (ok && !item.isEmpty()) {
@@ -237,18 +221,30 @@ void MainWindow::new_proj()
if (ok && !item.isEmpty()) {
disableActions();
+ preload_pcf = "";
chipArgs.package = package.toStdString().c_str();
- if (ctx)
- delete ctx;
- ctx = new Context(chipArgs);
-
- Q_EMIT contextChanged(ctx);
-
+ ctx = std::unique_ptr<Context>(new Context(chipArgs));
actionLoadJSON->setEnabled(true);
+
+ Q_EMIT displaySplash();
+ Q_EMIT contextChanged(ctx.get());
}
}
}
+void MainWindow::load_json(std::string filename, std::string pcf)
+{
+ preload_pcf = pcf;
+ disableActions();
+ Q_EMIT task->loadfile(filename);
+}
+
+void MainWindow::load_pcf(std::string filename)
+{
+ disableActions();
+ Q_EMIT task->loadpcf(filename);
+}
+
void MainWindow::newContext(Context *ctx)
{
std::string title = "nextpnr-ice40 - " + ctx->getChipName() + " ( " + chipArgs.package + " )";
@@ -259,8 +255,6 @@ void MainWindow::open_proj()
{
QString fileName = QFileDialog::getOpenFileName(this, QString("Open Project"), QString(), QString("*.proj"));
if (!fileName.isEmpty()) {
- tabWidget->setCurrentWidget(info);
-
std::string fn = fileName.toStdString();
disableActions();
}
@@ -270,12 +264,7 @@ void MainWindow::open_json()
{
QString fileName = QFileDialog::getOpenFileName(this, QString("Open JSON"), QString(), QString("*.json"));
if (!fileName.isEmpty()) {
- tabWidget->setCurrentWidget(info);
-
- std::string fn = fileName.toStdString();
- disableActions();
- timing_driven = false;
- Q_EMIT task->loadfile(fn);
+ load_json(fileName.toStdString(), "");
}
}
@@ -283,11 +272,7 @@ void MainWindow::open_pcf()
{
QString fileName = QFileDialog::getOpenFileName(this, QString("Open PCF"), QString(), QString("*.pcf"));
if (!fileName.isEmpty()) {
- tabWidget->setCurrentWidget(info);
-
- std::string fn = fileName.toStdString();
- disableActions();
- Q_EMIT task->loadpcf(fn);
+ load_pcf(fileName.toStdString());
}
}
@@ -328,9 +313,12 @@ void MainWindow::loadfile_finished(bool status)
log("Loading design successful.\n");
actionLoadPCF->setEnabled(true);
actionPack->setEnabled(true);
+ if (!preload_pcf.empty())
+ load_pcf(preload_pcf);
Q_EMIT updateTreeView();
} else {
log("Loading design failed.\n");
+ preload_pcf = "";
}
}
@@ -440,4 +428,4 @@ void MainWindow::budget()
void MainWindow::place() { Q_EMIT task->place(timing_driven); }
-NEXTPNR_NAMESPACE_END \ No newline at end of file
+NEXTPNR_NAMESPACE_END