CRLF -> LF eol
This commit is contained in:
parent
ec60542ffd
commit
e3f4578b3b
1094
gui/basewindow.cc
1094
gui/basewindow.cc
File diff suppressed because it is too large
Load Diff
284
gui/basewindow.h
284
gui/basewindow.h
@ -1,142 +1,142 @@
|
|||||||
/*
|
/*
|
||||||
* nextpnr -- Next Generation Place and Route
|
* nextpnr -- Next Generation Place and Route
|
||||||
*
|
*
|
||||||
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* copyright notice and this permission notice appear in all copies.
|
* copyright notice and this permission notice appear in all copies.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BASEMAINWINDOW_H
|
#ifndef BASEMAINWINDOW_H
|
||||||
#define BASEMAINWINDOW_H
|
#define BASEMAINWINDOW_H
|
||||||
|
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
#include "nextpnr.h"
|
#include "nextpnr.h"
|
||||||
#include "worker.h"
|
#include "worker.h"
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
#include <QProgressBar>
|
#include <QProgressBar>
|
||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
#include <QTabWidget>
|
#include <QTabWidget>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(std::string)
|
Q_DECLARE_METATYPE(std::string)
|
||||||
Q_DECLARE_METATYPE(NEXTPNR_NAMESPACE_PREFIX DecalXY)
|
Q_DECLARE_METATYPE(NEXTPNR_NAMESPACE_PREFIX DecalXY)
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
class PythonTab;
|
class PythonTab;
|
||||||
class DesignWidget;
|
class DesignWidget;
|
||||||
class FPGAViewWidget;
|
class FPGAViewWidget;
|
||||||
|
|
||||||
class BaseMainWindow : public QMainWindow
|
class BaseMainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BaseMainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent = 0);
|
explicit BaseMainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent = 0);
|
||||||
virtual ~BaseMainWindow();
|
virtual ~BaseMainWindow();
|
||||||
Context *getContext() { return ctx.get(); }
|
Context *getContext() { return ctx.get(); }
|
||||||
void updateActions();
|
void updateActions();
|
||||||
|
|
||||||
void notifyChangeContext();
|
void notifyChangeContext();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void createMenusAndBars();
|
void createMenusAndBars();
|
||||||
void disableActions();
|
void disableActions();
|
||||||
void enableDisableDecals();
|
void enableDisableDecals();
|
||||||
|
|
||||||
virtual void onDisableActions(){};
|
virtual void onDisableActions(){};
|
||||||
virtual void onUpdateActions(){};
|
virtual void onUpdateActions(){};
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
void writeInfo(std::string text);
|
void writeInfo(std::string text);
|
||||||
void closeTab(int index);
|
void closeTab(int index);
|
||||||
|
|
||||||
virtual void new_proj() = 0;
|
virtual void new_proj() = 0;
|
||||||
|
|
||||||
void open_json();
|
void open_json();
|
||||||
void save_json();
|
void save_json();
|
||||||
void place();
|
void place();
|
||||||
|
|
||||||
void execute_python();
|
void execute_python();
|
||||||
|
|
||||||
void pack_finished(bool status);
|
void pack_finished(bool status);
|
||||||
void place_finished(bool status);
|
void place_finished(bool status);
|
||||||
void route_finished(bool status);
|
void route_finished(bool status);
|
||||||
|
|
||||||
void taskCanceled();
|
void taskCanceled();
|
||||||
void taskStarted();
|
void taskStarted();
|
||||||
void taskPaused();
|
void taskPaused();
|
||||||
|
|
||||||
void screenshot();
|
void screenshot();
|
||||||
void saveMovie();
|
void saveMovie();
|
||||||
void saveSVG();
|
void saveSVG();
|
||||||
|
|
||||||
void about();
|
void about();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void contextChanged(Context *ctx);
|
void contextChanged(Context *ctx);
|
||||||
void updateTreeView();
|
void updateTreeView();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// state variables
|
// state variables
|
||||||
CommandHandler *handler;
|
CommandHandler *handler;
|
||||||
std::unique_ptr<Context> ctx;
|
std::unique_ptr<Context> ctx;
|
||||||
TaskManager *task;
|
TaskManager *task;
|
||||||
bool timing_driven;
|
bool timing_driven;
|
||||||
std::string currentProj;
|
std::string currentProj;
|
||||||
|
|
||||||
// main widgets
|
// main widgets
|
||||||
QTabWidget *tabWidget;
|
QTabWidget *tabWidget;
|
||||||
QTabWidget *centralTabWidget;
|
QTabWidget *centralTabWidget;
|
||||||
PythonTab *console;
|
PythonTab *console;
|
||||||
DesignWidget *designview;
|
DesignWidget *designview;
|
||||||
FPGAViewWidget *fpgaView;
|
FPGAViewWidget *fpgaView;
|
||||||
|
|
||||||
// Menus, bars and actions
|
// Menus, bars and actions
|
||||||
QMenuBar *menuBar;
|
QMenuBar *menuBar;
|
||||||
QMenu *menuDesign;
|
QMenu *menuDesign;
|
||||||
QStatusBar *statusBar;
|
QStatusBar *statusBar;
|
||||||
QToolBar *mainActionBar;
|
QToolBar *mainActionBar;
|
||||||
QProgressBar *progressBar;
|
QProgressBar *progressBar;
|
||||||
|
|
||||||
QAction *actionNew;
|
QAction *actionNew;
|
||||||
QAction *actionLoadJSON;
|
QAction *actionLoadJSON;
|
||||||
QAction *actionSaveJSON;
|
QAction *actionSaveJSON;
|
||||||
|
|
||||||
QAction *actionPack;
|
QAction *actionPack;
|
||||||
QAction *actionPlace;
|
QAction *actionPlace;
|
||||||
QAction *actionRoute;
|
QAction *actionRoute;
|
||||||
|
|
||||||
QAction *actionExecutePy;
|
QAction *actionExecutePy;
|
||||||
|
|
||||||
QAction *actionPlay;
|
QAction *actionPlay;
|
||||||
QAction *actionPause;
|
QAction *actionPause;
|
||||||
QAction *actionStop;
|
QAction *actionStop;
|
||||||
|
|
||||||
QAction *actionDisplayBel;
|
QAction *actionDisplayBel;
|
||||||
QAction *actionDisplayWire;
|
QAction *actionDisplayWire;
|
||||||
QAction *actionDisplayPip;
|
QAction *actionDisplayPip;
|
||||||
QAction *actionDisplayGroups;
|
QAction *actionDisplayGroups;
|
||||||
|
|
||||||
QAction *actionScreenshot;
|
QAction *actionScreenshot;
|
||||||
QAction *actionMovie;
|
QAction *actionMovie;
|
||||||
QAction *actionSaveSVG;
|
QAction *actionSaveSVG;
|
||||||
};
|
};
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
|
||||||
#endif // BASEMAINWINDOW_H
|
#endif // BASEMAINWINDOW_H
|
||||||
|
2144
gui/designwidget.cc
2144
gui/designwidget.cc
File diff suppressed because it is too large
Load Diff
@ -1,138 +1,138 @@
|
|||||||
/*
|
/*
|
||||||
* nextpnr -- Next Generation Place and Route
|
* nextpnr -- Next Generation Place and Route
|
||||||
*
|
*
|
||||||
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* copyright notice and this permission notice appear in all copies.
|
* copyright notice and this permission notice appear in all copies.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef DESIGNWIDGET_H
|
#ifndef DESIGNWIDGET_H
|
||||||
#define DESIGNWIDGET_H
|
#define DESIGNWIDGET_H
|
||||||
|
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QTabWidget>
|
#include <QTabWidget>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include "nextpnr.h"
|
#include "nextpnr.h"
|
||||||
#include "qtgroupboxpropertybrowser.h"
|
#include "qtgroupboxpropertybrowser.h"
|
||||||
#include "qtpropertymanager.h"
|
#include "qtpropertymanager.h"
|
||||||
#include "qttreepropertybrowser.h"
|
#include "qttreepropertybrowser.h"
|
||||||
#include "qtvariantproperty.h"
|
#include "qtvariantproperty.h"
|
||||||
#include "treemodel.h"
|
#include "treemodel.h"
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
class TreeView : public QTreeView
|
class TreeView : public QTreeView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TreeView(QWidget *parent = 0);
|
explicit TreeView(QWidget *parent = 0);
|
||||||
~TreeView();
|
~TreeView();
|
||||||
void mouseMoveEvent(QMouseEvent *event) override;
|
void mouseMoveEvent(QMouseEvent *event) override;
|
||||||
void leaveEvent(QEvent *event) override;
|
void leaveEvent(QEvent *event) override;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void hoverIndexChanged(QModelIndex index);
|
void hoverIndexChanged(QModelIndex index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QModelIndex current;
|
QModelIndex current;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DesignWidget : public QWidget
|
class DesignWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DesignWidget(QWidget *parent = 0);
|
explicit DesignWidget(QWidget *parent = 0);
|
||||||
~DesignWidget();
|
~DesignWidget();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void clearProperties();
|
void clearProperties();
|
||||||
QtProperty *addTopLevelProperty(const QString &id);
|
QtProperty *addTopLevelProperty(const QString &id);
|
||||||
QtProperty *addSubGroup(QtProperty *topItem, const QString &name);
|
QtProperty *addSubGroup(QtProperty *topItem, const QString &name);
|
||||||
void addProperty(QtProperty *topItem, int propertyType, const QString &name, QVariant value,
|
void addProperty(QtProperty *topItem, int propertyType, const QString &name, QVariant value,
|
||||||
const ElementType &type = ElementType::NONE);
|
const ElementType &type = ElementType::NONE);
|
||||||
QString getElementTypeName(ElementType type);
|
QString getElementTypeName(ElementType type);
|
||||||
ElementType getElementTypeByName(QString type);
|
ElementType getElementTypeByName(QString type);
|
||||||
TreeModel::Model *getTreeByElementType(ElementType type);
|
TreeModel::Model *getTreeByElementType(ElementType type);
|
||||||
int getIndexByElementType(ElementType type);
|
int getIndexByElementType(ElementType type);
|
||||||
int getElementIndex(ElementType type);
|
int getElementIndex(ElementType type);
|
||||||
void updateButtons();
|
void updateButtons();
|
||||||
void addToHistory(int tab, QModelIndex item);
|
void addToHistory(int tab, QModelIndex item);
|
||||||
std::vector<DecalXY> getDecals(ElementType type, IdStringList value);
|
std::vector<DecalXY> getDecals(ElementType type, IdStringList value);
|
||||||
void updateHighlightGroup(QList<TreeModel::Item *> item, int group);
|
void updateHighlightGroup(QList<TreeModel::Item *> item, int group);
|
||||||
void clearAllSelectionModels();
|
void clearAllSelectionModels();
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void selected(std::vector<DecalXY> decal, bool keep);
|
void selected(std::vector<DecalXY> decal, bool keep);
|
||||||
void highlight(std::vector<DecalXY> decal, int group);
|
void highlight(std::vector<DecalXY> decal, int group);
|
||||||
void hover(DecalXY decal);
|
void hover(DecalXY decal);
|
||||||
void zoomSelected();
|
void zoomSelected();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void prepareMenuProperty(const QPoint &pos);
|
void prepareMenuProperty(const QPoint &pos);
|
||||||
void prepareMenuTree(int num, const QPoint &pos);
|
void prepareMenuTree(int num, const QPoint &pos);
|
||||||
void onSelectionChanged(int num, const QItemSelection &selected, const QItemSelection &deselected);
|
void onSelectionChanged(int num, const QItemSelection &selected, const QItemSelection &deselected);
|
||||||
void onItemDoubleClicked(QTreeWidgetItem *item, int column);
|
void onItemDoubleClicked(QTreeWidgetItem *item, int column);
|
||||||
void onDoubleClicked(const QModelIndex &index);
|
void onDoubleClicked(const QModelIndex &index);
|
||||||
void onSearchInserted();
|
void onSearchInserted();
|
||||||
void onHoverIndexChanged(int num, QModelIndex index);
|
void onHoverIndexChanged(int num, QModelIndex index);
|
||||||
void onHoverPropertyChanged(QtBrowserItem *item);
|
void onHoverPropertyChanged(QtBrowserItem *item);
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void newContext(Context *ctx);
|
void newContext(Context *ctx);
|
||||||
void updateTree();
|
void updateTree();
|
||||||
void onClickedBel(BelId bel, bool keep);
|
void onClickedBel(BelId bel, bool keep);
|
||||||
void onClickedWire(WireId wire, bool keep);
|
void onClickedWire(WireId wire, bool keep);
|
||||||
void onClickedPip(PipId pip, bool keep);
|
void onClickedPip(PipId pip, bool keep);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Context *ctx;
|
Context *ctx;
|
||||||
|
|
||||||
QTabWidget *tabWidget;
|
QTabWidget *tabWidget;
|
||||||
|
|
||||||
TreeView *treeView[6];
|
TreeView *treeView[6];
|
||||||
QItemSelectionModel *selectionModel[6];
|
QItemSelectionModel *selectionModel[6];
|
||||||
TreeModel::Model *treeModel[6];
|
TreeModel::Model *treeModel[6];
|
||||||
QLineEdit *searchEdit;
|
QLineEdit *searchEdit;
|
||||||
QtVariantPropertyManager *variantManager;
|
QtVariantPropertyManager *variantManager;
|
||||||
QtVariantPropertyManager *readOnlyManager;
|
QtVariantPropertyManager *readOnlyManager;
|
||||||
QtGroupPropertyManager *groupManager;
|
QtGroupPropertyManager *groupManager;
|
||||||
QtVariantEditorFactory *variantFactory;
|
QtVariantEditorFactory *variantFactory;
|
||||||
QtTreePropertyBrowser *propertyEditor;
|
QtTreePropertyBrowser *propertyEditor;
|
||||||
|
|
||||||
QMap<QtProperty *, QString> propertyToId;
|
QMap<QtProperty *, QString> propertyToId;
|
||||||
QMap<QString, QtProperty *> idToProperty;
|
QMap<QString, QtProperty *> idToProperty;
|
||||||
|
|
||||||
std::vector<std::pair<int, QModelIndex>> history;
|
std::vector<std::pair<int, QModelIndex>> history;
|
||||||
int history_index;
|
int history_index;
|
||||||
bool history_ignore;
|
bool history_ignore;
|
||||||
|
|
||||||
QAction *actionFirst;
|
QAction *actionFirst;
|
||||||
QAction *actionPrev;
|
QAction *actionPrev;
|
||||||
QAction *actionNext;
|
QAction *actionNext;
|
||||||
QAction *actionLast;
|
QAction *actionLast;
|
||||||
QAction *actionClear;
|
QAction *actionClear;
|
||||||
|
|
||||||
QColor highlightColors[8];
|
QColor highlightColors[8];
|
||||||
QMap<TreeModel::Item *, int> highlightSelected;
|
QMap<TreeModel::Item *, int> highlightSelected;
|
||||||
|
|
||||||
QString currentSearch;
|
QString currentSearch;
|
||||||
QList<QModelIndex> currentSearchIndexes;
|
QList<QModelIndex> currentSearchIndexes;
|
||||||
int currentIndex;
|
int currentIndex;
|
||||||
int currentIndexTab;
|
int currentIndexTab;
|
||||||
};
|
};
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
|
||||||
#endif // DESIGNWIDGET_H
|
#endif // DESIGNWIDGET_H
|
||||||
|
@ -1,166 +1,166 @@
|
|||||||
/*
|
/*
|
||||||
* nextpnr -- Next Generation Place and Route
|
* nextpnr -- Next Generation Place and Route
|
||||||
*
|
*
|
||||||
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* copyright notice and this permission notice appear in all copies.
|
* copyright notice and this permission notice appear in all copies.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include "bitstream.h"
|
#include "bitstream.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
|
||||||
static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
|
static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
MainWindow::MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent)
|
MainWindow::MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent)
|
||||||
: BaseMainWindow(std::move(context), handler, parent)
|
: BaseMainWindow(std::move(context), handler, parent)
|
||||||
{
|
{
|
||||||
initMainResource();
|
initMainResource();
|
||||||
|
|
||||||
std::string title = "nextpnr-ecp5 - [EMPTY]";
|
std::string title = "nextpnr-ecp5 - [EMPTY]";
|
||||||
setWindowTitle(title.c_str());
|
setWindowTitle(title.c_str());
|
||||||
|
|
||||||
connect(this, &BaseMainWindow::contextChanged, this, &MainWindow::newContext);
|
connect(this, &BaseMainWindow::contextChanged, this, &MainWindow::newContext);
|
||||||
|
|
||||||
createMenu();
|
createMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow() {}
|
MainWindow::~MainWindow() {}
|
||||||
|
|
||||||
void MainWindow::newContext(Context *ctx)
|
void MainWindow::newContext(Context *ctx)
|
||||||
{
|
{
|
||||||
std::string title = "nextpnr-ecp5 - " + ctx->getChipName() + " ( " + ctx->archArgs().package + " )";
|
std::string title = "nextpnr-ecp5 - " + ctx->getChipName() + " ( " + ctx->archArgs().package + " )";
|
||||||
setWindowTitle(title.c_str());
|
setWindowTitle(title.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::createMenu()
|
void MainWindow::createMenu()
|
||||||
{
|
{
|
||||||
// Add arch specific actions
|
// Add arch specific actions
|
||||||
actionLoadLPF = new QAction("Open LPF", this);
|
actionLoadLPF = new QAction("Open LPF", this);
|
||||||
actionLoadLPF->setIcon(QIcon(":/icons/resources/open_lpf.png"));
|
actionLoadLPF->setIcon(QIcon(":/icons/resources/open_lpf.png"));
|
||||||
actionLoadLPF->setStatusTip("Open LPF file");
|
actionLoadLPF->setStatusTip("Open LPF file");
|
||||||
actionLoadLPF->setEnabled(false);
|
actionLoadLPF->setEnabled(false);
|
||||||
connect(actionLoadLPF, &QAction::triggered, this, &MainWindow::open_lpf);
|
connect(actionLoadLPF, &QAction::triggered, this, &MainWindow::open_lpf);
|
||||||
|
|
||||||
actionSaveConfig = new QAction("Save Bitstream", this);
|
actionSaveConfig = new QAction("Save Bitstream", this);
|
||||||
actionSaveConfig->setIcon(QIcon(":/icons/resources/save_config.png"));
|
actionSaveConfig->setIcon(QIcon(":/icons/resources/save_config.png"));
|
||||||
actionSaveConfig->setStatusTip("Save Bitstream config file");
|
actionSaveConfig->setStatusTip("Save Bitstream config file");
|
||||||
actionSaveConfig->setEnabled(false);
|
actionSaveConfig->setEnabled(false);
|
||||||
connect(actionSaveConfig, &QAction::triggered, this, &MainWindow::save_config);
|
connect(actionSaveConfig, &QAction::triggered, this, &MainWindow::save_config);
|
||||||
|
|
||||||
// Add actions in menus
|
// Add actions in menus
|
||||||
mainActionBar->addSeparator();
|
mainActionBar->addSeparator();
|
||||||
mainActionBar->addAction(actionLoadLPF);
|
mainActionBar->addAction(actionLoadLPF);
|
||||||
mainActionBar->addAction(actionSaveConfig);
|
mainActionBar->addAction(actionSaveConfig);
|
||||||
|
|
||||||
menuDesign->addSeparator();
|
menuDesign->addSeparator();
|
||||||
menuDesign->addAction(actionLoadLPF);
|
menuDesign->addAction(actionLoadLPF);
|
||||||
menuDesign->addAction(actionSaveConfig);
|
menuDesign->addAction(actionSaveConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::new_proj()
|
void MainWindow::new_proj()
|
||||||
{
|
{
|
||||||
QMap<QString, int> arch;
|
QMap<QString, int> arch;
|
||||||
if (Arch::is_available(ArchArgs::LFE5U_25F))
|
if (Arch::is_available(ArchArgs::LFE5U_25F))
|
||||||
arch.insert("Lattice ECP5 LFE5U-25F", ArchArgs::LFE5U_25F);
|
arch.insert("Lattice ECP5 LFE5U-25F", ArchArgs::LFE5U_25F);
|
||||||
if (Arch::is_available(ArchArgs::LFE5U_45F))
|
if (Arch::is_available(ArchArgs::LFE5U_45F))
|
||||||
arch.insert("Lattice ECP5 LFE5U-45F", ArchArgs::LFE5U_45F);
|
arch.insert("Lattice ECP5 LFE5U-45F", ArchArgs::LFE5U_45F);
|
||||||
if (Arch::is_available(ArchArgs::LFE5U_85F))
|
if (Arch::is_available(ArchArgs::LFE5U_85F))
|
||||||
arch.insert("Lattice ECP5 LFE5U-85F", ArchArgs::LFE5U_85F);
|
arch.insert("Lattice ECP5 LFE5U-85F", ArchArgs::LFE5U_85F);
|
||||||
if (Arch::is_available(ArchArgs::LFE5UM_25F))
|
if (Arch::is_available(ArchArgs::LFE5UM_25F))
|
||||||
arch.insert("Lattice ECP5 LFE5UM-25F", ArchArgs::LFE5UM_25F);
|
arch.insert("Lattice ECP5 LFE5UM-25F", ArchArgs::LFE5UM_25F);
|
||||||
if (Arch::is_available(ArchArgs::LFE5UM_45F))
|
if (Arch::is_available(ArchArgs::LFE5UM_45F))
|
||||||
arch.insert("Lattice ECP5 LFE5UM-45F", ArchArgs::LFE5UM_45F);
|
arch.insert("Lattice ECP5 LFE5UM-45F", ArchArgs::LFE5UM_45F);
|
||||||
if (Arch::is_available(ArchArgs::LFE5UM_85F))
|
if (Arch::is_available(ArchArgs::LFE5UM_85F))
|
||||||
arch.insert("Lattice ECP5 LFE5UM-85F", ArchArgs::LFE5UM_85F);
|
arch.insert("Lattice ECP5 LFE5UM-85F", ArchArgs::LFE5UM_85F);
|
||||||
if (Arch::is_available(ArchArgs::LFE5UM5G_25F))
|
if (Arch::is_available(ArchArgs::LFE5UM5G_25F))
|
||||||
arch.insert("Lattice ECP5 LFE5UM5G-25F", ArchArgs::LFE5UM5G_25F);
|
arch.insert("Lattice ECP5 LFE5UM5G-25F", ArchArgs::LFE5UM5G_25F);
|
||||||
if (Arch::is_available(ArchArgs::LFE5UM5G_45F))
|
if (Arch::is_available(ArchArgs::LFE5UM5G_45F))
|
||||||
arch.insert("Lattice ECP5 LFE5UM5G-45F", ArchArgs::LFE5UM5G_45F);
|
arch.insert("Lattice ECP5 LFE5UM5G-45F", ArchArgs::LFE5UM5G_45F);
|
||||||
if (Arch::is_available(ArchArgs::LFE5UM5G_85F))
|
if (Arch::is_available(ArchArgs::LFE5UM5G_85F))
|
||||||
arch.insert("Lattice ECP5 LFE5UM5G-85F", ArchArgs::LFE5UM5G_85F);
|
arch.insert("Lattice ECP5 LFE5UM5G-85F", ArchArgs::LFE5UM5G_85F);
|
||||||
|
|
||||||
bool ok;
|
bool ok;
|
||||||
QString item = QInputDialog::getItem(this, "Select new context", "Chip:", arch.keys(), 0, false, &ok);
|
QString item = QInputDialog::getItem(this, "Select new context", "Chip:", arch.keys(), 0, false, &ok);
|
||||||
if (ok && !item.isEmpty()) {
|
if (ok && !item.isEmpty()) {
|
||||||
ArchArgs chipArgs;
|
ArchArgs chipArgs;
|
||||||
chipArgs.type = (ArchArgs::ArchArgsTypes)arch.value(item);
|
chipArgs.type = (ArchArgs::ArchArgsTypes)arch.value(item);
|
||||||
|
|
||||||
QStringList packages;
|
QStringList packages;
|
||||||
for (auto package : Arch::get_supported_packages(chipArgs.type))
|
for (auto package : Arch::get_supported_packages(chipArgs.type))
|
||||||
packages.append(QLatin1String(package.data(), package.size()));
|
packages.append(QLatin1String(package.data(), package.size()));
|
||||||
QString package = QInputDialog::getItem(this, "Select package", "Package:", packages, 0, false, &ok);
|
QString package = QInputDialog::getItem(this, "Select package", "Package:", packages, 0, false, &ok);
|
||||||
|
|
||||||
if (ok && !item.isEmpty()) {
|
if (ok && !item.isEmpty()) {
|
||||||
handler->clear();
|
handler->clear();
|
||||||
currentProj = "";
|
currentProj = "";
|
||||||
disableActions();
|
disableActions();
|
||||||
chipArgs.package = package.toStdString().c_str();
|
chipArgs.package = package.toStdString().c_str();
|
||||||
ctx = std::unique_ptr<Context>(new Context(chipArgs));
|
ctx = std::unique_ptr<Context>(new Context(chipArgs));
|
||||||
actionLoadJSON->setEnabled(true);
|
actionLoadJSON->setEnabled(true);
|
||||||
|
|
||||||
Q_EMIT contextChanged(ctx.get());
|
Q_EMIT contextChanged(ctx.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::open_lpf()
|
void MainWindow::open_lpf()
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getOpenFileName(this, QString("Open LPF"), QString(), QString("*.lpf"));
|
QString fileName = QFileDialog::getOpenFileName(this, QString("Open LPF"), QString(), QString("*.lpf"));
|
||||||
if (!fileName.isEmpty()) {
|
if (!fileName.isEmpty()) {
|
||||||
std::ifstream in(fileName.toStdString());
|
std::ifstream in(fileName.toStdString());
|
||||||
if (ctx->apply_lpf(fileName.toStdString(), in)) {
|
if (ctx->apply_lpf(fileName.toStdString(), in)) {
|
||||||
log("Loading LPF successful.\n");
|
log("Loading LPF successful.\n");
|
||||||
actionPack->setEnabled(true);
|
actionPack->setEnabled(true);
|
||||||
actionLoadLPF->setEnabled(false);
|
actionLoadLPF->setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
actionLoadLPF->setEnabled(true);
|
actionLoadLPF->setEnabled(true);
|
||||||
log("Loading LPF failed.\n");
|
log("Loading LPF failed.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::save_config()
|
void MainWindow::save_config()
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getSaveFileName(this, QString("Save Bitstream"), QString(), QString("*.config"));
|
QString fileName = QFileDialog::getSaveFileName(this, QString("Save Bitstream"), QString(), QString("*.config"));
|
||||||
if (!fileName.isEmpty()) {
|
if (!fileName.isEmpty()) {
|
||||||
std::string fn = fileName.toStdString();
|
std::string fn = fileName.toStdString();
|
||||||
disableActions();
|
disableActions();
|
||||||
write_bitstream(ctx.get(), "", fileName.toStdString());
|
write_bitstream(ctx.get(), "", fileName.toStdString());
|
||||||
log("Saving Bitstream successful.\n");
|
log("Saving Bitstream successful.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onDisableActions()
|
void MainWindow::onDisableActions()
|
||||||
{
|
{
|
||||||
actionLoadLPF->setEnabled(false);
|
actionLoadLPF->setEnabled(false);
|
||||||
actionSaveConfig->setEnabled(false);
|
actionSaveConfig->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onUpdateActions()
|
void MainWindow::onUpdateActions()
|
||||||
{
|
{
|
||||||
if (ctx->settings.find(ctx->id("pack")) == ctx->settings.end())
|
if (ctx->settings.find(ctx->id("pack")) == ctx->settings.end())
|
||||||
actionLoadLPF->setEnabled(true);
|
actionLoadLPF->setEnabled(true);
|
||||||
if (ctx->settings.find(ctx->id("route")) != ctx->settings.end())
|
if (ctx->settings.find(ctx->id("route")) != ctx->settings.end())
|
||||||
actionSaveConfig->setEnabled(true);
|
actionSaveConfig->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
@ -1,55 +1,55 @@
|
|||||||
/*
|
/*
|
||||||
* nextpnr -- Next Generation Place and Route
|
* nextpnr -- Next Generation Place and Route
|
||||||
*
|
*
|
||||||
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* copyright notice and this permission notice appear in all copies.
|
* copyright notice and this permission notice appear in all copies.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MAINWINDOW_H
|
#ifndef MAINWINDOW_H
|
||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include "../basewindow.h"
|
#include "../basewindow.h"
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
class MainWindow : public BaseMainWindow
|
class MainWindow : public BaseMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent = 0);
|
explicit MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent = 0);
|
||||||
virtual ~MainWindow();
|
virtual ~MainWindow();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void createMenu();
|
void createMenu();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onDisableActions() override;
|
void onDisableActions() override;
|
||||||
void onUpdateActions() override;
|
void onUpdateActions() override;
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
void new_proj() override;
|
void new_proj() override;
|
||||||
void newContext(Context *ctx);
|
void newContext(Context *ctx);
|
||||||
void open_lpf();
|
void open_lpf();
|
||||||
void save_config();
|
void save_config();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QAction *actionLoadLPF;
|
QAction *actionLoadLPF;
|
||||||
QAction *actionSaveConfig;
|
QAction *actionSaveConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
@ -1,50 +1,50 @@
|
|||||||
/*
|
/*
|
||||||
* nextpnr -- Next Generation Place and Route
|
* nextpnr -- Next Generation Place and Route
|
||||||
*
|
*
|
||||||
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
||||||
* Copyright (C) 2021 Symbiflow Authors
|
* Copyright (C) 2021 Symbiflow Authors
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* copyright notice and this permission notice appear in all copies.
|
* copyright notice and this permission notice appear in all copies.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
|
static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
MainWindow::MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent)
|
MainWindow::MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent)
|
||||||
: BaseMainWindow(std::move(context), handler, parent)
|
: BaseMainWindow(std::move(context), handler, parent)
|
||||||
{
|
{
|
||||||
initMainResource();
|
initMainResource();
|
||||||
QMessageBox::critical(0, "Error - FIXME", "No GUI support for nextpnr-generic");
|
QMessageBox::critical(0, "Error - FIXME", "No GUI support for nextpnr-generic");
|
||||||
std::exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow() {}
|
MainWindow::~MainWindow() {}
|
||||||
|
|
||||||
void MainWindow::newContext(Context *ctx)
|
void MainWindow::newContext(Context *ctx)
|
||||||
{
|
{
|
||||||
std::string title = "nextpnr-generic - " + ctx->getChipName();
|
std::string title = "nextpnr-generic - " + ctx->getChipName();
|
||||||
setWindowTitle(title.c_str());
|
setWindowTitle(title.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::createMenu() {}
|
void MainWindow::createMenu() {}
|
||||||
|
|
||||||
void MainWindow::new_proj() {}
|
void MainWindow::new_proj() {}
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
@ -1,46 +1,46 @@
|
|||||||
/*
|
/*
|
||||||
* nextpnr -- Next Generation Place and Route
|
* nextpnr -- Next Generation Place and Route
|
||||||
*
|
*
|
||||||
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
||||||
* Copyright (C) 2021 Symbiflow Authors
|
* Copyright (C) 2021 Symbiflow Authors
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* copyright notice and this permission notice appear in all copies.
|
* copyright notice and this permission notice appear in all copies.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MAINWINDOW_H
|
#ifndef MAINWINDOW_H
|
||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include "../basewindow.h"
|
#include "../basewindow.h"
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
class MainWindow : public BaseMainWindow
|
class MainWindow : public BaseMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent = 0);
|
explicit MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent = 0);
|
||||||
virtual ~MainWindow();
|
virtual ~MainWindow();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void createMenu();
|
void createMenu();
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
void new_proj() override;
|
void new_proj() override;
|
||||||
void newContext(Context *ctx);
|
void newContext(Context *ctx);
|
||||||
};
|
};
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
@ -1,52 +1,52 @@
|
|||||||
/*
|
/*
|
||||||
* nextpnr -- Next Generation Place and Route
|
* nextpnr -- Next Generation Place and Route
|
||||||
*
|
*
|
||||||
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* copyright notice and this permission notice appear in all copies.
|
* copyright notice and this permission notice appear in all copies.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
|
static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
MainWindow::MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent)
|
MainWindow::MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent)
|
||||||
: BaseMainWindow(std::move(context), handler, parent)
|
: BaseMainWindow(std::move(context), handler, parent)
|
||||||
{
|
{
|
||||||
initMainResource();
|
initMainResource();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow() {}
|
MainWindow::~MainWindow() {}
|
||||||
|
|
||||||
void MainWindow::newContext(Context *ctx)
|
void MainWindow::newContext(Context *ctx)
|
||||||
{
|
{
|
||||||
std::string title = "nextpnr-generic - " + ctx->getChipName();
|
std::string title = "nextpnr-generic - " + ctx->getChipName();
|
||||||
setWindowTitle(title.c_str());
|
setWindowTitle(title.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::createMenu() {}
|
void MainWindow::createMenu() {}
|
||||||
|
|
||||||
void MainWindow::new_proj()
|
void MainWindow::new_proj()
|
||||||
{
|
{
|
||||||
QMessageBox::critical(0, "Error",
|
QMessageBox::critical(0, "Error",
|
||||||
"Creating a new project not supported in Viaduct mode, please re-start from command line.");
|
"Creating a new project not supported in Viaduct mode, please re-start from command line.");
|
||||||
std::exit(1);
|
std::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
@ -1,45 +1,45 @@
|
|||||||
/*
|
/*
|
||||||
* nextpnr -- Next Generation Place and Route
|
* nextpnr -- Next Generation Place and Route
|
||||||
*
|
*
|
||||||
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* copyright notice and this permission notice appear in all copies.
|
* copyright notice and this permission notice appear in all copies.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MAINWINDOW_H
|
#ifndef MAINWINDOW_H
|
||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include "../basewindow.h"
|
#include "../basewindow.h"
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
class MainWindow : public BaseMainWindow
|
class MainWindow : public BaseMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent = 0);
|
explicit MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent = 0);
|
||||||
virtual ~MainWindow();
|
virtual ~MainWindow();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void createMenu();
|
void createMenu();
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
void new_proj() override;
|
void new_proj() override;
|
||||||
void newContext(Context *ctx);
|
void newContext(Context *ctx);
|
||||||
};
|
};
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
@ -1,103 +1,103 @@
|
|||||||
/*
|
/*
|
||||||
* nextpnr -- Next Generation Place and Route
|
* nextpnr -- Next Generation Place and Route
|
||||||
*
|
*
|
||||||
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* copyright notice and this permission notice appear in all copies.
|
* copyright notice and this permission notice appear in all copies.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#include "cst.h"
|
#include "cst.h"
|
||||||
|
|
||||||
static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
|
static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
MainWindow::MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent)
|
MainWindow::MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent)
|
||||||
: BaseMainWindow(std::move(context), handler, parent)
|
: BaseMainWindow(std::move(context), handler, parent)
|
||||||
{
|
{
|
||||||
initMainResource();
|
initMainResource();
|
||||||
std::string title = "nextpnr-gowin - [EMPTY]";
|
std::string title = "nextpnr-gowin - [EMPTY]";
|
||||||
setWindowTitle(title.c_str());
|
setWindowTitle(title.c_str());
|
||||||
connect(this, &BaseMainWindow::contextChanged, this, &MainWindow::newContext);
|
connect(this, &BaseMainWindow::contextChanged, this, &MainWindow::newContext);
|
||||||
createMenu();
|
createMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow() {}
|
MainWindow::~MainWindow() {}
|
||||||
|
|
||||||
void MainWindow::newContext(Context *ctx)
|
void MainWindow::newContext(Context *ctx)
|
||||||
{
|
{
|
||||||
std::string title = "nextpnr-gowin - " + ctx->getChipName();
|
std::string title = "nextpnr-gowin - " + ctx->getChipName();
|
||||||
setWindowTitle(title.c_str());
|
setWindowTitle(title.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::load_cst(std::string filename)
|
void MainWindow::load_cst(std::string filename)
|
||||||
{
|
{
|
||||||
disableActions();
|
disableActions();
|
||||||
std::ifstream f(filename);
|
std::ifstream f(filename);
|
||||||
if (read_cst(ctx.get(), f)) {
|
if (read_cst(ctx.get(), f)) {
|
||||||
log("Loading CST successful.\n");
|
log("Loading CST successful.\n");
|
||||||
actionPack->setEnabled(true);
|
actionPack->setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
actionLoadCST->setEnabled(true);
|
actionLoadCST->setEnabled(true);
|
||||||
log("Loading CST failed.\n");
|
log("Loading CST failed.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::createMenu()
|
void MainWindow::createMenu()
|
||||||
{
|
{
|
||||||
actionLoadCST = new QAction("Open CST", this);
|
actionLoadCST = new QAction("Open CST", this);
|
||||||
actionLoadCST->setIcon(QIcon(":/icons/resources/open_cst.png"));
|
actionLoadCST->setIcon(QIcon(":/icons/resources/open_cst.png"));
|
||||||
actionLoadCST->setStatusTip("Open CST file");
|
actionLoadCST->setStatusTip("Open CST file");
|
||||||
actionLoadCST->setEnabled(false);
|
actionLoadCST->setEnabled(false);
|
||||||
connect(actionLoadCST, &QAction::triggered, this, &MainWindow::open_cst);
|
connect(actionLoadCST, &QAction::triggered, this, &MainWindow::open_cst);
|
||||||
|
|
||||||
// Add actions in menus
|
// Add actions in menus
|
||||||
mainActionBar->addSeparator();
|
mainActionBar->addSeparator();
|
||||||
mainActionBar->addAction(actionLoadCST);
|
mainActionBar->addAction(actionLoadCST);
|
||||||
|
|
||||||
menuDesign->addSeparator();
|
menuDesign->addSeparator();
|
||||||
menuDesign->addAction(actionLoadCST);
|
menuDesign->addAction(actionLoadCST);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::new_proj() {}
|
void MainWindow::new_proj() {}
|
||||||
|
|
||||||
void MainWindow::open_cst()
|
void MainWindow::open_cst()
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getOpenFileName(this, QString("Open CST"), QString(), QString("*.cst"));
|
QString fileName = QFileDialog::getOpenFileName(this, QString("Open CST"), QString(), QString("*.cst"));
|
||||||
if (!fileName.isEmpty()) {
|
if (!fileName.isEmpty()) {
|
||||||
load_cst(fileName.toStdString());
|
load_cst(fileName.toStdString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onDisableActions() { actionLoadCST->setEnabled(false); }
|
void MainWindow::onDisableActions() { actionLoadCST->setEnabled(false); }
|
||||||
|
|
||||||
void MainWindow::onUpdateActions()
|
void MainWindow::onUpdateActions()
|
||||||
{
|
{
|
||||||
if (ctx->settings.find(ctx->id("synth")) != ctx->settings.end()) {
|
if (ctx->settings.find(ctx->id("synth")) != ctx->settings.end()) {
|
||||||
actionLoadCST->setEnabled(true);
|
actionLoadCST->setEnabled(true);
|
||||||
}
|
}
|
||||||
if (ctx->settings.find(ctx->id("cst")) != ctx->settings.end()) {
|
if (ctx->settings.find(ctx->id("cst")) != ctx->settings.end()) {
|
||||||
actionLoadCST->setEnabled(false);
|
actionLoadCST->setEnabled(false);
|
||||||
}
|
}
|
||||||
if (ctx->settings.find(ctx->id("pack")) != ctx->settings.end()) {
|
if (ctx->settings.find(ctx->id("pack")) != ctx->settings.end()) {
|
||||||
actionLoadCST->setEnabled(false);
|
actionLoadCST->setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
@ -1,57 +1,57 @@
|
|||||||
/*
|
/*
|
||||||
* nextpnr -- Next Generation Place and Route
|
* nextpnr -- Next Generation Place and Route
|
||||||
*
|
*
|
||||||
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* copyright notice and this permission notice appear in all copies.
|
* copyright notice and this permission notice appear in all copies.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MAINWINDOW_H
|
#ifndef MAINWINDOW_H
|
||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include "../basewindow.h"
|
#include "../basewindow.h"
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
class MainWindow : public BaseMainWindow
|
class MainWindow : public BaseMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent = 0);
|
explicit MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent = 0);
|
||||||
virtual ~MainWindow();
|
virtual ~MainWindow();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void createMenu();
|
void createMenu();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onDisableActions() override;
|
void onDisableActions() override;
|
||||||
void onUpdateActions() override;
|
void onUpdateActions() override;
|
||||||
|
|
||||||
void load_cst(std::string filename);
|
void load_cst(std::string filename);
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
void new_proj() override;
|
void new_proj() override;
|
||||||
|
|
||||||
void open_cst();
|
void open_cst();
|
||||||
|
|
||||||
void newContext(Context *ctx);
|
void newContext(Context *ctx);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QAction *actionLoadCST;
|
QAction *actionLoadCST;
|
||||||
};
|
};
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
@ -1,182 +1,182 @@
|
|||||||
/*
|
/*
|
||||||
* nextpnr -- Next Generation Place and Route
|
* nextpnr -- Next Generation Place and Route
|
||||||
*
|
*
|
||||||
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* copyright notice and this permission notice appear in all copies.
|
* copyright notice and this permission notice appear in all copies.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include "bitstream.h"
|
#include "bitstream.h"
|
||||||
#include "design_utils.h"
|
#include "design_utils.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "pcf.h"
|
#include "pcf.h"
|
||||||
|
|
||||||
static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
|
static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
MainWindow::MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent)
|
MainWindow::MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent)
|
||||||
: BaseMainWindow(std::move(context), handler, parent)
|
: BaseMainWindow(std::move(context), handler, parent)
|
||||||
{
|
{
|
||||||
initMainResource();
|
initMainResource();
|
||||||
|
|
||||||
std::string title = "nextpnr-ice40 - [EMPTY]";
|
std::string title = "nextpnr-ice40 - [EMPTY]";
|
||||||
setWindowTitle(title.c_str());
|
setWindowTitle(title.c_str());
|
||||||
|
|
||||||
connect(this, &BaseMainWindow::contextChanged, this, &MainWindow::newContext);
|
connect(this, &BaseMainWindow::contextChanged, this, &MainWindow::newContext);
|
||||||
|
|
||||||
createMenu();
|
createMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow() {}
|
MainWindow::~MainWindow() {}
|
||||||
|
|
||||||
void MainWindow::createMenu()
|
void MainWindow::createMenu()
|
||||||
{
|
{
|
||||||
// Add arch specific actions
|
// Add arch specific actions
|
||||||
actionLoadPCF = new QAction("Open PCF", this);
|
actionLoadPCF = new QAction("Open PCF", this);
|
||||||
actionLoadPCF->setIcon(QIcon(":/icons/resources/open_pcf.png"));
|
actionLoadPCF->setIcon(QIcon(":/icons/resources/open_pcf.png"));
|
||||||
actionLoadPCF->setStatusTip("Open PCF file");
|
actionLoadPCF->setStatusTip("Open PCF file");
|
||||||
actionLoadPCF->setEnabled(false);
|
actionLoadPCF->setEnabled(false);
|
||||||
connect(actionLoadPCF, &QAction::triggered, this, &MainWindow::open_pcf);
|
connect(actionLoadPCF, &QAction::triggered, this, &MainWindow::open_pcf);
|
||||||
|
|
||||||
actionSaveAsc = new QAction("Save ASC", this);
|
actionSaveAsc = new QAction("Save ASC", this);
|
||||||
actionSaveAsc->setIcon(QIcon(":/icons/resources/save_asc.png"));
|
actionSaveAsc->setIcon(QIcon(":/icons/resources/save_asc.png"));
|
||||||
actionSaveAsc->setStatusTip("Save ASC file");
|
actionSaveAsc->setStatusTip("Save ASC file");
|
||||||
actionSaveAsc->setEnabled(false);
|
actionSaveAsc->setEnabled(false);
|
||||||
connect(actionSaveAsc, &QAction::triggered, this, &MainWindow::save_asc);
|
connect(actionSaveAsc, &QAction::triggered, this, &MainWindow::save_asc);
|
||||||
|
|
||||||
// Add actions in menus
|
// Add actions in menus
|
||||||
mainActionBar->addSeparator();
|
mainActionBar->addSeparator();
|
||||||
mainActionBar->addAction(actionLoadPCF);
|
mainActionBar->addAction(actionLoadPCF);
|
||||||
mainActionBar->addAction(actionSaveAsc);
|
mainActionBar->addAction(actionSaveAsc);
|
||||||
|
|
||||||
menuDesign->addSeparator();
|
menuDesign->addSeparator();
|
||||||
menuDesign->addAction(actionLoadPCF);
|
menuDesign->addAction(actionLoadPCF);
|
||||||
menuDesign->addAction(actionSaveAsc);
|
menuDesign->addAction(actionSaveAsc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::new_proj()
|
void MainWindow::new_proj()
|
||||||
{
|
{
|
||||||
QMap<QString, int> arch;
|
QMap<QString, int> arch;
|
||||||
if (Arch::is_available(ArchArgs::LP384))
|
if (Arch::is_available(ArchArgs::LP384))
|
||||||
arch.insert("Lattice iCE40LP384", ArchArgs::LP384);
|
arch.insert("Lattice iCE40LP384", ArchArgs::LP384);
|
||||||
if (Arch::is_available(ArchArgs::LP1K))
|
if (Arch::is_available(ArchArgs::LP1K))
|
||||||
arch.insert("Lattice iCE40LP1K", ArchArgs::LP1K);
|
arch.insert("Lattice iCE40LP1K", ArchArgs::LP1K);
|
||||||
if (Arch::is_available(ArchArgs::HX1K))
|
if (Arch::is_available(ArchArgs::HX1K))
|
||||||
arch.insert("Lattice iCE40HX1K", ArchArgs::HX1K);
|
arch.insert("Lattice iCE40HX1K", ArchArgs::HX1K);
|
||||||
if (Arch::is_available(ArchArgs::U1K))
|
if (Arch::is_available(ArchArgs::U1K))
|
||||||
arch.insert("Lattice iCE5LP1K", ArchArgs::U1K);
|
arch.insert("Lattice iCE5LP1K", ArchArgs::U1K);
|
||||||
if (Arch::is_available(ArchArgs::U2K))
|
if (Arch::is_available(ArchArgs::U2K))
|
||||||
arch.insert("Lattice iCE5LP2K", ArchArgs::U2K);
|
arch.insert("Lattice iCE5LP2K", ArchArgs::U2K);
|
||||||
if (Arch::is_available(ArchArgs::U4K))
|
if (Arch::is_available(ArchArgs::U4K))
|
||||||
arch.insert("Lattice iCE5LP4K", ArchArgs::U4K);
|
arch.insert("Lattice iCE5LP4K", ArchArgs::U4K);
|
||||||
if (Arch::is_available(ArchArgs::UP3K))
|
if (Arch::is_available(ArchArgs::UP3K))
|
||||||
arch.insert("Lattice iCE40UP3K", ArchArgs::UP3K);
|
arch.insert("Lattice iCE40UP3K", ArchArgs::UP3K);
|
||||||
if (Arch::is_available(ArchArgs::UP5K))
|
if (Arch::is_available(ArchArgs::UP5K))
|
||||||
arch.insert("Lattice iCE40UP5K", ArchArgs::UP5K);
|
arch.insert("Lattice iCE40UP5K", ArchArgs::UP5K);
|
||||||
if (Arch::is_available(ArchArgs::LP4K))
|
if (Arch::is_available(ArchArgs::LP4K))
|
||||||
arch.insert("Lattice iCE40LP4K", ArchArgs::LP4K);
|
arch.insert("Lattice iCE40LP4K", ArchArgs::LP4K);
|
||||||
if (Arch::is_available(ArchArgs::LP8K))
|
if (Arch::is_available(ArchArgs::LP8K))
|
||||||
arch.insert("Lattice iCE40LP8K", ArchArgs::LP8K);
|
arch.insert("Lattice iCE40LP8K", ArchArgs::LP8K);
|
||||||
if (Arch::is_available(ArchArgs::HX4K))
|
if (Arch::is_available(ArchArgs::HX4K))
|
||||||
arch.insert("Lattice iCE40HX4K", ArchArgs::HX4K);
|
arch.insert("Lattice iCE40HX4K", ArchArgs::HX4K);
|
||||||
if (Arch::is_available(ArchArgs::HX8K))
|
if (Arch::is_available(ArchArgs::HX8K))
|
||||||
arch.insert("Lattice iCE40HX8K", ArchArgs::HX8K);
|
arch.insert("Lattice iCE40HX8K", ArchArgs::HX8K);
|
||||||
|
|
||||||
bool ok;
|
bool ok;
|
||||||
QString item = QInputDialog::getItem(this, "Select new context", "Chip:", arch.keys(), 0, false, &ok);
|
QString item = QInputDialog::getItem(this, "Select new context", "Chip:", arch.keys(), 0, false, &ok);
|
||||||
if (ok && !item.isEmpty()) {
|
if (ok && !item.isEmpty()) {
|
||||||
ArchArgs chipArgs;
|
ArchArgs chipArgs;
|
||||||
chipArgs.type = (ArchArgs::ArchArgsTypes)arch.value(item);
|
chipArgs.type = (ArchArgs::ArchArgsTypes)arch.value(item);
|
||||||
|
|
||||||
QStringList packages;
|
QStringList packages;
|
||||||
for (auto package : Arch::get_supported_packages(chipArgs.type))
|
for (auto package : Arch::get_supported_packages(chipArgs.type))
|
||||||
packages.append(QLatin1String(package.data(), package.size()));
|
packages.append(QLatin1String(package.data(), package.size()));
|
||||||
QString package = QInputDialog::getItem(this, "Select package", "Package:", packages, 0, false, &ok);
|
QString package = QInputDialog::getItem(this, "Select package", "Package:", packages, 0, false, &ok);
|
||||||
|
|
||||||
if (ok && !item.isEmpty()) {
|
if (ok && !item.isEmpty()) {
|
||||||
handler->clear();
|
handler->clear();
|
||||||
currentProj = "";
|
currentProj = "";
|
||||||
disableActions();
|
disableActions();
|
||||||
chipArgs.package = package.toStdString().c_str();
|
chipArgs.package = package.toStdString().c_str();
|
||||||
ctx = std::unique_ptr<Context>(new Context(chipArgs));
|
ctx = std::unique_ptr<Context>(new Context(chipArgs));
|
||||||
actionLoadJSON->setEnabled(true);
|
actionLoadJSON->setEnabled(true);
|
||||||
|
|
||||||
Q_EMIT contextChanged(ctx.get());
|
Q_EMIT contextChanged(ctx.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::load_pcf(std::string filename)
|
void MainWindow::load_pcf(std::string filename)
|
||||||
{
|
{
|
||||||
disableActions();
|
disableActions();
|
||||||
std::ifstream f(filename);
|
std::ifstream f(filename);
|
||||||
if (apply_pcf(ctx.get(), filename, f)) {
|
if (apply_pcf(ctx.get(), filename, f)) {
|
||||||
log("Loading PCF successful.\n");
|
log("Loading PCF successful.\n");
|
||||||
actionPack->setEnabled(true);
|
actionPack->setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
actionLoadPCF->setEnabled(true);
|
actionLoadPCF->setEnabled(true);
|
||||||
log("Loading PCF failed.\n");
|
log("Loading PCF failed.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::newContext(Context *ctx)
|
void MainWindow::newContext(Context *ctx)
|
||||||
{
|
{
|
||||||
std::string title = "nextpnr-ice40 - " + ctx->getChipName() + " ( " + ctx->archArgs().package + " )";
|
std::string title = "nextpnr-ice40 - " + ctx->getChipName() + " ( " + ctx->archArgs().package + " )";
|
||||||
setWindowTitle(title.c_str());
|
setWindowTitle(title.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::open_pcf()
|
void MainWindow::open_pcf()
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getOpenFileName(this, QString("Open PCF"), QString(), QString("*.pcf"));
|
QString fileName = QFileDialog::getOpenFileName(this, QString("Open PCF"), QString(), QString("*.pcf"));
|
||||||
if (!fileName.isEmpty()) {
|
if (!fileName.isEmpty()) {
|
||||||
load_pcf(fileName.toStdString());
|
load_pcf(fileName.toStdString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::save_asc()
|
void MainWindow::save_asc()
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getSaveFileName(this, QString("Save ASC"), QString(), QString("*.asc"));
|
QString fileName = QFileDialog::getSaveFileName(this, QString("Save ASC"), QString(), QString("*.asc"));
|
||||||
if (!fileName.isEmpty()) {
|
if (!fileName.isEmpty()) {
|
||||||
std::string fn = fileName.toStdString();
|
std::string fn = fileName.toStdString();
|
||||||
disableActions();
|
disableActions();
|
||||||
std::ofstream f(fn);
|
std::ofstream f(fn);
|
||||||
write_asc(ctx.get(), f);
|
write_asc(ctx.get(), f);
|
||||||
log("Saving ASC successful.\n");
|
log("Saving ASC successful.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onDisableActions()
|
void MainWindow::onDisableActions()
|
||||||
{
|
{
|
||||||
actionLoadPCF->setEnabled(false);
|
actionLoadPCF->setEnabled(false);
|
||||||
actionSaveAsc->setEnabled(false);
|
actionSaveAsc->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onUpdateActions()
|
void MainWindow::onUpdateActions()
|
||||||
{
|
{
|
||||||
if (ctx->settings.find(ctx->id("pack")) == ctx->settings.end())
|
if (ctx->settings.find(ctx->id("pack")) == ctx->settings.end())
|
||||||
actionLoadPCF->setEnabled(true);
|
actionLoadPCF->setEnabled(true);
|
||||||
if (ctx->settings.find(ctx->id("route")) != ctx->settings.end())
|
if (ctx->settings.find(ctx->id("route")) != ctx->settings.end())
|
||||||
actionSaveAsc->setEnabled(true);
|
actionSaveAsc->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
@ -1,59 +1,59 @@
|
|||||||
/*
|
/*
|
||||||
* nextpnr -- Next Generation Place and Route
|
* nextpnr -- Next Generation Place and Route
|
||||||
*
|
*
|
||||||
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* copyright notice and this permission notice appear in all copies.
|
* copyright notice and this permission notice appear in all copies.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MAINWINDOW_H
|
#ifndef MAINWINDOW_H
|
||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include "../basewindow.h"
|
#include "../basewindow.h"
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
class MainWindow : public BaseMainWindow
|
class MainWindow : public BaseMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent = 0);
|
explicit MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent = 0);
|
||||||
virtual ~MainWindow();
|
virtual ~MainWindow();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void createMenu();
|
void createMenu();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void load_pcf(std::string filename);
|
void load_pcf(std::string filename);
|
||||||
|
|
||||||
void onDisableActions() override;
|
void onDisableActions() override;
|
||||||
void onUpdateActions() override;
|
void onUpdateActions() override;
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
void new_proj() override;
|
void new_proj() override;
|
||||||
|
|
||||||
void open_pcf();
|
void open_pcf();
|
||||||
void save_asc();
|
void save_asc();
|
||||||
|
|
||||||
void newContext(Context *ctx);
|
void newContext(Context *ctx);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QAction *actionLoadPCF;
|
QAction *actionLoadPCF;
|
||||||
QAction *actionSaveAsc;
|
QAction *actionSaveAsc;
|
||||||
};
|
};
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
238
gui/pythontab.cc
238
gui/pythontab.cc
@ -1,119 +1,119 @@
|
|||||||
/*
|
/*
|
||||||
* nextpnr -- Next Generation Place and Route
|
* nextpnr -- Next Generation Place and Route
|
||||||
*
|
*
|
||||||
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* copyright notice and this permission notice appear in all copies.
|
* copyright notice and this permission notice appear in all copies.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pythontab.h"
|
#include "pythontab.h"
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include "pybindings.h"
|
#include "pybindings.h"
|
||||||
#include "pyinterpreter.h"
|
#include "pyinterpreter.h"
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
const QString PythonTab::PROMPT = ">>> ";
|
const QString PythonTab::PROMPT = ">>> ";
|
||||||
const QString PythonTab::MULTILINE_PROMPT = "... ";
|
const QString PythonTab::MULTILINE_PROMPT = "... ";
|
||||||
|
|
||||||
PythonTab::PythonTab(QWidget *parent) : QWidget(parent), initialized(false)
|
PythonTab::PythonTab(QWidget *parent) : QWidget(parent), initialized(false)
|
||||||
{
|
{
|
||||||
QFont f("unexistent");
|
QFont f("unexistent");
|
||||||
f.setStyleHint(QFont::Monospace);
|
f.setStyleHint(QFont::Monospace);
|
||||||
|
|
||||||
// Add text area for Python output and input line
|
// Add text area for Python output and input line
|
||||||
console = new PythonConsole();
|
console = new PythonConsole();
|
||||||
console->setMinimumHeight(100);
|
console->setMinimumHeight(100);
|
||||||
console->setReadOnly(true);
|
console->setReadOnly(true);
|
||||||
console->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
|
console->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
|
||||||
console->setFont(f);
|
console->setFont(f);
|
||||||
|
|
||||||
console->setContextMenuPolicy(Qt::CustomContextMenu);
|
console->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
QAction *clearAction = new QAction("Clear &buffer", this);
|
QAction *clearAction = new QAction("Clear &buffer", this);
|
||||||
clearAction->setStatusTip("Clears display buffer");
|
clearAction->setStatusTip("Clears display buffer");
|
||||||
connect(clearAction, &QAction::triggered, this, &PythonTab::clearBuffer);
|
connect(clearAction, &QAction::triggered, this, &PythonTab::clearBuffer);
|
||||||
contextMenu = console->createStandardContextMenu();
|
contextMenu = console->createStandardContextMenu();
|
||||||
contextMenu->addSeparator();
|
contextMenu->addSeparator();
|
||||||
contextMenu->addAction(clearAction);
|
contextMenu->addAction(clearAction);
|
||||||
connect(console, &PythonConsole::customContextMenuRequested, this, &PythonTab::showContextMenu);
|
connect(console, &PythonConsole::customContextMenuRequested, this, &PythonTab::showContextMenu);
|
||||||
|
|
||||||
lineEdit = new LineEditor(&parseHelper);
|
lineEdit = new LineEditor(&parseHelper);
|
||||||
lineEdit->setMinimumHeight(30);
|
lineEdit->setMinimumHeight(30);
|
||||||
lineEdit->setMaximumHeight(30);
|
lineEdit->setMaximumHeight(30);
|
||||||
lineEdit->setFont(f);
|
lineEdit->setFont(f);
|
||||||
lineEdit->setPlaceholderText(PythonTab::PROMPT);
|
lineEdit->setPlaceholderText(PythonTab::PROMPT);
|
||||||
connect(lineEdit, &LineEditor::textLineInserted, this, &PythonTab::editLineReturnPressed);
|
connect(lineEdit, &LineEditor::textLineInserted, this, &PythonTab::editLineReturnPressed);
|
||||||
|
|
||||||
QGridLayout *mainLayout = new QGridLayout();
|
QGridLayout *mainLayout = new QGridLayout();
|
||||||
mainLayout->addWidget(console, 0, 0);
|
mainLayout->addWidget(console, 0, 0);
|
||||||
mainLayout->addWidget(lineEdit, 1, 0);
|
mainLayout->addWidget(lineEdit, 1, 0);
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
parseHelper.subscribe(console);
|
parseHelper.subscribe(console);
|
||||||
|
|
||||||
prompt = PythonTab::PROMPT;
|
prompt = PythonTab::PROMPT;
|
||||||
}
|
}
|
||||||
|
|
||||||
PythonTab::~PythonTab()
|
PythonTab::~PythonTab()
|
||||||
{
|
{
|
||||||
if (initialized) {
|
if (initialized) {
|
||||||
pyinterpreter_finalize();
|
pyinterpreter_finalize();
|
||||||
deinit_python();
|
deinit_python();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PythonTab::editLineReturnPressed(QString text)
|
void PythonTab::editLineReturnPressed(QString text)
|
||||||
{
|
{
|
||||||
console->displayString(prompt + text + "\n");
|
console->displayString(prompt + text + "\n");
|
||||||
|
|
||||||
parseHelper.process(text.toStdString());
|
parseHelper.process(text.toStdString());
|
||||||
|
|
||||||
if (parseHelper.buffered())
|
if (parseHelper.buffered())
|
||||||
prompt = PythonTab::MULTILINE_PROMPT;
|
prompt = PythonTab::MULTILINE_PROMPT;
|
||||||
else
|
else
|
||||||
prompt = PythonTab::PROMPT;
|
prompt = PythonTab::PROMPT;
|
||||||
|
|
||||||
lineEdit->setPlaceholderText(prompt);
|
lineEdit->setPlaceholderText(prompt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PythonTab::newContext(Context *ctx)
|
void PythonTab::newContext(Context *ctx)
|
||||||
{
|
{
|
||||||
if (initialized) {
|
if (initialized) {
|
||||||
pyinterpreter_finalize();
|
pyinterpreter_finalize();
|
||||||
deinit_python();
|
deinit_python();
|
||||||
}
|
}
|
||||||
console->clear();
|
console->clear();
|
||||||
|
|
||||||
pyinterpreter_preinit();
|
pyinterpreter_preinit();
|
||||||
init_python("nextpnr");
|
init_python("nextpnr");
|
||||||
pyinterpreter_initialize();
|
pyinterpreter_initialize();
|
||||||
pyinterpreter_aquire();
|
pyinterpreter_aquire();
|
||||||
python_export_global("ctx", ctx);
|
python_export_global("ctx", ctx);
|
||||||
pyinterpreter_release();
|
pyinterpreter_release();
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
|
||||||
QString version = QString("Python %1 on %2\n").arg(Py_GetVersion(), Py_GetPlatform());
|
QString version = QString("Python %1 on %2\n").arg(Py_GetVersion(), Py_GetPlatform());
|
||||||
console->displayString(version);
|
console->displayString(version);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PythonTab::showContextMenu(const QPoint &pt) { contextMenu->exec(mapToGlobal(pt)); }
|
void PythonTab::showContextMenu(const QPoint &pt) { contextMenu->exec(mapToGlobal(pt)); }
|
||||||
|
|
||||||
void PythonTab::clearBuffer() { console->clear(); }
|
void PythonTab::clearBuffer() { console->clear(); }
|
||||||
|
|
||||||
void PythonTab::info(std::string str) { console->displayString(str.c_str()); }
|
void PythonTab::info(std::string str) { console->displayString(str.c_str()); }
|
||||||
|
|
||||||
void PythonTab::execute_python(std::string filename) { console->execute_python(filename); }
|
void PythonTab::execute_python(std::string filename) { console->execute_python(filename); }
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
128
gui/pythontab.h
128
gui/pythontab.h
@ -1,64 +1,64 @@
|
|||||||
/*
|
/*
|
||||||
* nextpnr -- Next Generation Place and Route
|
* nextpnr -- Next Generation Place and Route
|
||||||
*
|
*
|
||||||
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
* Copyright (C) 2018 Miodrag Milanovic <micko@yosyshq.com>
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and/or distribute this software for any
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
* copyright notice and this permission notice appear in all copies.
|
* copyright notice and this permission notice appear in all copies.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef PYTHONTAB_H
|
#ifndef PYTHONTAB_H
|
||||||
#define PYTHONTAB_H
|
#define PYTHONTAB_H
|
||||||
|
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
#include "ParseHelper.h"
|
#include "ParseHelper.h"
|
||||||
#include "line_editor.h"
|
#include "line_editor.h"
|
||||||
#include "nextpnr.h"
|
#include "nextpnr.h"
|
||||||
#include "pyconsole.h"
|
#include "pyconsole.h"
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
class PythonTab : public QWidget
|
class PythonTab : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit PythonTab(QWidget *parent = 0);
|
explicit PythonTab(QWidget *parent = 0);
|
||||||
~PythonTab();
|
~PythonTab();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void showContextMenu(const QPoint &pt);
|
void showContextMenu(const QPoint &pt);
|
||||||
void editLineReturnPressed(QString text);
|
void editLineReturnPressed(QString text);
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void newContext(Context *ctx);
|
void newContext(Context *ctx);
|
||||||
void info(std::string str);
|
void info(std::string str);
|
||||||
void clearBuffer();
|
void clearBuffer();
|
||||||
void execute_python(std::string filename);
|
void execute_python(std::string filename);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PythonConsole *console;
|
PythonConsole *console;
|
||||||
LineEditor *lineEdit;
|
LineEditor *lineEdit;
|
||||||
QMenu *contextMenu;
|
QMenu *contextMenu;
|
||||||
bool initialized;
|
bool initialized;
|
||||||
ParseHelper parseHelper;
|
ParseHelper parseHelper;
|
||||||
QString prompt;
|
QString prompt;
|
||||||
|
|
||||||
static const QString PROMPT;
|
static const QString PROMPT;
|
||||||
static const QString MULTILINE_PROMPT;
|
static const QString MULTILINE_PROMPT;
|
||||||
};
|
};
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
|
||||||
#endif // PYTHONTAB_H
|
#endif // PYTHONTAB_H
|
||||||
|
Loading…
Reference in New Issue
Block a user