aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md7
-rw-r--r--common/place_sa.cc29
-rw-r--r--common/util.h9
-rw-r--r--gui/CMakeLists.txt2
-rw-r--r--gui/base.qrc (renamed from gui/nextpnr.qrc)0
-rw-r--r--gui/basewindow.cc8
-rw-r--r--gui/basewindow.h7
-rw-r--r--gui/designwidget.cc4
-rw-r--r--gui/designwidget.h5
-rw-r--r--gui/dummy/mainwindow.cc10
-rw-r--r--gui/dummy/mainwindow.h5
-rw-r--r--gui/dummy/nextpnr.qrc2
-rw-r--r--gui/fpgaviewwidget.cc4
-rw-r--r--gui/fpgaviewwidget.h5
-rw-r--r--gui/ice40/mainwindow.cc172
-rw-r--r--gui/ice40/mainwindow.h21
-rw-r--r--gui/ice40/nextpnr.qrc10
-rw-r--r--gui/ice40/resources/control_pause.pngbin0 -> 721 bytes
-rw-r--r--gui/ice40/resources/control_play.pngbin0 -> 717 bytes
-rw-r--r--gui/ice40/resources/control_stop.pngbin0 -> 695 bytes
-rw-r--r--gui/ice40/resources/pack.pngbin0 -> 853 bytes
-rw-r--r--gui/ice40/resources/place.pngbin0 -> 825 bytes
-rw-r--r--gui/ice40/resources/route.pngbin0 -> 683 bytes
-rw-r--r--gui/ice40/worker.cc138
-rw-r--r--gui/ice40/worker.h48
-rw-r--r--gui/infotab.cc4
-rw-r--r--gui/infotab.h5
-rw-r--r--gui/line_editor.cc7
-rw-r--r--gui/line_editor.h5
-rw-r--r--gui/pythontab.cc6
-rw-r--r--gui/pythontab.h5
-rw-r--r--ice40/bitstream.cc13
-rw-r--r--ice40/main.cc2
-rw-r--r--ice40/pack.cc17
34 files changed, 475 insertions, 75 deletions
diff --git a/README.md b/README.md
index 50df309c..751a864b 100644
--- a/README.md
+++ b/README.md
@@ -11,9 +11,6 @@ Prequisites
- CMake 3.3 or later
- Modern C++11 compiler (`clang-format` required for development)
- - Note: clang may run out of memory building the chipdbs (peak memory
- ~11GB) due to the system currently used. Use gcc, or the 1k-only
- flag, if this causes a problem.
- Qt5 or later (`qt5-default` for Ubuntu 16.04)
- Python 3.5 or later, including development libraries (`python3-dev` for Ubuntu)
- Boost libraries (`libboost-dev` or `libboost-all-dev` for Ubuntu)
@@ -29,8 +26,8 @@ Building
- For a release build, run `cmake .`
- Add `-DCMAKE_INSTALL_PREFIX=/your/install/prefix` to use a different install prefix to the default `/usr/local`
- Use Make to run the build itself
- - For all targets, just run `make`
- - For just the iCE40 CLI binary, run `make nextpnr-ice40`
+ - For all binary targets, just run `make`
+ - For just the iCE40 CLI&GUI binary, run `make nextpnr-ice40`
- For just the iCE40 Python module, run `make nextpnrpy_ice40`
- Using too many parallel jobs may lead to out-of-memory issues due to the significant memory needed to build the chipdbs
- To install nextpnr, run `make install`
diff --git a/common/place_sa.cc b/common/place_sa.cc
index 69ba968f..058f0a84 100644
--- a/common/place_sa.cc
+++ b/common/place_sa.cc
@@ -146,8 +146,9 @@ class SAPlacer
// Calculate wirelength after initial placement
curr_wirelength = 0;
+ curr_tns = 0;
for (auto net : ctx->nets) {
- wirelen_t wl = get_wirelength(net.second);
+ wirelen_t wl = get_wirelength(net.second, curr_tns);
wirelengths[net.first] = wl;
curr_wirelength += wl;
}
@@ -162,8 +163,9 @@ class SAPlacer
improved = false;
if (iter % 5 == 0 || iter == 1)
- log_info(" at iteration #%d: temp = %f, wire length = %f\n",
- iter, temp, double(curr_wirelength));
+ log_info(" at iteration #%d: temp = %f, wire length = "
+ "%.0f, est tns = %.02fns\n",
+ iter, temp, double(curr_wirelength), curr_tns);
for (int m = 0; m < 15; ++m) {
// Loop through all automatically placed cells
@@ -220,8 +222,9 @@ class SAPlacer
// Recalculate total wirelength entirely to avoid rounding errors
// accumulating over time
curr_wirelength = 0;
+ curr_tns = 0;
for (auto net : ctx->nets) {
- wirelen_t wl = get_wirelength(net.second);
+ wirelen_t wl = get_wirelength(net.second, curr_tns);
wirelengths[net.first] = wl;
curr_wirelength += wl;
}
@@ -308,7 +311,7 @@ class SAPlacer
}
// Get the total estimated wirelength for a net
- wirelen_t get_wirelength(NetInfo *net)
+ wirelen_t get_wirelength(NetInfo *net, float &tns)
{
wirelen_t wirelength = 0;
int driver_x, driver_y;
@@ -337,6 +340,8 @@ class SAPlacer
delay_t raw_wl = ctx->estimateDelay(drv_wire, user_wire);
float slack =
ctx->getDelayNS(load.budget) - ctx->getDelayNS(raw_wl);
+ if (slack < 0)
+ tns += slack;
worst_slack = std::min(slack, worst_slack);
int load_x, load_y;
bool load_gb;
@@ -348,8 +353,9 @@ class SAPlacer
xmax = std::max(xmax, load_x);
ymax = std::max(ymax, load_y);
}
- wirelength = wirelen_t((((ymax - ymin) + (xmax - xmin)) *
- (1.0 + std::exp(-worst_slack / 5))));
+ wirelength =
+ wirelen_t((((ymax - ymin) + (xmax - xmin)) *
+ std::min(5.0, (1.0 + std::exp(-worst_slack / 5)))));
return wirelength;
}
@@ -403,16 +409,16 @@ class SAPlacer
// Recalculate wirelengths for all nets touched by the peturbation
for (auto net : update) {
new_wirelength -= wirelengths.at(net->name);
- wirelen_t net_new_wl = get_wirelength(net);
+ float temp_tns = 0;
+ wirelen_t net_new_wl = get_wirelength(net, temp_tns);
new_wirelength += net_new_wl;
new_lengths.push_back(std::make_pair(net->name, net_new_wl));
}
delta = new_wirelength - curr_wirelength;
n_move++;
// SA acceptance criterea
- if (delta < 0 || (temp > 1e-6 &&
- (ctx->rng() / float(0x3fffffff)) <=
- std::exp(-(delta / 2) / temp))) {
+ if (delta < 0 || (temp > 1e-6 && (ctx->rng() / float(0x3fffffff)) <=
+ std::exp(-delta / temp))) {
n_accept++;
if (delta < 2)
improved = true;
@@ -466,6 +472,7 @@ class SAPlacer
Context *ctx;
std::unordered_map<IdString, wirelen_t> wirelengths;
wirelen_t curr_wirelength = std::numeric_limits<wirelen_t>::max();
+ float curr_tns = 0;
float temp = 1000;
bool improved = false;
int n_move, n_accept;
diff --git a/common/util.h b/common/util.h
index 34b2ed02..4c60292b 100644
--- a/common/util.h
+++ b/common/util.h
@@ -20,6 +20,7 @@
#ifndef UTIL_H
#define UTIL_H
+#include <map>
#include <string>
#include "nextpnr.h"
@@ -56,6 +57,14 @@ bool bool_or_default(const Container &ct, const KeyType &key, bool def = false)
{
return bool(int_or_default(ct, key, int(def)));
};
+
+// Wrap an unordered_map, and allow it to be iterated over sorted by key
+template <typename K, typename V>
+std::map<K, V> sorted(const std::unordered_map<K, V> &orig)
+{
+ return std::map<K, V>(orig.begin(), orig.end());
+};
+
NEXTPNR_NAMESPACE_END
#endif
diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt
index b4dcde11..f19d2d20 100644
--- a/gui/CMakeLists.txt
+++ b/gui/CMakeLists.txt
@@ -3,7 +3,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
aux_source_directory(. GUI_SOURCE_FILES)
aux_source_directory(${family}/ GUI_SOURCE_FILES)
-set(_RESOURCES nextpnr.qrc)
+set(_RESOURCES base.qrc ${family}/nextpnr.qrc)
qt5_add_resources(GUI_RESOURCE_FILES ${_RESOURCES})
diff --git a/gui/nextpnr.qrc b/gui/base.qrc
index b9e2f237..b9e2f237 100644
--- a/gui/nextpnr.qrc
+++ b/gui/base.qrc
diff --git a/gui/basewindow.cc b/gui/basewindow.cc
index 9020a719..f16b205d 100644
--- a/gui/basewindow.cc
+++ b/gui/basewindow.cc
@@ -10,10 +10,14 @@
#include "mainwindow.h"
#include "pythontab.h"
+static void initBasenameResource() { Q_INIT_RESOURCE(base); }
+
+NEXTPNR_NAMESPACE_BEGIN
+
BaseMainWindow::BaseMainWindow(Context *_ctx, QWidget *parent)
: QMainWindow(parent), ctx(_ctx)
{
- Q_INIT_RESOURCE(nextpnr);
+ initBasenameResource();
qRegisterMetaType<std::string>();
log_files.clear();
@@ -114,3 +118,5 @@ void BaseMainWindow::createMenusAndBars()
mainToolBar->addAction(actionOpen);
mainToolBar->addAction(actionSave);
}
+
+NEXTPNR_NAMESPACE_END
diff --git a/gui/basewindow.h b/gui/basewindow.h
index b20d4621..55e4affc 100644
--- a/gui/basewindow.h
+++ b/gui/basewindow.h
@@ -11,11 +11,10 @@
#include <QTabWidget>
#include <QToolBar>
-// FIXME
-USING_NEXTPNR_NAMESPACE
-
Q_DECLARE_METATYPE(std::string)
+NEXTPNR_NAMESPACE_BEGIN
+
class BaseMainWindow : public QMainWindow
{
Q_OBJECT
@@ -45,4 +44,6 @@ class BaseMainWindow : public QMainWindow
QStatusBar *statusBar;
};
+NEXTPNR_NAMESPACE_END
+
#endif // BASEMAINWINDOW_H
diff --git a/gui/designwidget.cc b/gui/designwidget.cc
index 9bb25992..7b1ce543 100644
--- a/gui/designwidget.cc
+++ b/gui/designwidget.cc
@@ -7,6 +7,8 @@
#include "fpgaviewwidget.h"
#include "pybindings.h"
+NEXTPNR_NAMESPACE_BEGIN
+
enum class ElementType
{
BEL,
@@ -234,3 +236,5 @@ void DesignWidget::selectObject()
{
Q_EMIT info("selected " + itemContextMenu->text(0).toStdString() + "\n");
}
+
+NEXTPNR_NAMESPACE_END
diff --git a/gui/designwidget.h b/gui/designwidget.h
index 9682726c..5bd12d4d 100644
--- a/gui/designwidget.h
+++ b/gui/designwidget.h
@@ -7,8 +7,7 @@
#include "qttreepropertybrowser.h"
#include "qtvariantproperty.h"
-// FIXME
-USING_NEXTPNR_NAMESPACE
+NEXTPNR_NAMESPACE_BEGIN
class DesignWidget : public QWidget
{
@@ -45,4 +44,6 @@ class DesignWidget : public QWidget
QMap<QString, QtVariantProperty *> idToProperty;
};
+NEXTPNR_NAMESPACE_END
+
#endif // DESIGNWIDGET_H
diff --git a/gui/dummy/mainwindow.cc b/gui/dummy/mainwindow.cc
index 7982c5f5..da162dd0 100644
--- a/gui/dummy/mainwindow.cc
+++ b/gui/dummy/mainwindow.cc
@@ -1,8 +1,14 @@
#include "mainwindow.h"
+static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
+
+NEXTPNR_NAMESPACE_BEGIN
+
MainWindow::MainWindow(Context *_ctx, QWidget *parent)
: BaseMainWindow(_ctx, parent)
{
+ initMainResource();
+
std::string title = "nextpnr-dummy - " + ctx->getChipName();
setWindowTitle(title.c_str());
@@ -19,4 +25,6 @@ void MainWindow::createMenu()
void MainWindow::open() {}
-bool MainWindow::save() { return false; } \ No newline at end of file
+bool MainWindow::save() { return false; }
+
+NEXTPNR_NAMESPACE_END
diff --git a/gui/dummy/mainwindow.h b/gui/dummy/mainwindow.h
index c9690f2c..c2786906 100644
--- a/gui/dummy/mainwindow.h
+++ b/gui/dummy/mainwindow.h
@@ -3,8 +3,7 @@
#include "../basewindow.h"
-// FIXME
-USING_NEXTPNR_NAMESPACE
+NEXTPNR_NAMESPACE_BEGIN
class MainWindow : public BaseMainWindow
{
@@ -22,4 +21,6 @@ class MainWindow : public BaseMainWindow
virtual bool save();
};
+NEXTPNR_NAMESPACE_END
+
#endif // MAINWINDOW_H
diff --git a/gui/dummy/nextpnr.qrc b/gui/dummy/nextpnr.qrc
new file mode 100644
index 00000000..03585ec0
--- /dev/null
+++ b/gui/dummy/nextpnr.qrc
@@ -0,0 +1,2 @@
+<RCC>
+</RCC>
diff --git a/gui/fpgaviewwidget.cc b/gui/fpgaviewwidget.cc
index 6b7e7787..8119eae3 100644
--- a/gui/fpgaviewwidget.cc
+++ b/gui/fpgaviewwidget.cc
@@ -6,6 +6,8 @@
#include <math.h>
#include "mainwindow.h"
+NEXTPNR_NAMESPACE_BEGIN
+
FPGAViewWidget::FPGAViewWidget(QWidget *parent)
: QOpenGLWidget(parent), m_xMove(0), m_yMove(0), m_zDistance(1.0)
{
@@ -173,3 +175,5 @@ void FPGAViewWidget::wheelEvent(QWheelEvent *event)
setZoom(step.y() * -0.1f);
}
}
+
+NEXTPNR_NAMESPACE_END
diff --git a/gui/fpgaviewwidget.h b/gui/fpgaviewwidget.h
index 2407f757..fc3ca562 100644
--- a/gui/fpgaviewwidget.h
+++ b/gui/fpgaviewwidget.h
@@ -7,8 +7,7 @@
#include <QPainter>
#include "nextpnr.h"
-// FIXME
-USING_NEXTPNR_NAMESPACE
+NEXTPNR_NAMESPACE_BEGIN
class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
{
@@ -49,4 +48,6 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
Context *ctx;
};
+NEXTPNR_NAMESPACE_END
+
#endif
diff --git a/gui/ice40/mainwindow.cc b/gui/ice40/mainwindow.cc
index 934798bb..0a248938 100644
--- a/gui/ice40/mainwindow.cc
+++ b/gui/ice40/mainwindow.cc
@@ -11,24 +11,105 @@
#include "place_sa.h"
#include "route.h"
+static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
+
+NEXTPNR_NAMESPACE_BEGIN
+
MainWindow::MainWindow(Context *_ctx, QWidget *parent)
: BaseMainWindow(_ctx, parent)
{
+ initMainResource();
+
std::string title = "nextpnr-ice40 - " + ctx->getChipName();
setWindowTitle(title.c_str());
- createMenu();
-
task = new TaskManager(_ctx);
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();
}
-MainWindow::~MainWindow() {}
+MainWindow::~MainWindow() { delete task; }
void MainWindow::createMenu()
{
- QMenu *menu_Custom = new QMenu("&ICE 40", menuBar);
- menuBar->addAction(menu_Custom->menuAction());
+ QMenu *menu_Design = new QMenu("&Design", menuBar);
+ menuBar->addAction(menu_Design->menuAction());
+
+ actionPack = new QAction("Pack", this);
+ QIcon iconPack;
+ iconPack.addFile(QStringLiteral(":/icons/resources/pack.png"));
+ 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");
+ connect(actionPlay, SIGNAL(triggered()), task, SLOT(continue_thread()));
+ actionPlay->setEnabled(false);
+
+ actionPause = new QAction("Pause", this);
+ QIcon iconPause;
+ iconPause.addFile(QStringLiteral(":/icons/resources/control_pause.png"));
+ actionPause->setIcon(iconPause);
+ actionPause->setStatusTip("Pause running task");
+ connect(actionPause, SIGNAL(triggered()), task, SLOT(pause_thread()));
+ actionPause->setEnabled(false);
+
+ actionStop = new QAction("Stop", this);
+ QIcon iconStop;
+ iconStop.addFile(QStringLiteral(":/icons/resources/control_stop.png"));
+ actionStop->setIcon(iconStop);
+ actionStop->setStatusTip("Stop running task");
+ connect(actionStop, SIGNAL(triggered()), task, SLOT(terminate_thread()));
+ actionStop->setEnabled(false);
+
+ QToolBar *taskToolBar = new QToolBar();
+ addToolBar(Qt::TopToolBarArea, taskToolBar);
+
+ taskToolBar->addAction(actionPlay);
+ taskToolBar->addAction(actionPause);
+ taskToolBar->addAction(actionStop);
}
void MainWindow::open()
@@ -39,7 +120,84 @@ void MainWindow::open()
tabWidget->setCurrentWidget(info);
std::string fn = fileName.toStdString();
- task->parsejson(fn);
+ disableActions();
+ Q_EMIT task->loadfile(fn);
+ }
+}
+
+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");
}
}
-bool MainWindow::save() { return false; } \ No newline at end of file
+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 \ No newline at end of file
diff --git a/gui/ice40/mainwindow.h b/gui/ice40/mainwindow.h
index fd65f9ae..9083ed8a 100644
--- a/gui/ice40/mainwindow.h
+++ b/gui/ice40/mainwindow.h
@@ -4,8 +4,7 @@
#include "../basewindow.h"
#include "worker.h"
-// FIXME
-USING_NEXTPNR_NAMESPACE
+NEXTPNR_NAMESPACE_BEGIN
class MainWindow : public BaseMainWindow
{
@@ -21,9 +20,27 @@ class MainWindow : public BaseMainWindow
protected Q_SLOTS:
virtual void open();
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:
+ void disableActions();
+
TaskManager *task;
+ QAction *actionPack;
+ QAction *actionPlace;
+ QAction *actionRoute;
+ QAction *actionPlay;
+ QAction *actionPause;
+ QAction *actionStop;
};
+NEXTPNR_NAMESPACE_END
+
#endif // MAINWINDOW_H
diff --git a/gui/ice40/nextpnr.qrc b/gui/ice40/nextpnr.qrc
new file mode 100644
index 00000000..3bc68978
--- /dev/null
+++ b/gui/ice40/nextpnr.qrc
@@ -0,0 +1,10 @@
+<RCC>
+ <qresource prefix="/icons">
+ <file>resources/control_play.png</file>
+ <file>resources/control_pause.png</file>
+ <file>resources/control_stop.png</file>
+ <file>resources/pack.png</file>
+ <file>resources/place.png</file>
+ <file>resources/route.png</file>
+ </qresource>
+</RCC>
diff --git a/gui/ice40/resources/control_pause.png b/gui/ice40/resources/control_pause.png
new file mode 100644
index 00000000..ec61099b
--- /dev/null
+++ b/gui/ice40/resources/control_pause.png
Binary files differ
diff --git a/gui/ice40/resources/control_play.png b/gui/ice40/resources/control_play.png
new file mode 100644
index 00000000..f8c8ec68
--- /dev/null
+++ b/gui/ice40/resources/control_play.png
Binary files differ
diff --git a/gui/ice40/resources/control_stop.png b/gui/ice40/resources/control_stop.png
new file mode 100644
index 00000000..e6f75d23
--- /dev/null
+++ b/gui/ice40/resources/control_stop.png
Binary files differ
diff --git a/gui/ice40/resources/pack.png b/gui/ice40/resources/pack.png
new file mode 100644
index 00000000..da3c2a2d
--- /dev/null
+++ b/gui/ice40/resources/pack.png
Binary files differ
diff --git a/gui/ice40/resources/place.png b/gui/ice40/resources/place.png
new file mode 100644
index 00000000..0905f933
--- /dev/null
+++ b/gui/ice40/resources/place.png
Binary files differ
diff --git a/gui/ice40/resources/route.png b/gui/ice40/resources/route.png
new file mode 100644
index 00000000..258c16c6
--- /dev/null
+++ b/gui/ice40/resources/route.png
Binary files differ
diff --git a/gui/ice40/worker.cc b/gui/ice40/worker.cc
index 5702137b..9df24f65 100644
--- a/gui/ice40/worker.cc
+++ b/gui/ice40/worker.cc
@@ -10,47 +10,151 @@
#include "route.h"
#include "timing.h"
-Worker::Worker(Context *_ctx) : ctx(_ctx)
+NEXTPNR_NAMESPACE_BEGIN
+
+struct WorkerInterruptionRequested
+{
+};
+
+Worker::Worker(Context *_ctx, TaskManager *parent) : ctx(_ctx)
{
- log_write_function = [this](std::string text) { Q_EMIT log(text); };
+ log_write_function = [this, parent](std::string text) {
+ Q_EMIT log(text);
+ if (parent->shouldTerminate()) {
+ parent->clearTerminate();
+ throw WorkerInterruptionRequested();
+ }
+ if (parent->isPaused())
+ {
+ Q_EMIT taskPaused();
+ }
+ while (parent->isPaused()) {
+ if (parent->shouldTerminate()) {
+ parent->clearTerminate();
+ throw WorkerInterruptionRequested();
+ }
+ 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::ifstream f(fn);
try {
- if (!parse_json_file(f, fn, ctx))
- log_error("Loading design failed.\n");
- if (!pack_design(ctx))
- log_error("Packing design failed.\n");
+ Q_EMIT loadfile_finished(parse_json_file(f, fn, ctx));
+ } catch (WorkerInterruptionRequested) {
+ Q_EMIT taskCanceled();
+ }
+}
+
+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;
assign_budget(ctx, freq);
print_utilisation(ctx);
+ Q_EMIT place_finished(place_design_sa(ctx));
+ } catch (WorkerInterruptionRequested) {
+ Q_EMIT taskCanceled();
+ }
+}
- 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");
- } catch (log_execution_error_exception) {
+void Worker::route()
+{
+ Q_EMIT taskStarted();
+ try {
+ Q_EMIT route_finished(route_design(ctx));
+ } catch (WorkerInterruptionRequested) {
+ Q_EMIT taskCanceled();
}
}
-TaskManager::TaskManager(Context *ctx)
+
+TaskManager::TaskManager(Context *ctx) : toTerminate(false), toPause(false)
{
- Worker *worker = new Worker(ctx);
+ Worker *worker = new Worker(ctx, this);
worker->moveToThread(&workerThread);
+
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::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();
}
TaskManager::~TaskManager()
{
+ if (workerThread.isRunning())
+ terminate_thread();
workerThread.quit();
workerThread.wait();
}
-void TaskManager::info(const std::string &result) { Q_EMIT log(result); } \ No newline at end of file
+void TaskManager::info(const std::string &result) { Q_EMIT log(result); }
+
+void TaskManager::terminate_thread()
+{
+ QMutexLocker locker(&mutex);
+ toPause = false;
+ toTerminate = true;
+}
+
+bool TaskManager::shouldTerminate()
+{
+ QMutexLocker locker(&mutex);
+ return toTerminate;
+}
+
+void TaskManager::clearTerminate()
+{
+ QMutexLocker locker(&mutex);
+ toTerminate = false;
+}
+
+void TaskManager::pause_thread()
+{
+ QMutexLocker locker(&mutex);
+ toPause = true;
+}
+
+void TaskManager::continue_thread()
+{
+ QMutexLocker locker(&mutex);
+ toPause = false;
+ Q_EMIT taskStarted();
+}
+
+bool TaskManager::isPaused()
+{
+ QMutexLocker locker(&mutex);
+ return toPause;
+}
+
+NEXTPNR_NAMESPACE_END
diff --git a/gui/ice40/worker.h b/gui/ice40/worker.h
index 12d740dd..320dc94c 100644
--- a/gui/ice40/worker.h
+++ b/gui/ice40/worker.h
@@ -1,21 +1,33 @@
#ifndef WORKER_H
#define WORKER_H
+#include <QMutex>
#include <QThread>
#include "nextpnr.h"
-// FIXME
-USING_NEXTPNR_NAMESPACE
+NEXTPNR_NAMESPACE_BEGIN
+
+class TaskManager;
class Worker : public QObject
{
Q_OBJECT
public:
- Worker(Context *ctx);
+ Worker(Context *ctx, TaskManager *parent);
public Q_SLOTS:
- void parsejson(const std::string &filename);
+ void loadfile(const std::string &);
+ void pack();
+ void place();
+ void route();
Q_SIGNALS:
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:
Context *ctx;
@@ -29,11 +41,37 @@ class TaskManager : public QObject
public:
TaskManager(Context *ctx);
~TaskManager();
+ bool shouldTerminate();
+ void clearTerminate();
+ bool isPaused();
public Q_SLOTS:
void info(const std::string &text);
+ void terminate_thread();
+ void pause_thread();
+ void continue_thread();
Q_SIGNALS:
- void parsejson(const std::string &);
+ void terminate();
+ void loadfile(const std::string &);
+ void pack();
+ void place();
+ void route();
+
+ // redirected signals
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:
+ QMutex mutex;
+ bool toTerminate;
+ bool toPause;
};
+NEXTPNR_NAMESPACE_END
+
#endif // WORKER_H
diff --git a/gui/infotab.cc b/gui/infotab.cc
index 7690b83c..29d557d2 100644
--- a/gui/infotab.cc
+++ b/gui/infotab.cc
@@ -1,6 +1,8 @@
#include "infotab.h"
#include <QGridLayout>
+NEXTPNR_NAMESPACE_BEGIN
+
InfoTab::InfoTab(QWidget *parent) : QWidget(parent)
{
plainTextEdit = new QPlainTextEdit();
@@ -37,3 +39,5 @@ void InfoTab::showContextMenu(const QPoint &pt)
}
void InfoTab::clearBuffer() { plainTextEdit->clear(); }
+
+NEXTPNR_NAMESPACE_END
diff --git a/gui/infotab.h b/gui/infotab.h
index d7f1408c..3e0220c4 100644
--- a/gui/infotab.h
+++ b/gui/infotab.h
@@ -5,8 +5,7 @@
#include <QPlainTextEdit>
#include "nextpnr.h"
-// FIXME
-USING_NEXTPNR_NAMESPACE
+NEXTPNR_NAMESPACE_BEGIN
class InfoTab : public QWidget
{
@@ -24,4 +23,6 @@ class InfoTab : public QWidget
QMenu *contextMenu;
};
+NEXTPNR_NAMESPACE_END
+
#endif // INFOTAB_H
diff --git a/gui/line_editor.cc b/gui/line_editor.cc
index b5ed955f..6299c9cc 100644
--- a/gui/line_editor.cc
+++ b/gui/line_editor.cc
@@ -1,7 +1,8 @@
#include "line_editor.h"
-
#include <QKeyEvent>
+NEXTPNR_NAMESPACE_BEGIN
+
LineEditor::LineEditor(QWidget *parent) : QLineEdit(parent), index(0)
{
setContextMenuPolicy(Qt::CustomContextMenu);
@@ -64,4 +65,6 @@ void LineEditor::clearHistory()
lines.clear();
index = 0;
clear();
-} \ No newline at end of file
+}
+
+NEXTPNR_NAMESPACE_END \ No newline at end of file
diff --git a/gui/line_editor.h b/gui/line_editor.h
index 15b675f9..5f27e502 100644
--- a/gui/line_editor.h
+++ b/gui/line_editor.h
@@ -3,6 +3,9 @@
#include <QLineEdit>
#include <QMenu>
+#include "nextpnr.h"
+
+NEXTPNR_NAMESPACE_BEGIN
class LineEditor : public QLineEdit
{
@@ -28,4 +31,6 @@ class LineEditor : public QLineEdit
QMenu *contextMenu;
};
+NEXTPNR_NAMESPACE_END
+
#endif // LINE_EDITOR_H
diff --git a/gui/pythontab.cc b/gui/pythontab.cc
index 96a6c4b9..19aa0162 100644
--- a/gui/pythontab.cc
+++ b/gui/pythontab.cc
@@ -3,6 +3,8 @@
#include "emb.h"
#include "pybindings.h"
+NEXTPNR_NAMESPACE_BEGIN
+
PythonTab::PythonTab(QWidget *parent) : QWidget(parent)
{
PyImport_ImportModule("emb");
@@ -114,4 +116,6 @@ void PythonTab::showContextMenu(const QPoint &pt)
contextMenu->exec(mapToGlobal(pt));
}
-void PythonTab::clearBuffer() { plainTextEdit->clear(); } \ No newline at end of file
+void PythonTab::clearBuffer() { plainTextEdit->clear(); }
+
+NEXTPNR_NAMESPACE_END
diff --git a/gui/pythontab.h b/gui/pythontab.h
index 5aed8b0b..52a8ff8d 100644
--- a/gui/pythontab.h
+++ b/gui/pythontab.h
@@ -8,8 +8,7 @@
#include "line_editor.h"
#include "nextpnr.h"
-// FIXME
-USING_NEXTPNR_NAMESPACE
+NEXTPNR_NAMESPACE_BEGIN
class PythonTab : public QWidget
{
@@ -33,4 +32,6 @@ class PythonTab : public QWidget
emb::stdout_write_type write;
};
+NEXTPNR_NAMESPACE_END
+
#endif // PYTHONTAB_H
diff --git a/ice40/bitstream.cc b/ice40/bitstream.cc
index 8754fef7..e722cea4 100644
--- a/ice40/bitstream.cc
+++ b/ice40/bitstream.cc
@@ -229,6 +229,16 @@ void write_asc(const Context *ctx, std::ostream &out)
set_config(ti, config.at(iey).at(iex),
"IoCtrl.REN_" + std::to_string(iez), !pullup);
}
+
+ if (ctx->args.type == ArchArgs::UP5K) {
+ if (iez == 0) {
+ set_config(ti, config.at(iey).at(iex), "IoCtrl.cf_bit_39",
+ !pullup);
+ } else if (iez == 1) {
+ set_config(ti, config.at(iey).at(iex), "IoCtrl.cf_bit_35",
+ !pullup);
+ }
+ }
} else if (cell.second->type == ctx->id("SB_GB")) {
// no cell config bits
} else if (cell.second->type == ctx->id("ICESTORM_RAM")) {
@@ -312,7 +322,8 @@ void write_asc(const Context *ctx, std::ostream &out)
ctx->args.type == ArchArgs::HX8K) {
setColBufCtrl = (y == 8 || y == 9 || y == 24 || y == 25);
} else if (ctx->args.type == ArchArgs::UP5K) {
- if (tile == TILE_LOGIC) {
+ if (tile == TILE_LOGIC || tile == TILE_RAMB ||
+ tile == TILE_RAMT) {
setColBufCtrl = (y == 4 || y == 5 || y == 14 || y == 15 ||
y == 26 || y == 27);
} else {
diff --git a/ice40/main.cc b/ice40/main.cc
index 067637e8..9e925148 100644
--- a/ice40/main.cc
+++ b/ice40/main.cc
@@ -38,6 +38,8 @@
#include "timing.h"
#include "version.h"
+USING_NEXTPNR_NAMESPACE
+
void svg_dump_el(const GraphicElement &el)
{
float scale = 10.0, offset = 10.0;
diff --git a/ice40/pack.cc b/ice40/pack.cc
index 9258014e..35cef8b8 100644
--- a/ice40/pack.cc
+++ b/ice40/pack.cc
@@ -24,6 +24,7 @@
#include "cells.h"
#include "design_utils.h"
#include "log.h"
+#include "util.h"
NEXTPNR_NAMESPACE_BEGIN
@@ -34,7 +35,7 @@ static void pack_lut_lutffs(Context *ctx)
std::unordered_set<IdString> packed_cells;
std::vector<CellInfo *> new_cells;
- for (auto cell : ctx->cells) {
+ for (auto cell : sorted(ctx->cells)) {
CellInfo *ci = cell.second;
if (ctx->verbose)
log_info("cell '%s' is of type '%s'\n", ci->name.c_str(ctx),
@@ -96,7 +97,7 @@ static void pack_nonlut_ffs(Context *ctx)
std::unordered_set<IdString> packed_cells;
std::vector<CellInfo *> new_cells;
- for (auto cell : ctx->cells) {
+ for (auto cell : sorted(ctx->cells)) {
CellInfo *ci = cell.second;
if (is_ff(ctx, ci)) {
CellInfo *packed = create_ice_cell(ctx, "ICESTORM_LC",
@@ -126,7 +127,7 @@ static void pack_carries(Context *ctx)
std::unordered_set<IdString> packed_cells;
- for (auto cell : ctx->cells) {
+ for (auto cell : sorted(ctx->cells)) {
CellInfo *ci = cell.second;
if (is_carry(ctx, ci)) {
packed_cells.insert(cell.first);
@@ -201,7 +202,7 @@ static void pack_ram(Context *ctx)
std::unordered_set<IdString> packed_cells;
std::vector<CellInfo *> new_cells;
- for (auto cell : ctx->cells) {
+ for (auto cell : sorted(ctx->cells)) {
CellInfo *ci = cell.second;
if (is_ram(ctx, ci)) {
CellInfo *packed = create_ice_cell(ctx, "ICESTORM_RAM",
@@ -285,7 +286,7 @@ static void pack_constants(Context *ctx)
bool gnd_used = false, vcc_used = false;
- for (auto net : ctx->nets) {
+ for (auto net : sorted(ctx->nets)) {
NetInfo *ni = net.second;
if (ni->driver.cell != nullptr &&
ni->driver.cell->type == ctx->id("GND")) {
@@ -329,7 +330,7 @@ static void pack_io(Context *ctx)
log_info("Packing IOs..\n");
- for (auto cell : ctx->cells) {
+ for (auto cell : sorted(ctx->cells)) {
CellInfo *ci = cell.second;
if (is_nextpnr_iob(ctx, ci)) {
CellInfo *sb = nullptr;
@@ -412,8 +413,8 @@ static void promote_globals(Context *ctx)
{
log_info("Promoting globals..\n");
- std::unordered_map<IdString, int> clock_count, reset_count, cen_count;
- for (auto net : ctx->nets) {
+ std::map<IdString, int> clock_count, reset_count, cen_count;
+ for (auto net : sorted(ctx->nets)) {
NetInfo *ni = net.second;
if (ni->driver.cell != nullptr && !is_global_net(ctx, ni)) {
clock_count[net.first] = 0;