1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
#include "mainwindow.h"
#include <QAction>
#include <QFileDialog>
#include <QGridLayout>
#include <QIcon>
#include <QMenu>
#include <QMenuBar>
#include <QSplitter>
#include <QStatusBar>
#include <QToolBar>
#include <fstream>
#include "designwidget.h"
#include "fpgaviewwidget.h"
#include "jsonparse.h"
#include "log.h"
#include "pythontab.h"
//#include "pack.h"
//#include "pcf.h"
#include "place_sa.h"
#include "pybindings.h"
#include "route.h"
//#include "bitstream.h"
#include "design_utils.h"
MainWindow::MainWindow(Context *_ctx, QWidget *parent)
: QMainWindow(parent), ctx(_ctx)
{
log_files.clear();
log_streams.clear();
log_write_function = [this](std::string text) { info->info(text); };
std::string title = "nextpnr-ice40 - " + ctx->getChipName();
setWindowTitle(title.c_str());
setObjectName(QStringLiteral("MainWindow"));
resize(1024, 768);
createMenusAndBars();
QWidget *centralWidget = new QWidget(this);
QGridLayout *gridLayout = new QGridLayout(centralWidget);
gridLayout->setSpacing(6);
gridLayout->setContentsMargins(11, 11, 11, 11);
QSplitter *splitter_h = new QSplitter(Qt::Horizontal, centralWidget);
QSplitter *splitter_v = new QSplitter(Qt::Vertical, splitter_h);
splitter_h->addWidget(splitter_v);
gridLayout->addWidget(splitter_h, 0, 0, 1, 1);
setCentralWidget(centralWidget);
DesignWidget *designview = new DesignWidget(ctx);
designview->setMinimumWidth(300);
designview->setMaximumWidth(300);
splitter_h->addWidget(designview);
connect(designview, SIGNAL(info(std::string)), this,
SLOT(writeInfo(std::string)));
tabWidget = new QTabWidget();
tabWidget->addTab(new PythonTab(), "Python");
info = new InfoTab();
tabWidget->addTab(info, "Info");
splitter_v->addWidget(new FPGAViewWidget());
splitter_v->addWidget(tabWidget);
}
MainWindow::~MainWindow() {}
void MainWindow::writeInfo(std::string text) { info->info(text); }
void MainWindow::createMenusAndBars()
{
QAction *actionOpen = new QAction("Open", this);
QIcon icon1;
icon1.addFile(QStringLiteral(":/icons/resources/open.png"));
actionOpen->setIcon(icon1);
actionOpen->setShortcuts(QKeySequence::Open);
actionOpen->setStatusTip("Open an existing JSON file");
connect(actionOpen, SIGNAL(triggered()), this, SLOT(open()));
QAction *actionSave = new QAction("Save", this);
QIcon icon2;
icon2.addFile(QStringLiteral(":/icons/resources/save.png"));
actionSave->setIcon(icon2);
actionSave->setShortcuts(QKeySequence::Save);
actionSave->setStatusTip("Save the ASC to disk");
connect(actionSave, SIGNAL(triggered()), this, SLOT(save()));
actionSave->setEnabled(false);
QAction *actionExit = new QAction("Exit", this);
QIcon icon3;
icon3.addFile(QStringLiteral(":/icons/resources/exit.png"));
actionExit->setIcon(icon3);
actionExit->setShortcuts(QKeySequence::Quit);
actionExit->setStatusTip("Exit the application");
connect(actionExit, SIGNAL(triggered()), this, SLOT(close()));
QAction *actionAbout = new QAction("About", this);
QMenuBar *menuBar = new QMenuBar();
menuBar->setGeometry(QRect(0, 0, 1024, 27));
QMenu *menu_File = new QMenu("&File", menuBar);
QMenu *menu_Help = new QMenu("&Help", menuBar);
menuBar->addAction(menu_File->menuAction());
menuBar->addAction(menu_Help->menuAction());
setMenuBar(menuBar);
QToolBar *mainToolBar = new QToolBar();
addToolBar(Qt::TopToolBarArea, mainToolBar);
QStatusBar *statusBar = new QStatusBar();
setStatusBar(statusBar);
menu_File->addAction(actionOpen);
menu_File->addAction(actionSave);
menu_File->addSeparator();
menu_File->addAction(actionExit);
menu_Help->addAction(actionAbout);
mainToolBar->addAction(actionOpen);
mainToolBar->addAction(actionSave);
}
void MainWindow::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 MainWindow::save() { return false; }
|