From 22e4081c73ab7eec3c9f0841fcb1f247a85b5265 Mon Sep 17 00:00:00 2001 From: YRabbit Date: Sat, 29 Jan 2022 14:45:17 +1000 Subject: 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 --- gui/gowin/mainwindow.cc | 60 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 3 deletions(-) (limited to 'gui/gowin/mainwindow.cc') 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 #include #include +#include "cst.h" + static void initMainResource() { Q_INIT_RESOURCE(nextpnr); } NEXTPNR_NAMESPACE_BEGIN @@ -30,8 +33,10 @@ MainWindow::MainWindow(std::unique_ptr 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 -- cgit v1.2.3