aboutsummaryrefslogtreecommitdiffstats
path: root/gui/ice40
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2018-06-26 15:47:22 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2018-06-26 15:47:43 +0200
commit0bd73c19778c9bdbc8e6d85c120715e239a9bc0d (patch)
treec269c560c2dc284a4721bea2722a73bb522e5e3e /gui/ice40
parent6f12f2b7e8c58a0b14c6f1f3df2112b8860a6e4f (diff)
downloadnextpnr-0bd73c19778c9bdbc8e6d85c120715e239a9bc0d.tar.gz
nextpnr-0bd73c19778c9bdbc8e6d85c120715e239a9bc0d.tar.bz2
nextpnr-0bd73c19778c9bdbc8e6d85c120715e239a9bc0d.zip
Make GUI use recreated context
Diffstat (limited to 'gui/ice40')
-rw-r--r--gui/ice40/mainwindow.cc26
-rw-r--r--gui/ice40/mainwindow.h4
-rw-r--r--gui/ice40/worker.cc14
-rw-r--r--gui/ice40/worker.h6
4 files changed, 40 insertions, 10 deletions
diff --git a/gui/ice40/mainwindow.cc b/gui/ice40/mainwindow.cc
index 61ceb3e6..32074adc 100644
--- a/gui/ice40/mainwindow.cc
+++ b/gui/ice40/mainwindow.cc
@@ -36,14 +36,14 @@ static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
NEXTPNR_NAMESPACE_BEGIN
-MainWindow::MainWindow(Context *_ctx, QWidget *parent) : BaseMainWindow(_ctx, parent), timing_driven(false)
+MainWindow::MainWindow(QWidget *parent) : BaseMainWindow(parent), timing_driven(false)
{
initMainResource();
- std::string title = "nextpnr-ice40 - " + ctx->getChipName();
+ std::string title = "nextpnr-ice40 - [EMPTY]";
setWindowTitle(title.c_str());
- task = new TaskManager(_ctx);
+ task = new TaskManager();
connect(task, SIGNAL(log(std::string)), this, SLOT(writeInfo(std::string)));
connect(task, SIGNAL(loadfile_finished(bool)), this, SLOT(loadfile_finished(bool)));
@@ -58,6 +58,9 @@ MainWindow::MainWindow(Context *_ctx, QWidget *parent) : BaseMainWindow(_ctx, pa
connect(task, SIGNAL(taskStarted()), this, SLOT(taskStarted()));
connect(task, SIGNAL(taskPaused()), this, SLOT(taskPaused()));
+ connect(this, SIGNAL(contextChanged(Context*)), this, SLOT(newContext(Context*)));
+ connect(this, SIGNAL(contextChanged(Context*)), task, SIGNAL(contextChanged(Context*)));
+
createMenu();
}
@@ -178,12 +181,27 @@ void MainWindow::createMenu()
void MainWindow::new_proj()
{
disableActions();
+ ArchArgs chipArgs;
+ chipArgs.type = ArchArgs::HX1K;
+ chipArgs.package = "tq144";
+ if (ctx)
+ delete ctx;
+ ctx = new Context(chipArgs);
+
+ Q_EMIT contextChanged(ctx);
+
actionLoadJSON->setEnabled(true);
}
+void MainWindow::newContext(Context *ctx)
+{
+ std::string title = "nextpnr-ice40 - " + ctx->getChipName();
+ setWindowTitle(title.c_str());
+}
+
void MainWindow::open_proj()
{
- QString fileName = QFileDialog::getOpenFileName(this, QString("Open Project"), QString(), QString("*.npnr"));
+ QString fileName = QFileDialog::getOpenFileName(this, QString("Open Project"), QString(), QString("*.proj"));
if (!fileName.isEmpty()) {
tabWidget->setCurrentWidget(info);
diff --git a/gui/ice40/mainwindow.h b/gui/ice40/mainwindow.h
index f4037a47..ffeb0473 100644
--- a/gui/ice40/mainwindow.h
+++ b/gui/ice40/mainwindow.h
@@ -30,7 +30,7 @@ class MainWindow : public BaseMainWindow
Q_OBJECT
public:
- explicit MainWindow(Context *ctx, QWidget *parent = 0);
+ explicit MainWindow(QWidget *parent = 0);
virtual ~MainWindow();
public:
@@ -59,6 +59,8 @@ class MainWindow : public BaseMainWindow
void taskStarted();
void taskPaused();
+ void newContext(Context *ctx);
+
private:
void disableActions();
diff --git a/gui/ice40/worker.cc b/gui/ice40/worker.cc
index f6d6d261..c49b8769 100644
--- a/gui/ice40/worker.cc
+++ b/gui/ice40/worker.cc
@@ -35,7 +35,7 @@ struct WorkerInterruptionRequested
{
};
-Worker::Worker(Context *_ctx, TaskManager *parent) : ctx(_ctx)
+Worker::Worker(TaskManager *parent) : ctx(nullptr)
{
log_write_function = [this, parent](std::string text) {
Q_EMIT log(text);
@@ -56,6 +56,11 @@ Worker::Worker(Context *_ctx, TaskManager *parent) : ctx(_ctx)
};
}
+void Worker::newContext(Context *ctx_)
+{
+ ctx = ctx_;
+}
+
void Worker::loadfile(const std::string &filename)
{
Q_EMIT taskStarted();
@@ -136,9 +141,9 @@ void Worker::route()
}
}
-TaskManager::TaskManager(Context *ctx) : toTerminate(false), toPause(false)
+TaskManager::TaskManager() : toTerminate(false), toPause(false)
{
- Worker *worker = new Worker(ctx, this);
+ Worker *worker = new Worker(this);
worker->moveToThread(&workerThread);
connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater);
@@ -151,6 +156,9 @@ TaskManager::TaskManager(Context *ctx) : toTerminate(false), toPause(false)
connect(this, &TaskManager::place, worker, &Worker::place);
connect(this, &TaskManager::route, worker, &Worker::route);
+
+ connect(this, &TaskManager::contextChanged, worker, &Worker::newContext);
+
connect(worker, &Worker::log, this, &TaskManager::info);
connect(worker, &Worker::loadfile_finished, this, &TaskManager::loadfile_finished);
connect(worker, &Worker::loadpcf_finished, this, &TaskManager::loadpcf_finished);
diff --git a/gui/ice40/worker.h b/gui/ice40/worker.h
index 18f4b2c2..f4369535 100644
--- a/gui/ice40/worker.h
+++ b/gui/ice40/worker.h
@@ -32,8 +32,9 @@ class Worker : public QObject
{
Q_OBJECT
public:
- Worker(Context *ctx, TaskManager *parent);
+ explicit Worker(TaskManager *parent);
public Q_SLOTS:
+ void newContext(Context *);
void loadfile(const std::string &);
void loadpcf(const std::string &);
void saveasc(const std::string &);
@@ -64,7 +65,7 @@ class TaskManager : public QObject
QThread workerThread;
public:
- TaskManager(Context *ctx);
+ explicit TaskManager();
~TaskManager();
bool shouldTerminate();
void clearTerminate();
@@ -75,6 +76,7 @@ class TaskManager : public QObject
void pause_thread();
void continue_thread();
Q_SIGNALS:
+ void contextChanged(Context *ctx);
void terminate();
void loadfile(const std::string &);
void loadpcf(const std::string &);