clangformat cleanup

This commit is contained in:
Miodrag Milanovic 2018-06-23 16:06:49 +02:00
parent c0b1078c12
commit 4b78ae15df
18 changed files with 84 additions and 194 deletions

View File

@ -107,8 +107,7 @@ PyMODINIT_FUNC PyInit_emb(void)
PyObject *m = PyModule_Create(&embmodule); PyObject *m = PyModule_Create(&embmodule);
if (m) { if (m) {
Py_INCREF(&StdoutType); Py_INCREF(&StdoutType);
PyModule_AddObject(m, "Stdout", PyModule_AddObject(m, "Stdout", reinterpret_cast<PyObject *>(&StdoutType));
reinterpret_cast<PyObject *>(&StdoutType));
} }
return m; return m;
} }

View File

@ -29,10 +29,10 @@
#endif #endif
#include <boost/filesystem/convenience.hpp> #include <boost/filesystem/convenience.hpp>
#include <boost/program_options.hpp> #include <boost/program_options.hpp>
#include <iostream>
#include "log.h" #include "log.h"
#include "nextpnr.h" #include "nextpnr.h"
#include "version.h" #include "version.h"
#include <iostream>
USING_NEXTPNR_NAMESPACE USING_NEXTPNR_NAMESPACE
@ -55,18 +55,14 @@ int main(int argc, char *argv[])
po::positional_options_description pos; po::positional_options_description pos;
#ifndef NO_PYTHON #ifndef NO_PYTHON
options.add_options()("run", po::value<std::vector<std::string>>(), options.add_options()("run", po::value<std::vector<std::string>>(), "python file to execute");
"python file to execute");
pos.add("run", -1); pos.add("run", -1);
#endif #endif
options.add_options()("version,V", "show version"); options.add_options()("version,V", "show version");
po::variables_map vm; po::variables_map vm;
try { try {
po::parsed_options parsed = po::command_line_parser(argc, argv) po::parsed_options parsed = po::command_line_parser(argc, argv).options(options).positional(pos).run();
.options(options)
.positional(pos)
.run();
po::store(parsed, vm); po::store(parsed, vm);
@ -79,8 +75,7 @@ int main(int argc, char *argv[])
} }
if (vm.count("help") || argc == 1) { if (vm.count("help") || argc == 1) {
std::cout << boost::filesystem::basename(argv[0]) std::cout << boost::filesystem::basename(argv[0]) << " -- Next Generation Place and Route (git "
<< " -- Next Generation Place and Route (git "
"sha1 " GIT_COMMIT_HASH_STR ")\n"; "sha1 " GIT_COMMIT_HASH_STR ")\n";
std::cout << "\n"; std::cout << "\n";
std::cout << options << "\n"; std::cout << options << "\n";
@ -88,8 +83,7 @@ int main(int argc, char *argv[])
} }
if (vm.count("version")) { if (vm.count("version")) {
std::cout << boost::filesystem::basename(argv[0]) std::cout << boost::filesystem::basename(argv[0]) << " -- Next Generation Place and Route (git "
<< " -- Next Generation Place and Route (git "
"sha1 " GIT_COMMIT_HASH_STR ")\n"; "sha1 " GIT_COMMIT_HASH_STR ")\n";
return 1; return 1;
} }
@ -115,8 +109,7 @@ int main(int argc, char *argv[])
#ifndef NO_PYTHON #ifndef NO_PYTHON
if (vm.count("run")) { if (vm.count("run")) {
std::vector<std::string> files = std::vector<std::string> files = vm["run"].as<std::vector<std::string>>();
vm["run"].as<std::vector<std::string>>();
for (auto filename : files) for (auto filename : files)
execute_python_file(filename.c_str()); execute_python_file(filename.c_str());
} }

View File

@ -36,8 +36,7 @@ static void initBasenameResource() { Q_INIT_RESOURCE(base); }
NEXTPNR_NAMESPACE_BEGIN NEXTPNR_NAMESPACE_BEGIN
BaseMainWindow::BaseMainWindow(Context *_ctx, QWidget *parent) BaseMainWindow::BaseMainWindow(Context *_ctx, QWidget *parent) : QMainWindow(parent), ctx(_ctx)
: QMainWindow(parent), ctx(_ctx)
{ {
initBasenameResource(); initBasenameResource();
qRegisterMetaType<std::string>(); qRegisterMetaType<std::string>();
@ -69,8 +68,7 @@ BaseMainWindow::BaseMainWindow(Context *_ctx, QWidget *parent)
designview->setMaximumWidth(300); designview->setMaximumWidth(300);
splitter_h->addWidget(designview); splitter_h->addWidget(designview);
connect(designview, SIGNAL(info(std::string)), this, connect(designview, SIGNAL(info(std::string)), this, SLOT(writeInfo(std::string)));
SLOT(writeInfo(std::string)));
tabWidget = new QTabWidget(); tabWidget = new QTabWidget();
#ifndef NO_PYTHON #ifndef NO_PYTHON

View File

@ -37,10 +37,7 @@ enum class ElementType
class ElementTreeItem : public QTreeWidgetItem class ElementTreeItem : public QTreeWidgetItem
{ {
public: public:
ElementTreeItem(ElementType t, QString str) ElementTreeItem(ElementType t, QString str) : QTreeWidgetItem((QTreeWidget *)nullptr, QStringList(str)), type(t) {}
: QTreeWidgetItem((QTreeWidget *)nullptr, QStringList(str)), type(t)
{
}
virtual ~ElementTreeItem(){}; virtual ~ElementTreeItem(){};
ElementType getType() { return type; }; ElementType getType() { return type; };
@ -52,11 +49,7 @@ class ElementTreeItem : public QTreeWidgetItem
class BelTreeItem : public ElementTreeItem class BelTreeItem : public ElementTreeItem
{ {
public: public:
BelTreeItem(IdString d, ElementType type, QString str) BelTreeItem(IdString d, ElementType type, QString str) : ElementTreeItem(type, str) { this->data = d; }
: ElementTreeItem(type, str)
{
this->data = d;
}
virtual ~BelTreeItem(){}; virtual ~BelTreeItem(){};
IdString getData() { return this->data; }; IdString getData() { return this->data; };
@ -68,11 +61,7 @@ class BelTreeItem : public ElementTreeItem
class WireTreeItem : public ElementTreeItem class WireTreeItem : public ElementTreeItem
{ {
public: public:
WireTreeItem(IdString d, ElementType type, QString str) WireTreeItem(IdString d, ElementType type, QString str) : ElementTreeItem(type, str) { this->data = d; }
: ElementTreeItem(type, str)
{
this->data = d;
}
virtual ~WireTreeItem(){}; virtual ~WireTreeItem(){};
IdString getData() { return this->data; }; IdString getData() { return this->data; };
@ -84,11 +73,7 @@ class WireTreeItem : public ElementTreeItem
class PipTreeItem : public ElementTreeItem class PipTreeItem : public ElementTreeItem
{ {
public: public:
PipTreeItem(IdString d, ElementType type, QString str) PipTreeItem(IdString d, ElementType type, QString str) : ElementTreeItem(type, str) { this->data = d; }
: ElementTreeItem(type, str)
{
this->data = d;
}
virtual ~PipTreeItem(){}; virtual ~PipTreeItem(){};
IdString getData() { return this->data; }; IdString getData() { return this->data; };
@ -97,8 +82,7 @@ class PipTreeItem : public ElementTreeItem
IdString data; IdString data;
}; };
DesignWidget::DesignWidget(Context *_ctx, QWidget *parent) DesignWidget::DesignWidget(Context *_ctx, QWidget *parent) : QWidget(parent), ctx(_ctx)
: QWidget(parent), ctx(_ctx)
{ {
treeWidget = new QTreeWidget(); treeWidget = new QTreeWidget();
@ -115,8 +99,7 @@ DesignWidget::DesignWidget(Context *_ctx, QWidget *parent)
QList<QTreeWidgetItem *> bel_items; QList<QTreeWidgetItem *> bel_items;
for (auto bel : ctx->getBels()) { for (auto bel : ctx->getBels()) {
auto name = ctx->getBelName(bel); auto name = ctx->getBelName(bel);
bel_items.append(new BelTreeItem(name, ElementType::BEL, bel_items.append(new BelTreeItem(name, ElementType::BEL, QString(name.c_str(ctx))));
QString(name.c_str(ctx))));
} }
bel_root->addChildren(bel_items); bel_root->addChildren(bel_items);
@ -127,8 +110,7 @@ DesignWidget::DesignWidget(Context *_ctx, QWidget *parent)
treeWidget->insertTopLevelItem(0, wire_root); treeWidget->insertTopLevelItem(0, wire_root);
for (auto wire : ctx->getWires()) { for (auto wire : ctx->getWires()) {
auto name = ctx->getWireName(wire); auto name = ctx->getWireName(wire);
wire_items.append(new WireTreeItem(name, ElementType::WIRE, wire_items.append(new WireTreeItem(name, ElementType::WIRE, QString(name.c_str(ctx))));
QString(name.c_str(ctx))));
} }
wire_root->addChildren(wire_items); wire_root->addChildren(wire_items);
@ -139,8 +121,7 @@ DesignWidget::DesignWidget(Context *_ctx, QWidget *parent)
treeWidget->insertTopLevelItem(0, pip_root); treeWidget->insertTopLevelItem(0, pip_root);
for (auto pip : ctx->getPips()) { for (auto pip : ctx->getPips()) {
auto name = ctx->getPipName(pip); auto name = ctx->getPipName(pip);
pip_items.append(new PipTreeItem(name, ElementType::PIP, pip_items.append(new PipTreeItem(name, ElementType::PIP, QString(name.c_str(ctx))));
QString(name.c_str(ctx))));
} }
pip_root->addChildren(pip_items); pip_root->addChildren(pip_items);
@ -165,11 +146,9 @@ DesignWidget::DesignWidget(Context *_ctx, QWidget *parent)
setLayout(mainLayout); setLayout(mainLayout);
// Connection // Connection
connect(treeWidget, &QTreeWidget::customContextMenuRequested, this, connect(treeWidget, &QTreeWidget::customContextMenuRequested, this, &DesignWidget::prepareMenu);
&DesignWidget::prepareMenu);
connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), SLOT(onItemClicked(QTreeWidgetItem *, int)));
SLOT(onItemClicked(QTreeWidgetItem *, int)));
} }
DesignWidget::~DesignWidget() DesignWidget::~DesignWidget()
@ -188,8 +167,7 @@ void DesignWidget::addProperty(QtVariantProperty *property, const QString &id)
void DesignWidget::clearProperties() void DesignWidget::clearProperties()
{ {
QMap<QtProperty *, QString>::ConstIterator itProp = QMap<QtProperty *, QString>::ConstIterator itProp = propertyToId.constBegin();
propertyToId.constBegin();
while (itProp != propertyToId.constEnd()) { while (itProp != propertyToId.constEnd()) {
delete itProp.key(); delete itProp.key();
itProp++; itProp++;
@ -210,23 +188,20 @@ void DesignWidget::onItemClicked(QTreeWidgetItem *item, int pos)
if (type == ElementType::BEL) { if (type == ElementType::BEL) {
IdString c = static_cast<BelTreeItem *>(item)->getData(); IdString c = static_cast<BelTreeItem *>(item)->getData();
QtVariantProperty *topItem = QtVariantProperty *topItem = variantManager->addProperty(QVariant::String, QString("Name"));
variantManager->addProperty(QVariant::String, QString("Name"));
topItem->setValue(QString(c.c_str(ctx))); topItem->setValue(QString(c.c_str(ctx)));
addProperty(topItem, QString("Name")); addProperty(topItem, QString("Name"));
} else if (type == ElementType::WIRE) { } else if (type == ElementType::WIRE) {
IdString c = static_cast<WireTreeItem *>(item)->getData(); IdString c = static_cast<WireTreeItem *>(item)->getData();
QtVariantProperty *topItem = QtVariantProperty *topItem = variantManager->addProperty(QVariant::String, QString("Name"));
variantManager->addProperty(QVariant::String, QString("Name"));
topItem->setValue(QString(c.c_str(ctx))); topItem->setValue(QString(c.c_str(ctx)));
addProperty(topItem, QString("Name")); addProperty(topItem, QString("Name"));
} else if (type == ElementType::PIP) { } else if (type == ElementType::PIP) {
IdString c = static_cast<PipTreeItem *>(item)->getData(); IdString c = static_cast<PipTreeItem *>(item)->getData();
QtVariantProperty *topItem = QtVariantProperty *topItem = variantManager->addProperty(QVariant::String, QString("Name"));
variantManager->addProperty(QVariant::String, QString("Name"));
topItem->setValue(QString(c.c_str(ctx))); topItem->setValue(QString(c.c_str(ctx)));
addProperty(topItem, QString("Name")); addProperty(topItem, QString("Name"));
} }
@ -250,9 +225,6 @@ void DesignWidget::prepareMenu(const QPoint &pos)
menu.exec(tree->mapToGlobal(pos)); menu.exec(tree->mapToGlobal(pos));
} }
void DesignWidget::selectObject() void DesignWidget::selectObject() { Q_EMIT info("selected " + itemContextMenu->text(0).toStdString() + "\n"); }
{
Q_EMIT info("selected " + itemContextMenu->text(0).toStdString() + "\n");
}
NEXTPNR_NAMESPACE_END NEXTPNR_NAMESPACE_END

View File

@ -23,8 +23,7 @@ static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
NEXTPNR_NAMESPACE_BEGIN NEXTPNR_NAMESPACE_BEGIN
MainWindow::MainWindow(Context *_ctx, QWidget *parent) MainWindow::MainWindow(Context *_ctx, QWidget *parent) : BaseMainWindow(_ctx, parent)
: BaseMainWindow(_ctx, parent)
{ {
initMainResource(); initMainResource();

View File

@ -31,8 +31,8 @@
NEXTPNR_NAMESPACE_BEGIN NEXTPNR_NAMESPACE_BEGIN
void PolyLine::buildPoint(LineShaderData *building, const QVector2D *prev, void PolyLine::buildPoint(LineShaderData *building, const QVector2D *prev, const QVector2D *cur,
const QVector2D *cur, const QVector2D *next) const const QVector2D *next) const
{ {
// buildPoint emits two vertices per line point, along with normals to move // buildPoint emits two vertices per line point, along with normals to move
// them the right directio when rendering and miter to compensate for // them the right directio when rendering and miter to compensate for
@ -164,13 +164,10 @@ void PolyLine::build(LineShaderData &target) const
bool LineShader::compile(void) bool LineShader::compile(void)
{ {
program_ = new QOpenGLShaderProgram(parent_); program_ = new QOpenGLShaderProgram(parent_);
program_->addShaderFromSourceCode(QOpenGLShader::Vertex, program_->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource_);
vertexShaderSource_); program_->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource_);
program_->addShaderFromSourceCode(QOpenGLShader::Fragment,
fragmentShaderSource_);
if (!program_->link()) { if (!program_->link()) {
printf("could not link program: %s\n", printf("could not link program: %s\n", program_->log().toStdString().c_str());
program_->log().toStdString().c_str());
return false; return false;
} }
@ -205,44 +202,35 @@ void LineShader::draw(const LineShaderData &line, const QMatrix4x4 &projection)
program_->bind(); program_->bind();
buffers_.position.bind(); buffers_.position.bind();
buffers_.position.allocate(&line.vertices[0], buffers_.position.allocate(&line.vertices[0], sizeof(Vertex2DPOD) * line.vertices.size());
sizeof(Vertex2DPOD) * line.vertices.size());
buffers_.normal.bind(); buffers_.normal.bind();
buffers_.normal.allocate(&line.normals[0], buffers_.normal.allocate(&line.normals[0], sizeof(Vertex2DPOD) * line.normals.size());
sizeof(Vertex2DPOD) * line.normals.size());
buffers_.miter.bind(); buffers_.miter.bind();
buffers_.miter.allocate(&line.miters[0], buffers_.miter.allocate(&line.miters[0], sizeof(GLfloat) * line.miters.size());
sizeof(GLfloat) * line.miters.size());
buffers_.index.bind(); buffers_.index.bind();
buffers_.index.allocate(&line.indices[0], buffers_.index.allocate(&line.indices[0], sizeof(GLuint) * line.indices.size());
sizeof(GLuint) * line.indices.size());
program_->setUniformValue(uniforms_.projection, projection); program_->setUniformValue(uniforms_.projection, projection);
program_->setUniformValue(uniforms_.thickness, line.thickness); program_->setUniformValue(uniforms_.thickness, line.thickness);
program_->setUniformValue(uniforms_.color, line.color.r, line.color.g, program_->setUniformValue(uniforms_.color, line.color.r, line.color.g, line.color.b, line.color.a);
line.color.b, line.color.a);
buffers_.position.bind(); buffers_.position.bind();
program_->enableAttributeArray("position"); program_->enableAttributeArray("position");
gl->glVertexAttribPointer(attributes_.position, 2, GL_FLOAT, GL_FALSE, 0, gl->glVertexAttribPointer(attributes_.position, 2, GL_FLOAT, GL_FALSE, 0, (void *)0);
(void *)0);
buffers_.normal.bind(); buffers_.normal.bind();
program_->enableAttributeArray("normal"); program_->enableAttributeArray("normal");
gl->glVertexAttribPointer(attributes_.normal, 2, GL_FLOAT, GL_FALSE, 0, gl->glVertexAttribPointer(attributes_.normal, 2, GL_FLOAT, GL_FALSE, 0, (void *)0);
(void *)0);
buffers_.miter.bind(); buffers_.miter.bind();
program_->enableAttributeArray("miter"); program_->enableAttributeArray("miter");
gl->glVertexAttribPointer(attributes_.miter, 1, GL_FLOAT, GL_FALSE, 0, gl->glVertexAttribPointer(attributes_.miter, 1, GL_FLOAT, GL_FALSE, 0, (void *)0);
(void *)0);
buffers_.index.bind(); buffers_.index.bind();
gl->glDrawElements(GL_TRIANGLES, line.indices.size(), GL_UNSIGNED_INT, gl->glDrawElements(GL_TRIANGLES, line.indices.size(), GL_UNSIGNED_INT, (void *)0);
(void *)0);
program_->disableAttributeArray("miter"); program_->disableAttributeArray("miter");
program_->disableAttributeArray("normal"); program_->disableAttributeArray("normal");
@ -253,8 +241,7 @@ void LineShader::draw(const LineShaderData &line, const QMatrix4x4 &projection)
} }
FPGAViewWidget::FPGAViewWidget(QWidget *parent) FPGAViewWidget::FPGAViewWidget(QWidget *parent)
: QOpenGLWidget(parent), moveX_(0), moveY_(0), zoom_(10.0f), : QOpenGLWidget(parent), moveX_(0), moveY_(0), zoom_(10.0f), lineShader_(this)
lineShader_(this)
{ {
ctx_ = qobject_cast<BaseMainWindow *>(getMainWindow())->getContext(); ctx_ = qobject_cast<BaseMainWindow *>(getMainWindow())->getContext();
auto fmt = format(); auto fmt = format();
@ -263,8 +250,7 @@ FPGAViewWidget::FPGAViewWidget(QWidget *parent)
setFormat(fmt); setFormat(fmt);
fmt = format(); fmt = format();
printf("FPGAViewWidget running on OpenGL %d.%d\n", fmt.majorVersion(), printf("FPGAViewWidget running on OpenGL %d.%d\n", fmt.majorVersion(), fmt.minorVersion());
fmt.minorVersion());
if (fmt.majorVersion() < 3) { if (fmt.majorVersion() < 3) {
printf("Could not get OpenGL 3.0 context. Aborting.\n"); printf("Could not get OpenGL 3.0 context. Aborting.\n");
log_abort(); log_abort();
@ -344,8 +330,7 @@ void FPGAViewWidget::drawElement(LineShaderData &out, const GraphicElement &el)
} }
if (el.type == GraphicElement::G_LINE) { if (el.type == GraphicElement::G_LINE) {
PolyLine(offset + scale * el.x1, offset + scale * el.y1, PolyLine(offset + scale * el.x1, offset + scale * el.y1, offset + scale * el.x2, offset + scale * el.y2)
offset + scale * el.x2, offset + scale * el.y2)
.build(out); .build(out);
} }
} }

View File

@ -51,15 +51,8 @@ struct ColorPOD
GLfloat b; GLfloat b;
GLfloat a; GLfloat a;
ColorPOD(GLfloat R, GLfloat G, GLfloat B, GLfloat A) ColorPOD(GLfloat R, GLfloat G, GLfloat B, GLfloat A) : r(R), g(G), b(B), a(A) {}
: r(R), g(G), b(B), a(A) ColorPOD(const QColor &color) : r(color.redF()), g(color.greenF()), b(color.blueF()), a(color.alphaF()) {}
{
}
ColorPOD(const QColor &color)
: r(color.redF()), g(color.greenF()), b(color.blueF()),
a(color.alphaF())
{
}
} __attribute__((packed)); } __attribute__((packed));
// LineShaderData is a built set of vertices that can be rendered by the // LineShaderData is a built set of vertices that can be rendered by the
@ -75,10 +68,7 @@ struct LineShaderData
GLfloat thickness; GLfloat thickness;
ColorPOD color; ColorPOD color;
LineShaderData(GLfloat Thickness, QColor Color) LineShaderData(GLfloat Thickness, QColor Color) : thickness(Thickness), color(Color) {}
: thickness(Thickness), color(Color)
{
}
}; };
// PolyLine is a set of segments defined by points, that can be built to a // PolyLine is a set of segments defined by points, that can be built to a
@ -89,8 +79,7 @@ class PolyLine
std::vector<QVector2D> points_; std::vector<QVector2D> points_;
bool closed_; bool closed_;
void buildPoint(LineShaderData *building, const QVector2D *prev, void buildPoint(LineShaderData *building, const QVector2D *prev, const QVector2D *cur, const QVector2D *next) const;
const QVector2D *cur, const QVector2D *next) const;
public: public:
// Create an empty PolyLine. // Create an empty PolyLine.
@ -212,8 +201,7 @@ class LineShader
" gl_Position = projection * vec4(p, 0.0, 1.0);\n" " gl_Position = projection * vec4(p, 0.0, 1.0);\n"
"}\n"; "}\n";
static constexpr const char *fragmentShaderSource_ = static constexpr const char *fragmentShaderSource_ = "uniform lowp vec4 color;\n"
"uniform lowp vec4 color;\n"
"void main() {\n" "void main() {\n"
" gl_FragColor = color;\n" " gl_FragColor = color;\n"
"}\n"; "}\n";

View File

@ -36,8 +36,7 @@ static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
NEXTPNR_NAMESPACE_BEGIN NEXTPNR_NAMESPACE_BEGIN
MainWindow::MainWindow(Context *_ctx, QWidget *parent) MainWindow::MainWindow(Context *_ctx, QWidget *parent) : BaseMainWindow(_ctx, parent), timing_driven(false)
: BaseMainWindow(_ctx, parent), timing_driven(false)
{ {
initMainResource(); initMainResource();
@ -47,20 +46,16 @@ MainWindow::MainWindow(Context *_ctx, QWidget *parent)
task = new TaskManager(_ctx); task = new TaskManager(_ctx);
connect(task, SIGNAL(log(std::string)), this, SLOT(writeInfo(std::string))); connect(task, SIGNAL(log(std::string)), this, SLOT(writeInfo(std::string)));
connect(task, SIGNAL(loadfile_finished(bool)), this, connect(task, SIGNAL(loadfile_finished(bool)), this, SLOT(loadfile_finished(bool)));
SLOT(loadfile_finished(bool)));
connect(task, SIGNAL(pack_finished(bool)), this, SLOT(pack_finished(bool))); connect(task, SIGNAL(pack_finished(bool)), this, SLOT(pack_finished(bool)));
connect(task, SIGNAL(budget_finish(bool)), this, SLOT(budget_finish(bool))); connect(task, SIGNAL(budget_finish(bool)), this, SLOT(budget_finish(bool)));
connect(task, SIGNAL(place_finished(bool)), this, connect(task, SIGNAL(place_finished(bool)), this, SLOT(place_finished(bool)));
SLOT(place_finished(bool))); connect(task, SIGNAL(route_finished(bool)), this, SLOT(route_finished(bool)));
connect(task, SIGNAL(route_finished(bool)), this,
SLOT(route_finished(bool)));
connect(task, SIGNAL(taskCanceled()), this, SLOT(taskCanceled())); connect(task, SIGNAL(taskCanceled()), this, SLOT(taskCanceled()));
connect(task, SIGNAL(taskStarted()), this, SLOT(taskStarted())); connect(task, SIGNAL(taskStarted()), this, SLOT(taskStarted()));
connect(task, SIGNAL(taskPaused()), this, SLOT(taskPaused())); connect(task, SIGNAL(taskPaused()), this, SLOT(taskPaused()));
connect(this, SIGNAL(budget(double)), task, SIGNAL(budget(double))); connect(this, SIGNAL(budget(double)), task, SIGNAL(budget(double)));
connect(this, SIGNAL(place(bool)), task, SIGNAL(place(bool))); connect(this, SIGNAL(place(bool)), task, SIGNAL(place(bool)));
@ -153,8 +148,7 @@ void MainWindow::createMenu()
void MainWindow::open() void MainWindow::open()
{ {
QString fileName = QFileDialog::getOpenFileName(this, QString(), QString(), QString fileName = QFileDialog::getOpenFileName(this, QString(), QString(), QString("*.json"));
QString("*.json"));
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
tabWidget->setCurrentWidget(info); tabWidget->setCurrentWidget(info);
@ -254,21 +248,14 @@ void MainWindow::taskPaused()
void MainWindow::budget() void MainWindow::budget()
{ {
bool ok; bool ok;
double freq = QInputDialog::getDouble(this, "Assign timing budget", double freq = QInputDialog::getDouble(this, "Assign timing budget", "Frequency [MHz]:", 50, 0, 250, 2, &ok);
"Frequency [MHz]:",
50, 0, 250, 2, &ok);
if (ok) { if (ok) {
freq *= 1e6; freq *= 1e6;
timing_driven = true; timing_driven = true;
Q_EMIT budget(freq); Q_EMIT budget(freq);
} }
}
void MainWindow::place()
{
Q_EMIT place(timing_driven);
} }
void MainWindow::place() { Q_EMIT place(timing_driven); }
NEXTPNR_NAMESPACE_END NEXTPNR_NAMESPACE_END

View File

@ -125,14 +125,11 @@ TaskManager::TaskManager(Context *ctx) : toTerminate(false), toPause(false)
connect(this, &TaskManager::route, worker, &Worker::route); connect(this, &TaskManager::route, worker, &Worker::route);
connect(worker, &Worker::log, this, &TaskManager::info); connect(worker, &Worker::log, this, &TaskManager::info);
connect(worker, &Worker::loadfile_finished, this, connect(worker, &Worker::loadfile_finished, this, &TaskManager::loadfile_finished);
&TaskManager::loadfile_finished);
connect(worker, &Worker::pack_finished, this, &TaskManager::pack_finished); connect(worker, &Worker::pack_finished, this, &TaskManager::pack_finished);
connect(worker, &Worker::budget_finish, this, &TaskManager::budget_finish); connect(worker, &Worker::budget_finish, this, &TaskManager::budget_finish);
connect(worker, &Worker::place_finished, this, connect(worker, &Worker::place_finished, this, &TaskManager::place_finished);
&TaskManager::place_finished); connect(worker, &Worker::route_finished, this, &TaskManager::route_finished);
connect(worker, &Worker::route_finished, this,
&TaskManager::route_finished);
connect(worker, &Worker::taskCanceled, this, &TaskManager::taskCanceled); connect(worker, &Worker::taskCanceled, this, &TaskManager::taskCanceled);
connect(worker, &Worker::taskStarted, this, &TaskManager::taskStarted); connect(worker, &Worker::taskStarted, this, &TaskManager::taskStarted);

View File

@ -37,8 +37,7 @@ InfoTab::InfoTab(QWidget *parent) : QWidget(parent)
contextMenu = plainTextEdit->createStandardContextMenu(); contextMenu = plainTextEdit->createStandardContextMenu();
contextMenu->addSeparator(); contextMenu->addSeparator();
contextMenu->addAction(clearAction); contextMenu->addAction(clearAction);
connect(plainTextEdit, SIGNAL(customContextMenuRequested(const QPoint)), connect(plainTextEdit, SIGNAL(customContextMenuRequested(const QPoint)), this, SLOT(showContextMenu(const QPoint)));
this, SLOT(showContextMenu(const QPoint)));
QGridLayout *mainLayout = new QGridLayout(); QGridLayout *mainLayout = new QGridLayout();
mainLayout->addWidget(plainTextEdit); mainLayout->addWidget(plainTextEdit);
@ -52,10 +51,7 @@ void InfoTab::info(std::string str)
plainTextEdit->moveCursor(QTextCursor::End); plainTextEdit->moveCursor(QTextCursor::End);
} }
void InfoTab::showContextMenu(const QPoint &pt) void InfoTab::showContextMenu(const QPoint &pt) { contextMenu->exec(mapToGlobal(pt)); }
{
contextMenu->exec(mapToGlobal(pt));
}
void InfoTab::clearBuffer() { plainTextEdit->clear(); } void InfoTab::clearBuffer() { plainTextEdit->clear(); }

View File

@ -33,8 +33,7 @@ LineEditor::LineEditor(QWidget *parent) : QLineEdit(parent), index(0)
contextMenu->addAction(clearAction); contextMenu->addAction(clearAction);
connect(this, SIGNAL(returnPressed()), SLOT(textInserted())); connect(this, SIGNAL(returnPressed()), SLOT(textInserted()));
connect(this, SIGNAL(customContextMenuRequested(const QPoint)), this, connect(this, SIGNAL(customContextMenuRequested(const QPoint)), this, SLOT(showContextMenu(const QPoint)));
SLOT(showContextMenu(const QPoint)));
} }
void LineEditor::keyPressEvent(QKeyEvent *ev) void LineEditor::keyPressEvent(QKeyEvent *ev)
@ -74,10 +73,7 @@ void LineEditor::textInserted()
Q_EMIT textLineInserted(lines.back()); Q_EMIT textLineInserted(lines.back());
} }
void LineEditor::showContextMenu(const QPoint &pt) void LineEditor::showContextMenu(const QPoint &pt) { contextMenu->exec(mapToGlobal(pt)); }
{
contextMenu->exec(mapToGlobal(pt));
}
void LineEditor::clearHistory() void LineEditor::clearHistory()
{ {

View File

@ -16,7 +16,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* *
*/ */
#ifndef NO_PYTHON #ifndef NO_PYTHON
#include "pythontab.h" #include "pythontab.h"
#include <QGridLayout> #include <QGridLayout>
@ -44,8 +44,7 @@ PythonTab::PythonTab(QWidget *parent) : QWidget(parent)
contextMenu = plainTextEdit->createStandardContextMenu(); contextMenu = plainTextEdit->createStandardContextMenu();
contextMenu->addSeparator(); contextMenu->addSeparator();
contextMenu->addAction(clearAction); contextMenu->addAction(clearAction);
connect(plainTextEdit, SIGNAL(customContextMenuRequested(const QPoint)), connect(plainTextEdit, SIGNAL(customContextMenuRequested(const QPoint)), this, SLOT(showContextMenu(const QPoint)));
this, SLOT(showContextMenu(const QPoint)));
lineEdit = new LineEditor(); lineEdit = new LineEditor();
lineEdit->setMinimumHeight(30); lineEdit->setMinimumHeight(30);
@ -57,8 +56,7 @@ PythonTab::PythonTab(QWidget *parent) : QWidget(parent)
mainLayout->addWidget(lineEdit, 1, 0); mainLayout->addWidget(lineEdit, 1, 0);
setLayout(mainLayout); setLayout(mainLayout);
connect(lineEdit, SIGNAL(textLineInserted(QString)), this, connect(lineEdit, SIGNAL(textLineInserted(QString)), this, SLOT(editLineReturnPressed(QString)));
SLOT(editLineReturnPressed(QString)));
write = [this](std::string s) { write = [this](std::string s) {
plainTextEdit->moveCursor(QTextCursor::End); plainTextEdit->moveCursor(QTextCursor::End);
@ -88,9 +86,7 @@ int PythonTab::executePython(std::string &command)
if (m == NULL) if (m == NULL)
return -1; return -1;
d = PyModule_GetDict(m); d = PyModule_GetDict(m);
v = PyRun_StringFlags(command.c_str(), v = PyRun_StringFlags(command.c_str(), (command.empty() ? Py_file_input : Py_single_input), d, d, NULL);
(command.empty() ? Py_file_input : Py_single_input),
d, d, NULL);
if (v == NULL) { if (v == NULL) {
PyObject *exception, *v, *tb; PyObject *exception, *v, *tb;
@ -111,8 +107,7 @@ int PythonTab::executePython(std::string &command)
PyErr_Clear(); PyErr_Clear();
PyObject *objectsRepresentation = PyObject_Str(v); PyObject *objectsRepresentation = PyObject_Str(v);
std::string errorStr = std::string errorStr = PyUnicode_AsUTF8(objectsRepresentation) + std::string("\n");
PyUnicode_AsUTF8(objectsRepresentation) + std::string("\n");
print(errorStr); print(errorStr);
Py_DECREF(objectsRepresentation); Py_DECREF(objectsRepresentation);
Py_XDECREF(exception); Py_XDECREF(exception);
@ -131,10 +126,7 @@ void PythonTab::editLineReturnPressed(QString text)
executePython(input); executePython(input);
} }
void PythonTab::showContextMenu(const QPoint &pt) void PythonTab::showContextMenu(const QPoint &pt) { contextMenu->exec(mapToGlobal(pt)); }
{
contextMenu->exec(mapToGlobal(pt));
}
void PythonTab::clearBuffer() { plainTextEdit->clear(); } void PythonTab::clearBuffer() { plainTextEdit->clear(); }

View File

@ -59,8 +59,7 @@ TEST_F(HX1KTest, uphill_to_downhill)
for (auto dst : ctx->getWires()) { for (auto dst : ctx->getWires()) {
for (auto uphill_pip : ctx->getPipsUphill(dst)) { for (auto uphill_pip : ctx->getPipsUphill(dst)) {
bool found_downhill = false; bool found_downhill = false;
for (auto downhill_pip : ctx->getPipsDownhill( for (auto downhill_pip : ctx->getPipsDownhill(ctx->getPipSrcWire(uphill_pip))) {
ctx->getPipSrcWire(uphill_pip))) {
if (uphill_pip == downhill_pip) { if (uphill_pip == downhill_pip) {
ASSERT_FALSE(found_downhill); ASSERT_FALSE(found_downhill);
found_downhill = true; found_downhill = true;
@ -76,8 +75,7 @@ TEST_F(HX1KTest, downhill_to_uphill)
for (auto dst : ctx->getWires()) { for (auto dst : ctx->getWires()) {
for (auto downhill_pip : ctx->getPipsDownhill(dst)) { for (auto downhill_pip : ctx->getPipsDownhill(dst)) {
bool found_uphill = false; bool found_uphill = false;
for (auto uphill_pip : ctx->getPipsUphill( for (auto uphill_pip : ctx->getPipsUphill(ctx->getPipDstWire(downhill_pip))) {
ctx->getPipDstWire(downhill_pip))) {
if (uphill_pip == downhill_pip) { if (uphill_pip == downhill_pip) {
ASSERT_FALSE(found_uphill); ASSERT_FALSE(found_uphill);
found_uphill = true; found_uphill = true;

View File

@ -59,8 +59,7 @@ TEST_F(HX8KTest, uphill_to_downhill)
for (auto dst : ctx->getWires()) { for (auto dst : ctx->getWires()) {
for (auto uphill_pip : ctx->getPipsUphill(dst)) { for (auto uphill_pip : ctx->getPipsUphill(dst)) {
bool found_downhill = false; bool found_downhill = false;
for (auto downhill_pip : ctx->getPipsDownhill( for (auto downhill_pip : ctx->getPipsDownhill(ctx->getPipSrcWire(uphill_pip))) {
ctx->getPipSrcWire(uphill_pip))) {
if (uphill_pip == downhill_pip) { if (uphill_pip == downhill_pip) {
ASSERT_FALSE(found_downhill); ASSERT_FALSE(found_downhill);
found_downhill = true; found_downhill = true;
@ -76,8 +75,7 @@ TEST_F(HX8KTest, downhill_to_uphill)
for (auto dst : ctx->getWires()) { for (auto dst : ctx->getWires()) {
for (auto downhill_pip : ctx->getPipsDownhill(dst)) { for (auto downhill_pip : ctx->getPipsDownhill(dst)) {
bool found_uphill = false; bool found_uphill = false;
for (auto uphill_pip : ctx->getPipsUphill( for (auto uphill_pip : ctx->getPipsUphill(ctx->getPipDstWire(downhill_pip))) {
ctx->getPipDstWire(downhill_pip))) {
if (uphill_pip == downhill_pip) { if (uphill_pip == downhill_pip) {
ASSERT_FALSE(found_uphill); ASSERT_FALSE(found_uphill);
found_uphill = true; found_uphill = true;

View File

@ -59,8 +59,7 @@ TEST_F(LP1KTest, uphill_to_downhill)
for (auto dst : ctx->getWires()) { for (auto dst : ctx->getWires()) {
for (auto uphill_pip : ctx->getPipsUphill(dst)) { for (auto uphill_pip : ctx->getPipsUphill(dst)) {
bool found_downhill = false; bool found_downhill = false;
for (auto downhill_pip : ctx->getPipsDownhill( for (auto downhill_pip : ctx->getPipsDownhill(ctx->getPipSrcWire(uphill_pip))) {
ctx->getPipSrcWire(uphill_pip))) {
if (uphill_pip == downhill_pip) { if (uphill_pip == downhill_pip) {
ASSERT_FALSE(found_downhill); ASSERT_FALSE(found_downhill);
found_downhill = true; found_downhill = true;
@ -76,8 +75,7 @@ TEST_F(LP1KTest, downhill_to_uphill)
for (auto dst : ctx->getWires()) { for (auto dst : ctx->getWires()) {
for (auto downhill_pip : ctx->getPipsDownhill(dst)) { for (auto downhill_pip : ctx->getPipsDownhill(dst)) {
bool found_uphill = false; bool found_uphill = false;
for (auto uphill_pip : ctx->getPipsUphill( for (auto uphill_pip : ctx->getPipsUphill(ctx->getPipDstWire(downhill_pip))) {
ctx->getPipDstWire(downhill_pip))) {
if (uphill_pip == downhill_pip) { if (uphill_pip == downhill_pip) {
ASSERT_FALSE(found_uphill); ASSERT_FALSE(found_uphill);
found_uphill = true; found_uphill = true;

View File

@ -59,8 +59,7 @@ TEST_F(LP384Test, uphill_to_downhill)
for (auto dst : ctx->getWires()) { for (auto dst : ctx->getWires()) {
for (auto uphill_pip : ctx->getPipsUphill(dst)) { for (auto uphill_pip : ctx->getPipsUphill(dst)) {
bool found_downhill = false; bool found_downhill = false;
for (auto downhill_pip : ctx->getPipsDownhill( for (auto downhill_pip : ctx->getPipsDownhill(ctx->getPipSrcWire(uphill_pip))) {
ctx->getPipSrcWire(uphill_pip))) {
if (uphill_pip == downhill_pip) { if (uphill_pip == downhill_pip) {
ASSERT_FALSE(found_downhill); ASSERT_FALSE(found_downhill);
found_downhill = true; found_downhill = true;
@ -76,8 +75,7 @@ TEST_F(LP384Test, downhill_to_uphill)
for (auto dst : ctx->getWires()) { for (auto dst : ctx->getWires()) {
for (auto downhill_pip : ctx->getPipsDownhill(dst)) { for (auto downhill_pip : ctx->getPipsDownhill(dst)) {
bool found_uphill = false; bool found_uphill = false;
for (auto uphill_pip : ctx->getPipsUphill( for (auto uphill_pip : ctx->getPipsUphill(ctx->getPipDstWire(downhill_pip))) {
ctx->getPipDstWire(downhill_pip))) {
if (uphill_pip == downhill_pip) { if (uphill_pip == downhill_pip) {
ASSERT_FALSE(found_uphill); ASSERT_FALSE(found_uphill);
found_uphill = true; found_uphill = true;

View File

@ -59,8 +59,7 @@ TEST_F(LP8KTest, uphill_to_downhill)
for (auto dst : ctx->getWires()) { for (auto dst : ctx->getWires()) {
for (auto uphill_pip : ctx->getPipsUphill(dst)) { for (auto uphill_pip : ctx->getPipsUphill(dst)) {
bool found_downhill = false; bool found_downhill = false;
for (auto downhill_pip : ctx->getPipsDownhill( for (auto downhill_pip : ctx->getPipsDownhill(ctx->getPipSrcWire(uphill_pip))) {
ctx->getPipSrcWire(uphill_pip))) {
if (uphill_pip == downhill_pip) { if (uphill_pip == downhill_pip) {
ASSERT_FALSE(found_downhill); ASSERT_FALSE(found_downhill);
found_downhill = true; found_downhill = true;
@ -76,8 +75,7 @@ TEST_F(LP8KTest, downhill_to_uphill)
for (auto dst : ctx->getWires()) { for (auto dst : ctx->getWires()) {
for (auto downhill_pip : ctx->getPipsDownhill(dst)) { for (auto downhill_pip : ctx->getPipsDownhill(dst)) {
bool found_uphill = false; bool found_uphill = false;
for (auto uphill_pip : ctx->getPipsUphill( for (auto uphill_pip : ctx->getPipsUphill(ctx->getPipDstWire(downhill_pip))) {
ctx->getPipDstWire(downhill_pip))) {
if (uphill_pip == downhill_pip) { if (uphill_pip == downhill_pip) {
ASSERT_FALSE(found_uphill); ASSERT_FALSE(found_uphill);
found_uphill = true; found_uphill = true;

View File

@ -59,8 +59,7 @@ TEST_F(UP5KTest, uphill_to_downhill)
for (auto dst : ctx->getWires()) { for (auto dst : ctx->getWires()) {
for (auto uphill_pip : ctx->getPipsUphill(dst)) { for (auto uphill_pip : ctx->getPipsUphill(dst)) {
bool found_downhill = false; bool found_downhill = false;
for (auto downhill_pip : ctx->getPipsDownhill( for (auto downhill_pip : ctx->getPipsDownhill(ctx->getPipSrcWire(uphill_pip))) {
ctx->getPipSrcWire(uphill_pip))) {
if (uphill_pip == downhill_pip) { if (uphill_pip == downhill_pip) {
ASSERT_FALSE(found_downhill); ASSERT_FALSE(found_downhill);
found_downhill = true; found_downhill = true;
@ -76,8 +75,7 @@ TEST_F(UP5KTest, downhill_to_uphill)
for (auto dst : ctx->getWires()) { for (auto dst : ctx->getWires()) {
for (auto downhill_pip : ctx->getPipsDownhill(dst)) { for (auto downhill_pip : ctx->getPipsDownhill(dst)) {
bool found_uphill = false; bool found_uphill = false;
for (auto uphill_pip : ctx->getPipsUphill( for (auto uphill_pip : ctx->getPipsUphill(ctx->getPipDstWire(downhill_pip))) {
ctx->getPipDstWire(downhill_pip))) {
if (uphill_pip == downhill_pip) { if (uphill_pip == downhill_pip) {
ASSERT_FALSE(found_uphill); ASSERT_FALSE(found_uphill);
found_uphill = true; found_uphill = true;