routing flow supported in gui
@ -26,6 +26,15 @@ MainWindow::MainWindow(Context *_ctx, QWidget *parent)
|
|||||||
task = new TaskManager(_ctx);
|
task = new TaskManager(_ctx);
|
||||||
connect(task, SIGNAL(log(std::string)), this, SLOT(writeInfo(std::string)));
|
connect(task, SIGNAL(log(std::string)), this, SLOT(writeInfo(std::string)));
|
||||||
|
|
||||||
|
connect(task, SIGNAL(loadfile_finished(bool)), this, SLOT(loadfile_finished(bool)));
|
||||||
|
connect(task, SIGNAL(pack_finished(bool)), this, SLOT(pack_finished(bool)));
|
||||||
|
connect(task, SIGNAL(place_finished(bool)), this, SLOT(place_finished(bool)));
|
||||||
|
connect(task, SIGNAL(route_finished(bool)), this, SLOT(route_finished(bool)));
|
||||||
|
|
||||||
|
connect(task, SIGNAL(taskCanceled()), this, SLOT(taskCanceled()));
|
||||||
|
connect(task, SIGNAL(taskStarted()), this, SLOT(taskStarted()));
|
||||||
|
connect(task, SIGNAL(taskPaused()), this, SLOT(taskPaused()));
|
||||||
|
|
||||||
createMenu();
|
createMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,29 +42,67 @@ MainWindow::~MainWindow() { delete task; }
|
|||||||
|
|
||||||
void MainWindow::createMenu()
|
void MainWindow::createMenu()
|
||||||
{
|
{
|
||||||
QMenu *menu_Custom = new QMenu("&ICE 40", menuBar);
|
QMenu *menu_Design = new QMenu("&Design", menuBar);
|
||||||
menuBar->addAction(menu_Custom->menuAction());
|
menuBar->addAction(menu_Design->menuAction());
|
||||||
|
|
||||||
QAction *actionPlay = new QAction("Play", this);
|
actionPack = new QAction("Pack", this);
|
||||||
QIcon icon1;
|
QIcon iconPack;
|
||||||
icon1.addFile(QStringLiteral(":/icons/resources/control_play.png"));
|
iconPack.addFile(QStringLiteral(":/icons/resources/pack.png"));
|
||||||
actionPlay->setIcon(icon1);
|
actionPack->setIcon(iconPack);
|
||||||
|
actionPack->setStatusTip("Pack current design");
|
||||||
|
connect(actionPack, SIGNAL(triggered()), task, SIGNAL(pack()));
|
||||||
|
actionPack->setEnabled(false);
|
||||||
|
|
||||||
|
actionPlace = new QAction("Place", this);
|
||||||
|
QIcon iconPlace;
|
||||||
|
iconPlace.addFile(QStringLiteral(":/icons/resources/place.png"));
|
||||||
|
actionPlace->setIcon(iconPlace);
|
||||||
|
actionPlace->setStatusTip("Place current design");
|
||||||
|
connect(actionPlace, SIGNAL(triggered()), task, SIGNAL(place()));
|
||||||
|
actionPlace->setEnabled(false);
|
||||||
|
|
||||||
|
actionRoute = new QAction("Route", this);
|
||||||
|
QIcon iconRoute;
|
||||||
|
iconRoute.addFile(QStringLiteral(":/icons/resources/route.png"));
|
||||||
|
actionRoute->setIcon(iconRoute);
|
||||||
|
actionRoute->setStatusTip("Route current design");
|
||||||
|
connect(actionRoute, SIGNAL(triggered()), task, SIGNAL(route()));
|
||||||
|
actionRoute->setEnabled(false);
|
||||||
|
|
||||||
|
QToolBar *taskFPGABar = new QToolBar();
|
||||||
|
addToolBar(Qt::TopToolBarArea, taskFPGABar);
|
||||||
|
|
||||||
|
taskFPGABar->addAction(actionPack);
|
||||||
|
taskFPGABar->addAction(actionPlace);
|
||||||
|
taskFPGABar->addAction(actionRoute);
|
||||||
|
|
||||||
|
menu_Design->addAction(actionPack);
|
||||||
|
menu_Design->addAction(actionPlace);
|
||||||
|
menu_Design->addAction(actionRoute);
|
||||||
|
|
||||||
|
actionPlay = new QAction("Play", this);
|
||||||
|
QIcon iconPlay;
|
||||||
|
iconPlay.addFile(QStringLiteral(":/icons/resources/control_play.png"));
|
||||||
|
actionPlay->setIcon(iconPlay);
|
||||||
actionPlay->setStatusTip("Continue running task");
|
actionPlay->setStatusTip("Continue running task");
|
||||||
connect(actionPlay, SIGNAL(triggered()), task, SLOT(continue_thread()));
|
connect(actionPlay, SIGNAL(triggered()), task, SLOT(continue_thread()));
|
||||||
|
actionPlay->setEnabled(false);
|
||||||
|
|
||||||
QAction *actionPause = new QAction("Pause", this);
|
actionPause = new QAction("Pause", this);
|
||||||
QIcon icon2;
|
QIcon iconPause;
|
||||||
icon2.addFile(QStringLiteral(":/icons/resources/control_pause.png"));
|
iconPause.addFile(QStringLiteral(":/icons/resources/control_pause.png"));
|
||||||
actionPause->setIcon(icon2);
|
actionPause->setIcon(iconPause);
|
||||||
actionPause->setStatusTip("Pause running task");
|
actionPause->setStatusTip("Pause running task");
|
||||||
connect(actionPause, SIGNAL(triggered()), task, SLOT(pause_thread()));
|
connect(actionPause, SIGNAL(triggered()), task, SLOT(pause_thread()));
|
||||||
|
actionPause->setEnabled(false);
|
||||||
|
|
||||||
QAction *actionStop = new QAction("Stop", this);
|
actionStop = new QAction("Stop", this);
|
||||||
QIcon icon3;
|
QIcon iconStop;
|
||||||
icon3.addFile(QStringLiteral(":/icons/resources/control_stop.png"));
|
iconStop.addFile(QStringLiteral(":/icons/resources/control_stop.png"));
|
||||||
actionStop->setIcon(icon3);
|
actionStop->setIcon(iconStop);
|
||||||
actionStop->setStatusTip("Stop running task");
|
actionStop->setStatusTip("Stop running task");
|
||||||
connect(actionStop, SIGNAL(triggered()), task, SLOT(terminate_thread()));
|
connect(actionStop, SIGNAL(triggered()), task, SLOT(terminate_thread()));
|
||||||
|
actionStop->setEnabled(false);
|
||||||
|
|
||||||
QToolBar *taskToolBar = new QToolBar();
|
QToolBar *taskToolBar = new QToolBar();
|
||||||
addToolBar(Qt::TopToolBarArea, taskToolBar);
|
addToolBar(Qt::TopToolBarArea, taskToolBar);
|
||||||
@ -73,10 +120,84 @@ void MainWindow::open()
|
|||||||
tabWidget->setCurrentWidget(info);
|
tabWidget->setCurrentWidget(info);
|
||||||
|
|
||||||
std::string fn = fileName.toStdString();
|
std::string fn = fileName.toStdString();
|
||||||
Q_EMIT task->parsejson(fn);
|
disableActions();
|
||||||
|
Q_EMIT task->loadfile(fn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::save() { return false; }
|
bool MainWindow::save() { return false; }
|
||||||
|
|
||||||
|
void MainWindow::disableActions()
|
||||||
|
{
|
||||||
|
actionPack->setEnabled(false);
|
||||||
|
actionPlace->setEnabled(false);
|
||||||
|
actionRoute->setEnabled(false);
|
||||||
|
|
||||||
|
actionPlay->setEnabled(false);
|
||||||
|
actionPause->setEnabled(false);
|
||||||
|
actionStop->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::loadfile_finished(bool status)
|
||||||
|
{
|
||||||
|
disableActions();
|
||||||
|
if (status) {
|
||||||
|
log("Loading design successful.\n");
|
||||||
|
actionPack->setEnabled(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log("Loading design failed.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void MainWindow::pack_finished(bool status)
|
||||||
|
{
|
||||||
|
disableActions();
|
||||||
|
if (status) {
|
||||||
|
log("Packing design successful.\n");
|
||||||
|
actionPlace->setEnabled(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log("Packing design failed.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void MainWindow::place_finished(bool status)
|
||||||
|
{
|
||||||
|
disableActions();
|
||||||
|
if (status) {
|
||||||
|
log("Placing design successful.\n");
|
||||||
|
actionRoute->setEnabled(true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log("Placing design failed.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void MainWindow::route_finished(bool status)
|
||||||
|
{
|
||||||
|
disableActions();
|
||||||
|
if (status)
|
||||||
|
log("Routing design successful.\n");
|
||||||
|
else
|
||||||
|
log("Routing design failed.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::taskCanceled()
|
||||||
|
{
|
||||||
|
log("CANCELED\n");
|
||||||
|
disableActions();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::taskStarted()
|
||||||
|
{
|
||||||
|
disableActions();
|
||||||
|
actionPause->setEnabled(true);
|
||||||
|
actionStop->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::taskPaused()
|
||||||
|
{
|
||||||
|
disableActions();
|
||||||
|
actionPlay->setEnabled(true);
|
||||||
|
actionStop->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
@ -20,9 +20,25 @@ class MainWindow : public BaseMainWindow
|
|||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
virtual void open();
|
virtual void open();
|
||||||
virtual bool save();
|
virtual bool save();
|
||||||
|
void loadfile_finished(bool status);
|
||||||
|
void pack_finished(bool status);
|
||||||
|
void place_finished(bool status);
|
||||||
|
void route_finished(bool status);
|
||||||
|
|
||||||
|
void taskCanceled();
|
||||||
|
void taskStarted();
|
||||||
|
void taskPaused();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void disableActions();
|
||||||
|
|
||||||
TaskManager *task;
|
TaskManager *task;
|
||||||
|
QAction *actionPack;
|
||||||
|
QAction *actionPlace;
|
||||||
|
QAction *actionRoute;
|
||||||
|
QAction *actionPlay;
|
||||||
|
QAction *actionPause;
|
||||||
|
QAction *actionStop;
|
||||||
};
|
};
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
@ -3,5 +3,8 @@
|
|||||||
<file>resources/control_play.png</file>
|
<file>resources/control_play.png</file>
|
||||||
<file>resources/control_pause.png</file>
|
<file>resources/control_pause.png</file>
|
||||||
<file>resources/control_stop.png</file>
|
<file>resources/control_stop.png</file>
|
||||||
|
<file>resources/pack.png</file>
|
||||||
|
<file>resources/place.png</file>
|
||||||
|
<file>resources/route.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
Before Width: | Height: | Size: 598 B After Width: | Height: | Size: 721 B |
Before Width: | Height: | Size: 592 B After Width: | Height: | Size: 717 B |
Before Width: | Height: | Size: 403 B After Width: | Height: | Size: 695 B |
BIN
gui/ice40/resources/pack.png
Normal file
After Width: | Height: | Size: 853 B |
BIN
gui/ice40/resources/place.png
Normal file
After Width: | Height: | Size: 825 B |
BIN
gui/ice40/resources/route.png
Normal file
After Width: | Height: | Size: 683 B |
@ -24,43 +24,88 @@ Worker::Worker(Context *_ctx, TaskManager *parent) : ctx(_ctx)
|
|||||||
parent->clearTerminate();
|
parent->clearTerminate();
|
||||||
throw WorkerInterruptionRequested();
|
throw WorkerInterruptionRequested();
|
||||||
}
|
}
|
||||||
|
if (parent->isPaused())
|
||||||
|
{
|
||||||
|
Q_EMIT taskPaused();
|
||||||
|
}
|
||||||
while (parent->isPaused()) {
|
while (parent->isPaused()) {
|
||||||
|
if (parent->shouldTerminate()) {
|
||||||
|
parent->clearTerminate();
|
||||||
|
throw WorkerInterruptionRequested();
|
||||||
|
}
|
||||||
QThread::sleep(1);
|
QThread::sleep(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Worker::parsejson(const std::string &filename)
|
void Worker::loadfile(const std::string &filename)
|
||||||
{
|
{
|
||||||
|
Q_EMIT taskStarted();
|
||||||
std::string fn = filename;
|
std::string fn = filename;
|
||||||
std::ifstream f(fn);
|
std::ifstream f(fn);
|
||||||
try {
|
try {
|
||||||
if (!parse_json_file(f, fn, ctx))
|
Q_EMIT loadfile_finished(parse_json_file(f, fn, ctx));
|
||||||
log_error("Loading design failed.\n");
|
} catch (WorkerInterruptionRequested) {
|
||||||
if (!pack_design(ctx))
|
Q_EMIT taskCanceled();
|
||||||
log_error("Packing design failed.\n");
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Worker::pack()
|
||||||
|
{
|
||||||
|
Q_EMIT taskStarted();
|
||||||
|
try {
|
||||||
|
Q_EMIT pack_finished(pack_design(ctx));
|
||||||
|
} catch (WorkerInterruptionRequested) {
|
||||||
|
Q_EMIT taskCanceled();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Worker::place()
|
||||||
|
{
|
||||||
|
Q_EMIT taskStarted();
|
||||||
|
try {
|
||||||
double freq = 50e6;
|
double freq = 50e6;
|
||||||
assign_budget(ctx, freq);
|
assign_budget(ctx, freq);
|
||||||
print_utilisation(ctx);
|
print_utilisation(ctx);
|
||||||
|
Q_EMIT place_finished(place_design_sa(ctx));
|
||||||
if (!place_design_sa(ctx))
|
|
||||||
log_error("Placing design failed.\n");
|
|
||||||
if (!route_design(ctx))
|
|
||||||
log_error("Routing design failed.\n");
|
|
||||||
Q_EMIT log("DONE\n");
|
|
||||||
} catch (log_execution_error_exception) {
|
|
||||||
} catch (WorkerInterruptionRequested) {
|
} catch (WorkerInterruptionRequested) {
|
||||||
Q_EMIT log("CANCELED\n");
|
Q_EMIT taskCanceled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Worker::route()
|
||||||
|
{
|
||||||
|
Q_EMIT taskStarted();
|
||||||
|
try {
|
||||||
|
Q_EMIT route_finished(route_design(ctx));
|
||||||
|
} catch (WorkerInterruptionRequested) {
|
||||||
|
Q_EMIT taskCanceled();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TaskManager::TaskManager(Context *ctx) : toTerminate(false), toPause(false)
|
TaskManager::TaskManager(Context *ctx) : toTerminate(false), toPause(false)
|
||||||
{
|
{
|
||||||
Worker *worker = new Worker(ctx, this);
|
Worker *worker = new Worker(ctx, this);
|
||||||
worker->moveToThread(&workerThread);
|
worker->moveToThread(&workerThread);
|
||||||
|
|
||||||
connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater);
|
connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater);
|
||||||
connect(this, &TaskManager::parsejson, worker, &Worker::parsejson);
|
|
||||||
|
connect(this, &TaskManager::loadfile, worker, &Worker::loadfile);
|
||||||
|
connect(this, &TaskManager::pack, worker, &Worker::pack);
|
||||||
|
connect(this, &TaskManager::place, worker, &Worker::place);
|
||||||
|
connect(this, &TaskManager::route, worker, &Worker::route);
|
||||||
|
|
||||||
connect(worker, &Worker::log, this, &TaskManager::info);
|
connect(worker, &Worker::log, this, &TaskManager::info);
|
||||||
|
connect(worker, &Worker::loadfile_finished, this, &TaskManager::loadfile_finished);
|
||||||
|
connect(worker, &Worker::pack_finished, this, &TaskManager::pack_finished);
|
||||||
|
connect(worker, &Worker::place_finished, this, &TaskManager::place_finished);
|
||||||
|
connect(worker, &Worker::route_finished, this, &TaskManager::route_finished);
|
||||||
|
|
||||||
|
connect(worker, &Worker::taskCanceled, this, &TaskManager::taskCanceled);
|
||||||
|
connect(worker, &Worker::taskStarted, this, &TaskManager::taskStarted);
|
||||||
|
connect(worker, &Worker::taskPaused, this, &TaskManager::taskPaused);
|
||||||
|
|
||||||
workerThread.start();
|
workerThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,6 +122,7 @@ void TaskManager::info(const std::string &result) { Q_EMIT log(result); }
|
|||||||
void TaskManager::terminate_thread()
|
void TaskManager::terminate_thread()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&mutex);
|
QMutexLocker locker(&mutex);
|
||||||
|
toPause = false;
|
||||||
toTerminate = true;
|
toTerminate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +148,9 @@ void TaskManager::continue_thread()
|
|||||||
{
|
{
|
||||||
QMutexLocker locker(&mutex);
|
QMutexLocker locker(&mutex);
|
||||||
toPause = false;
|
toPause = false;
|
||||||
|
Q_EMIT taskStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TaskManager::isPaused()
|
bool TaskManager::isPaused()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&mutex);
|
QMutexLocker locker(&mutex);
|
||||||
|
@ -15,9 +15,19 @@ class Worker : public QObject
|
|||||||
public:
|
public:
|
||||||
Worker(Context *ctx, TaskManager *parent);
|
Worker(Context *ctx, TaskManager *parent);
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void parsejson(const std::string &filename);
|
void loadfile(const std::string &);
|
||||||
|
void pack();
|
||||||
|
void place();
|
||||||
|
void route();
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void log(const std::string &text);
|
void log(const std::string &text);
|
||||||
|
void loadfile_finished(bool status);
|
||||||
|
void pack_finished(bool status);
|
||||||
|
void place_finished(bool status);
|
||||||
|
void route_finished(bool status);
|
||||||
|
void taskCanceled();
|
||||||
|
void taskStarted();
|
||||||
|
void taskPaused();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Context *ctx;
|
Context *ctx;
|
||||||
@ -41,8 +51,20 @@ class TaskManager : public QObject
|
|||||||
void continue_thread();
|
void continue_thread();
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void terminate();
|
void terminate();
|
||||||
void parsejson(const std::string &);
|
void loadfile(const std::string &);
|
||||||
|
void pack();
|
||||||
|
void place();
|
||||||
|
void route();
|
||||||
|
|
||||||
|
// redirected signals
|
||||||
void log(const std::string &text);
|
void log(const std::string &text);
|
||||||
|
void loadfile_finished(bool status);
|
||||||
|
void pack_finished(bool status);
|
||||||
|
void place_finished(bool status);
|
||||||
|
void route_finished(bool status);
|
||||||
|
void taskCanceled();
|
||||||
|
void taskStarted();
|
||||||
|
void taskPaused();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMutex mutex;
|
QMutex mutex;
|
||||||
|