diff options
author | YRabbit <rabbit@yrabbit.cyou> | 2022-01-29 14:45:17 +1000 |
---|---|---|
committer | YRabbit <rabbit@yrabbit.cyou> | 2022-01-29 14:45:17 +1000 |
commit | 22e4081c73ab7eec3c9f0841fcb1f247a85b5265 (patch) | |
tree | a6356121c9ea35e6221a42ed5e67c260f280f4ad /gui/gowin/mainwindow.cc | |
parent | e069b3bc6ab4d504e84ef62086d2bb9e5144717b (diff) | |
download | nextpnr-22e4081c73ab7eec3c9f0841fcb1f247a85b5265.tar.gz nextpnr-22e4081c73ab7eec3c9f0841fcb1f247a85b5265.tar.bz2 nextpnr-22e4081c73ab7eec3c9f0841fcb1f247a85b5265.zip |
gowin: Add GUI.
* Items such as LUT, DFF, MUX, ALU, IOB are displayed;
* Local wires, 1-2-4-8 wires are displayed;
* The clock spines, taps and branches are displayed with some caveats.
For now, you can not create a project in the GUI because of possible
conflict with another PR (about GW1NR-9C support), but you can specify
the board in the command line and load .JSON and .CST in the GUI.
Although ALUs are displayed, but the CIN and COUT wires are not. This is
still an unsolved problem.
Signed-off-by: YRabbit <rabbit@yrabbit.cyou>
Diffstat (limited to 'gui/gowin/mainwindow.cc')
-rw-r--r-- | gui/gowin/mainwindow.cc | 60 |
1 files changed, 57 insertions, 3 deletions
diff --git a/gui/gowin/mainwindow.cc b/gui/gowin/mainwindow.cc index 9dafcef5..c7ba44ab 100644 --- a/gui/gowin/mainwindow.cc +++ b/gui/gowin/mainwindow.cc @@ -19,9 +19,12 @@ #include "mainwindow.h"
+#include <QFileDialog>
#include <QMessageBox>
#include <cstdlib>
+#include "cst.h"
+
static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
NEXTPNR_NAMESPACE_BEGIN
@@ -30,8 +33,10 @@ MainWindow::MainWindow(std::unique_ptr<Context> context, CommandHandler *handler : BaseMainWindow(std::move(context), handler, parent)
{
initMainResource();
- QMessageBox::critical(0, "Error - FIXME", "No GUI support for nextpnr-gowin");
- std::exit(1);
+ std::string title = "nextpnr-gowin - [EMPTY]";
+ setWindowTitle(title.c_str());
+ connect(this, &BaseMainWindow::contextChanged, this, &MainWindow::newContext);
+ createMenu();
}
MainWindow::~MainWindow() {}
@@ -42,8 +47,57 @@ void MainWindow::newContext(Context *ctx) setWindowTitle(title.c_str());
}
-void MainWindow::createMenu() {}
+void MainWindow::load_cst(std::string filename)
+{
+ disableActions();
+ std::ifstream f(filename);
+ if (read_cst(ctx.get(), f)) {
+ log("Loading CST successful.\n");
+ actionPack->setEnabled(true);
+ } else {
+ actionLoadCST->setEnabled(true);
+ log("Loading CST failed.\n");
+ }
+}
+
+void MainWindow::createMenu()
+{
+ actionLoadCST = new QAction("Open CST", this);
+ actionLoadCST->setIcon(QIcon(":/icons/resources/open_cst.png"));
+ actionLoadCST->setStatusTip("Open CST file");
+ actionLoadCST->setEnabled(false);
+ connect(actionLoadCST, &QAction::triggered, this, &MainWindow::open_cst);
+
+ // Add actions in menus
+ mainActionBar->addSeparator();
+ mainActionBar->addAction(actionLoadCST);
+
+ menuDesign->addSeparator();
+ menuDesign->addAction(actionLoadCST);
+}
void MainWindow::new_proj() {}
+void MainWindow::open_cst()
+{
+ QString fileName = QFileDialog::getOpenFileName(this, QString("Open CST"), QString(), QString("*.cst"));
+ if (!fileName.isEmpty()) {
+ load_cst(fileName.toStdString());
+ }
+}
+
+void MainWindow::onDisableActions() { actionLoadCST->setEnabled(false); }
+
+void MainWindow::onUpdateActions()
+{
+ if (ctx->settings.find(ctx->id("synth")) != ctx->settings.end()) {
+ actionLoadCST->setEnabled(true);
+ }
+ if (ctx->settings.find(ctx->id("cst")) != ctx->settings.end()) {
+ actionLoadCST->setEnabled(false);
+ }
+ if (ctx->settings.find(ctx->id("pack")) != ctx->settings.end()) {
+ actionLoadCST->setEnabled(false);
+ }
+}
NEXTPNR_NAMESPACE_END
|