Merge branch 'master' of gitlab.com:SymbioticEDA/nextpnr
This commit is contained in:
commit
417e67938c
@ -3,28 +3,22 @@
|
||||
#include <QGridLayout>
|
||||
#include <QIcon>
|
||||
#include <QSplitter>
|
||||
#include <fstream>
|
||||
#include "designwidget.h"
|
||||
#include "fpgaviewwidget.h"
|
||||
#include "jsonparse.h"
|
||||
#include "log.h"
|
||||
#include "mainwindow.h"
|
||||
#include "pythontab.h"
|
||||
//#include "pack.h"
|
||||
//#include "pcf.h"
|
||||
#include "place_sa.h"
|
||||
#include "route.h"
|
||||
//#include "bitstream.h"
|
||||
#include "design_utils.h"
|
||||
|
||||
|
||||
BaseMainWindow::BaseMainWindow(Context *_ctx, QWidget *parent)
|
||||
: QMainWindow(parent), ctx(_ctx)
|
||||
{
|
||||
Q_INIT_RESOURCE(nextpnr);
|
||||
qRegisterMetaType<std::string>();
|
||||
|
||||
log_files.clear();
|
||||
log_streams.clear();
|
||||
log_write_function = [this](std::string text) { info->info(text); };
|
||||
|
||||
setObjectName(QStringLiteral("BaseMainWindow"));
|
||||
resize(1024, 768);
|
||||
@ -57,7 +51,11 @@ BaseMainWindow::BaseMainWindow(Context *_ctx, QWidget *parent)
|
||||
tabWidget->addTab(new PythonTab(), "Python");
|
||||
info = new InfoTab();
|
||||
tabWidget->addTab(info, "Info");
|
||||
splitter_v->addWidget(new FPGAViewWidget());
|
||||
|
||||
centralTabWidget = new QTabWidget();
|
||||
centralTabWidget->addTab(new FPGAViewWidget(), "Graphics");
|
||||
|
||||
splitter_v->addWidget(centralTabWidget);
|
||||
splitter_v->addWidget(tabWidget);
|
||||
}
|
||||
|
||||
@ -117,22 +115,3 @@ void BaseMainWindow::createMenusAndBars()
|
||||
mainToolBar->addAction(actionOpen);
|
||||
mainToolBar->addAction(actionSave);
|
||||
}
|
||||
|
||||
void BaseMainWindow::open()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, QString(), QString(),
|
||||
QString("*.json"));
|
||||
if (!fileName.isEmpty()) {
|
||||
tabWidget->setCurrentWidget(info);
|
||||
|
||||
std::string fn = fileName.toStdString();
|
||||
std::istream *f = new std::ifstream(fn);
|
||||
|
||||
parse_json_file(f, fn, ctx);
|
||||
|
||||
// pack_design(ctx);
|
||||
print_utilisation(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
bool BaseMainWindow::save() { return false; }
|
||||
|
@ -14,13 +14,15 @@
|
||||
// FIXME
|
||||
USING_NEXTPNR_NAMESPACE
|
||||
|
||||
Q_DECLARE_METATYPE(std::string)
|
||||
|
||||
class BaseMainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BaseMainWindow(Context *ctx, QWidget *parent = 0);
|
||||
~BaseMainWindow();
|
||||
virtual ~BaseMainWindow();
|
||||
Context *getContext() { return ctx; }
|
||||
|
||||
protected:
|
||||
@ -28,12 +30,14 @@ class BaseMainWindow : public QMainWindow
|
||||
|
||||
protected Q_SLOTS:
|
||||
void writeInfo(std::string text);
|
||||
void open();
|
||||
bool save();
|
||||
|
||||
virtual void open() = 0;
|
||||
virtual bool save() = 0;
|
||||
|
||||
protected:
|
||||
Context *ctx;
|
||||
QTabWidget *tabWidget;
|
||||
QTabWidget *centralTabWidget;
|
||||
InfoTab *info;
|
||||
|
||||
QMenuBar *menuBar;
|
||||
|
@ -16,3 +16,12 @@ void MainWindow::createMenu()
|
||||
QMenu *menu_Custom = new QMenu("&Dummy", menuBar);
|
||||
menuBar->addAction(menu_Custom->menuAction());
|
||||
}
|
||||
|
||||
void MainWindow::open()
|
||||
{
|
||||
}
|
||||
|
||||
bool MainWindow::save()
|
||||
{
|
||||
return false;
|
||||
}
|
@ -12,10 +12,14 @@ class MainWindow : public BaseMainWindow
|
||||
|
||||
public:
|
||||
explicit MainWindow(Context *ctx, QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
virtual ~MainWindow();
|
||||
|
||||
public:
|
||||
void createMenu();
|
||||
|
||||
protected Q_SLOTS:
|
||||
virtual void open();
|
||||
virtual bool save();
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "mainwindow.h"
|
||||
#include <QAction>
|
||||
#include <QFileDialog>
|
||||
#include <QIcon>
|
||||
#include "bitstream.h"
|
||||
#include "design_utils.h"
|
||||
@ -17,6 +18,10 @@ MainWindow::MainWindow(Context *_ctx, QWidget *parent)
|
||||
setWindowTitle(title.c_str());
|
||||
|
||||
createMenu();
|
||||
|
||||
task = new TaskManager(_ctx);
|
||||
connect(task, SIGNAL(log(std::string)), this,
|
||||
SLOT(writeInfo(std::string)));
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {}
|
||||
@ -26,3 +31,19 @@ void MainWindow::createMenu()
|
||||
QMenu *menu_Custom = new QMenu("&ICE 40", menuBar);
|
||||
menuBar->addAction(menu_Custom->menuAction());
|
||||
}
|
||||
|
||||
void MainWindow::open()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, QString(), QString(),
|
||||
QString("*.json"));
|
||||
if (!fileName.isEmpty()) {
|
||||
tabWidget->setCurrentWidget(info);
|
||||
|
||||
std::string fn = fileName.toStdString();
|
||||
task->parsejson(fn);
|
||||
}
|
||||
}
|
||||
bool MainWindow::save()
|
||||
{
|
||||
return false;
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include "../basewindow.h"
|
||||
#include "worker.h"
|
||||
|
||||
// FIXME
|
||||
USING_NEXTPNR_NAMESPACE
|
||||
@ -12,10 +13,17 @@ class MainWindow : public BaseMainWindow
|
||||
|
||||
public:
|
||||
explicit MainWindow(Context *ctx, QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
virtual ~MainWindow();
|
||||
|
||||
public:
|
||||
void createMenu();
|
||||
|
||||
protected Q_SLOTS:
|
||||
virtual void open();
|
||||
virtual bool save();
|
||||
|
||||
private:
|
||||
TaskManager *task;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
58
gui/ice40/worker.cc
Normal file
58
gui/ice40/worker.cc
Normal file
@ -0,0 +1,58 @@
|
||||
#include "worker.h"
|
||||
#include <fstream>
|
||||
#include "jsonparse.h"
|
||||
#include "log.h"
|
||||
#include "pack.h"
|
||||
#include "pcf.h"
|
||||
#include "place_sa.h"
|
||||
#include "route.h"
|
||||
#include "bitstream.h"
|
||||
#include "design_utils.h"
|
||||
#include "timing.h"
|
||||
|
||||
Worker::Worker(Context *_ctx) : ctx(_ctx)
|
||||
{
|
||||
log_write_function = [this](std::string text) { Q_EMIT log(text); };
|
||||
}
|
||||
|
||||
void Worker::parsejson(const std::string &filename)
|
||||
{
|
||||
std::string fn = filename;
|
||||
std::istream *f = new std::ifstream(fn);
|
||||
|
||||
parse_json_file(f, fn, ctx);
|
||||
if (!pack_design(ctx))
|
||||
log_error("Packing design failed.\n");
|
||||
double freq = 50e6;
|
||||
assign_budget(ctx, freq);
|
||||
print_utilisation(ctx);
|
||||
|
||||
if (!place_design_sa(ctx))
|
||||
log_error("Placing design failed.\n");
|
||||
if (!route_design(ctx))
|
||||
log_error("Routing design failed.\n");
|
||||
print_utilisation(ctx);
|
||||
Q_EMIT log("done");
|
||||
}
|
||||
|
||||
|
||||
TaskManager::TaskManager(Context *ctx)
|
||||
{
|
||||
Worker *worker = new Worker(ctx);
|
||||
worker->moveToThread(&workerThread);
|
||||
connect(&workerThread, &QThread::finished, worker, &QObject::deleteLater);
|
||||
connect(this, &TaskManager::parsejson, worker, &Worker::parsejson);
|
||||
connect(worker, &Worker::log, this, &TaskManager::info);
|
||||
workerThread.start();
|
||||
}
|
||||
|
||||
TaskManager::~TaskManager()
|
||||
{
|
||||
workerThread.quit();
|
||||
workerThread.wait();
|
||||
}
|
||||
|
||||
void TaskManager::info(const std::string &result)
|
||||
{
|
||||
Q_EMIT log(result);
|
||||
}
|
37
gui/ice40/worker.h
Normal file
37
gui/ice40/worker.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef WORKER_H
|
||||
#define WORKER_H
|
||||
|
||||
#include "nextpnr.h"
|
||||
#include <QThread>
|
||||
|
||||
// FIXME
|
||||
USING_NEXTPNR_NAMESPACE
|
||||
|
||||
class Worker : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Worker(Context *ctx);
|
||||
public Q_SLOTS:
|
||||
void parsejson(const std::string &filename);
|
||||
Q_SIGNALS:
|
||||
void log(const std::string &text);
|
||||
private:
|
||||
Context *ctx;
|
||||
};
|
||||
|
||||
class TaskManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
QThread workerThread;
|
||||
public:
|
||||
TaskManager(Context *ctx);
|
||||
~TaskManager();
|
||||
public Q_SLOTS:
|
||||
void info(const std::string &text);
|
||||
Q_SIGNALS:
|
||||
void parsejson(const std::string &);
|
||||
void log(const std::string &text);
|
||||
};
|
||||
|
||||
#endif // WORKER_H
|
Loading…
Reference in New Issue
Block a user