From f2fecc3c69a4b98b5ee39e4e855e6402c7dd34ab Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 28 Nov 2018 17:04:10 +0100 Subject: [PATCH] make gui run --- common/log.h | 10 +++ gui/application.cc | 6 +- gui/xc7/family.cmake | 1 + gui/xc7/mainwindow.cc | 51 +++++++++++++ gui/xc7/mainwindow.h | 45 ++++++++++++ gui/xc7/nextpnr.qrc | 2 + xc7/arch.cc | 163 +++++++---------------------------------- xc7/arch.h | 4 + xc7/arch_pybindings.cc | 12 +-- xc7/arch_pybindings.h | 7 ++ 10 files changed, 150 insertions(+), 151 deletions(-) create mode 100644 gui/xc7/family.cmake create mode 100644 gui/xc7/mainwindow.cc create mode 100644 gui/xc7/mainwindow.h create mode 100644 gui/xc7/nextpnr.qrc diff --git a/common/log.h b/common/log.h index 77adbb2f..52158f18 100644 --- a/common/log.h +++ b/common/log.h @@ -84,4 +84,14 @@ static inline void log_assert_worker(bool cond, const char *expr, const char *fi NEXTPNR_NAMESPACE_END +namespace std { +template <> struct hash +{ + std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX LogLevel &loglevel) const noexcept + { + return std::hash()((int)loglevel); + } +}; +} // namespace std + #endif diff --git a/gui/application.cc b/gui/application.cc index aece5d2a..ccbf5645 100644 --- a/gui/application.cc +++ b/gui/application.cc @@ -50,9 +50,9 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv) bool Application::notify(QObject *receiver, QEvent *event) { bool retVal = true; - try { + //try { retVal = QApplication::notify(receiver, event); - } catch (assertion_failure ex) { + /*} catch (assertion_failure ex) { QString msg; QTextStream out(&msg); out << ex.filename.c_str() << " at " << ex.line << "\n"; @@ -60,7 +60,7 @@ bool Application::notify(QObject *receiver, QEvent *event) QMessageBox::critical(0, "Error", msg); } catch (...) { QMessageBox::critical(0, "Error", "Fatal error !!!"); - } + }*/ return retVal; } diff --git a/gui/xc7/family.cmake b/gui/xc7/family.cmake new file mode 100644 index 00000000..3b010c7b --- /dev/null +++ b/gui/xc7/family.cmake @@ -0,0 +1 @@ +include_directories(/opt/torc/src) \ No newline at end of file diff --git a/gui/xc7/mainwindow.cc b/gui/xc7/mainwindow.cc new file mode 100644 index 00000000..3ee64727 --- /dev/null +++ b/gui/xc7/mainwindow.cc @@ -0,0 +1,51 @@ +/* + * nextpnr -- Next Generation Place and Route + * + * Copyright (C) 2018 Miodrag Milanovic + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +#include "mainwindow.h" + +static void initMainResource() { Q_INIT_RESOURCE(nextpnr); } + +NEXTPNR_NAMESPACE_BEGIN + +MainWindow::MainWindow(std::unique_ptr context, ArchArgs args, QWidget *parent) + : BaseMainWindow(std::move(context), args, parent) +{ + initMainResource(); + + std::string title = "nextpnr-xc7 - [EMPTY]"; + setWindowTitle(title.c_str()); + + connect(this, &BaseMainWindow::contextChanged, this, &MainWindow::newContext); + + createMenu(); +} + +MainWindow::~MainWindow() {} + +void MainWindow::newContext(Context *ctx) +{ + std::string title = "nextpnr-xc7 - " + ctx->getChipName(); + setWindowTitle(title.c_str()); +} + +void MainWindow::createMenu() {} + +void MainWindow::new_proj() {} + +NEXTPNR_NAMESPACE_END diff --git a/gui/xc7/mainwindow.h b/gui/xc7/mainwindow.h new file mode 100644 index 00000000..bb6a4cf1 --- /dev/null +++ b/gui/xc7/mainwindow.h @@ -0,0 +1,45 @@ +/* + * nextpnr -- Next Generation Place and Route + * + * Copyright (C) 2018 Miodrag Milanovic + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include "../basewindow.h" + +NEXTPNR_NAMESPACE_BEGIN + +class MainWindow : public BaseMainWindow +{ + Q_OBJECT + + public: + explicit MainWindow(std::unique_ptr context, ArchArgs args, QWidget *parent = 0); + virtual ~MainWindow(); + + public: + void createMenu(); + + protected Q_SLOTS: + void new_proj() override; + void newContext(Context *ctx); +}; + +NEXTPNR_NAMESPACE_END + +#endif // MAINWINDOW_H diff --git a/gui/xc7/nextpnr.qrc b/gui/xc7/nextpnr.qrc new file mode 100644 index 00000000..03585ec0 --- /dev/null +++ b/gui/xc7/nextpnr.qrc @@ -0,0 +1,2 @@ + + diff --git a/xc7/arch.cc b/xc7/arch.cc index d95453e3..13c1537a 100644 --- a/xc7/arch.cc +++ b/xc7/arch.cc @@ -455,6 +455,12 @@ PortType Arch::getBelPinType(BelId bel, IdString pin) const return PORT_INOUT; } +std::vector> Arch::getBelAttrs(BelId bel) const +{ + std::vector> ret; + return ret; +} + WireId Arch::getBelPinWire(BelId bel, IdString pin) const { auto pin_name = pin.str(this); @@ -533,14 +539,14 @@ std::vector Arch::getBelPins(BelId bel) const { std::vector ret; - NPNR_ASSERT(bel != BelId()); +/* NPNR_ASSERT(bel != BelId()); int num_bel_wires = chip_info->bel_data[bel.index].num_bel_wires; const BelWirePOD *bel_wires = chip_info->bel_data[bel.index].bel_wires.get(); for (int i = 0; i < num_bel_wires; i++) ret.push_back(IdString(bel_wires[i].port)); - +*/ return ret; } @@ -600,13 +606,20 @@ IdString Arch::getWireType(WireId wire) const return IdString(); } +// ----------------------------------------------------------------------- +std::vector> Arch::getWireAttrs(WireId wire) const +{ + std::vector> ret; + return ret; +} + // ----------------------------------------------------------------------- PipId Arch::getPipByName(IdString name) const { PipId ret; - if (pip_by_name.empty()) { +/* if (pip_by_name.empty()) { for (int i = 0; i < chip_info->num_pips; i++) { PipId pip; pip.index = i; @@ -617,7 +630,7 @@ PipId Arch::getPipByName(IdString name) const auto it = pip_by_name.find(name); if (it != pip_by_name.end()) ret.index = it->second; - +*/ return ret; } @@ -647,6 +660,13 @@ IdString Arch::getPipName(PipId pip) const //#endif } +std::vector> Arch::getPipAttrs(PipId pip) const +{ + std::vector> ret; + + return ret; +} + // ----------------------------------------------------------------------- BelId Arch::getPackagePinBel(const std::string &pin) const { return getBelByName(id(pin)); } @@ -719,7 +739,7 @@ IdString Arch::getGroupName(GroupId group) const std::vector Arch::getGroups() const { std::vector ret; - +/* for (int y = 0; y < chip_info->height; y++) { for (int x = 0; x < chip_info->width; x++) { TileType type = chip_info->tile_grid[y * chip_info->width + x]; @@ -764,7 +784,7 @@ std::vector Arch::getGroups() const ret.push_back(group); } } - } + }*/ return ret; } @@ -843,137 +863,6 @@ DecalXY Arch::getGroupDecal(GroupId group) const std::vector Arch::getDecalGraphics(DecalId decal) const { std::vector ret; - - if (decal.type == DecalId::TYPE_GROUP) { - int type = (decal.index >> 16) & 255; - int x = (decal.index >> 8) & 255; - int y = decal.index & 255; - - if (type == GroupId::TYPE_FRAME) { - GraphicElement el; - el.type = GraphicElement::TYPE_LINE; - el.style = GraphicElement::STYLE_FRAME; - - el.x1 = x + 0.01, el.x2 = x + 0.02, el.y1 = y + 0.01, el.y2 = y + 0.01; - ret.push_back(el); - el.x1 = x + 0.01, el.x2 = x + 0.01, el.y1 = y + 0.01, el.y2 = y + 0.02; - ret.push_back(el); - - el.x1 = x + 0.99, el.x2 = x + 0.98, el.y1 = y + 0.01, el.y2 = y + 0.01; - ret.push_back(el); - el.x1 = x + 0.99, el.x2 = x + 0.99, el.y1 = y + 0.01, el.y2 = y + 0.02; - ret.push_back(el); - - el.x1 = x + 0.99, el.x2 = x + 0.98, el.y1 = y + 0.99, el.y2 = y + 0.99; - ret.push_back(el); - el.x1 = x + 0.99, el.x2 = x + 0.99, el.y1 = y + 0.99, el.y2 = y + 0.98; - ret.push_back(el); - - el.x1 = x + 0.01, el.x2 = x + 0.02, el.y1 = y + 0.99, el.y2 = y + 0.99; - ret.push_back(el); - el.x1 = x + 0.01, el.x2 = x + 0.01, el.y1 = y + 0.99, el.y2 = y + 0.98; - ret.push_back(el); - } - - if (type == GroupId::TYPE_MAIN_SW) { - GraphicElement el; - el.type = GraphicElement::TYPE_BOX; - el.style = GraphicElement::STYLE_FRAME; - - el.x1 = x + main_swbox_x1; - el.x2 = x + main_swbox_x2; - el.y1 = y + main_swbox_y1; - el.y2 = y + main_swbox_y2; - ret.push_back(el); - } - - if (type == GroupId::TYPE_LOCAL_SW) { - GraphicElement el; - el.type = GraphicElement::TYPE_BOX; - el.style = GraphicElement::STYLE_FRAME; - - el.x1 = x + local_swbox_x1; - el.x2 = x + local_swbox_x2; - el.y1 = y + local_swbox_y1; - el.y2 = y + local_swbox_y2; - ret.push_back(el); - } - - if (GroupId::TYPE_LC0_SW <= type && type <= GroupId::TYPE_LC7_SW) { - GraphicElement el; - el.type = GraphicElement::TYPE_BOX; - el.style = GraphicElement::STYLE_FRAME; - - el.x1 = x + lut_swbox_x1; - el.x2 = x + lut_swbox_x2; - el.y1 = y + logic_cell_y1 + logic_cell_pitch * (type - GroupId::TYPE_LC0_SW); - el.y2 = y + logic_cell_y2 + logic_cell_pitch * (type - GroupId::TYPE_LC0_SW); - ret.push_back(el); - } - } - - if (decal.type == DecalId::TYPE_WIRE) { - int n = chip_info->wire_data[decal.index].num_segments; - const WireSegmentPOD *p = chip_info->wire_data[decal.index].segments.get(); - - GraphicElement::style_t style = decal.active ? GraphicElement::STYLE_ACTIVE : GraphicElement::STYLE_INACTIVE; - - for (int i = 0; i < n; i++) - gfxTileWire(ret, p[i].x, p[i].y, GfxTileWireId(p[i].index), style); - } - - if (decal.type == DecalId::TYPE_PIP) { - const PipInfoPOD &p = chip_info->pip_data[decal.index]; - GraphicElement::style_t style = decal.active ? GraphicElement::STYLE_ACTIVE : GraphicElement::STYLE_HIDDEN; - gfxTilePip(ret, p.x, p.y, GfxTileWireId(p.src_seg), GfxTileWireId(p.dst_seg), style); - } - - if (decal.type == DecalId::TYPE_BEL) { - BelId bel; - bel.index = SiteIndex(decal.index); - - auto bel_type = getBelType(bel); - - if (bel_type == id_ICESTORM_LC) { - GraphicElement el; - el.type = GraphicElement::TYPE_BOX; - el.style = decal.active ? GraphicElement::STYLE_ACTIVE : GraphicElement::STYLE_INACTIVE; - el.x1 = chip_info->bel_data[bel.index].x + logic_cell_x1; - el.x2 = chip_info->bel_data[bel.index].x + logic_cell_x2; - el.y1 = chip_info->bel_data[bel.index].y + logic_cell_y1 + - (chip_info->bel_data[bel.index].z) * logic_cell_pitch; - el.y2 = chip_info->bel_data[bel.index].y + logic_cell_y2 + - (chip_info->bel_data[bel.index].z) * logic_cell_pitch; - ret.push_back(el); - } - - if (bel_type == id_SB_IO) { - GraphicElement el; - el.type = GraphicElement::TYPE_BOX; - el.style = decal.active ? GraphicElement::STYLE_ACTIVE : GraphicElement::STYLE_INACTIVE; - el.x1 = chip_info->bel_data[bel.index].x + logic_cell_x1; - el.x2 = chip_info->bel_data[bel.index].x + logic_cell_x2; - el.y1 = chip_info->bel_data[bel.index].y + logic_cell_y1 + - (4 * chip_info->bel_data[bel.index].z) * logic_cell_pitch; - el.y2 = chip_info->bel_data[bel.index].y + logic_cell_y2 + - (4 * chip_info->bel_data[bel.index].z + 3) * logic_cell_pitch; - ret.push_back(el); - } - - if (bel_type == id_ICESTORM_RAM) { - for (int i = 0; i < 2; i++) { - GraphicElement el; - el.type = GraphicElement::TYPE_BOX; - el.style = decal.active ? GraphicElement::STYLE_ACTIVE : GraphicElement::STYLE_INACTIVE; - el.x1 = chip_info->bel_data[bel.index].x + logic_cell_x1; - el.x2 = chip_info->bel_data[bel.index].x + logic_cell_x2; - el.y1 = chip_info->bel_data[bel.index].y + logic_cell_y1 + i; - el.y2 = chip_info->bel_data[bel.index].y + logic_cell_y2 + i + 7 * logic_cell_pitch; - ret.push_back(el); - } - } - } - return ret; } diff --git a/xc7/arch.h b/xc7/arch.h index 648ace00..b106d9ab 100644 --- a/xc7/arch.h +++ b/xc7/arch.h @@ -625,6 +625,8 @@ struct Arch : BaseCtx return torc_info->site_index_to_type[site_index]; } + std::vector> getBelAttrs(BelId bel) const; + WireId getBelPinWire(BelId bel, IdString pin) const; PortType getBelPinType(BelId bel, IdString pin) const; std::vector getBelPins(BelId bel) const; @@ -640,6 +642,7 @@ struct Arch : BaseCtx } IdString getWireType(WireId wire) const; + std::vector> getWireAttrs(WireId wire) const; uint32_t getWireChecksum(WireId wire) const { return wire.index; } @@ -816,6 +819,7 @@ struct Arch : BaseCtx IdString getPipName(PipId pip) const; IdString getPipType(PipId pip) const { return IdString(); } + std::vector> getPipAttrs(PipId pip) const; uint32_t getPipChecksum(PipId pip) const { return pip.index; } diff --git a/xc7/arch_pybindings.cc b/xc7/arch_pybindings.cc index f1639ba6..04d9d5d9 100644 --- a/xc7/arch_pybindings.cc +++ b/xc7/arch_pybindings.cc @@ -31,21 +31,11 @@ void arch_wrap_python() using namespace PythonConversion; class_("ArchArgs").def_readwrite("type", &ArchArgs::type); - enum_().type)>("iCE40Type") - .value("NONE", ArchArgs::NONE) - .value("LP384", ArchArgs::LP384) - .value("LP1K", ArchArgs::LP1K) - .value("LP8K", ArchArgs::LP8K) - .value("HX1K", ArchArgs::HX1K) - .value("HX8K", ArchArgs::HX8K) - .value("UP5K", ArchArgs::UP5K) - .export_values(); - class_("BelId").def_readwrite("index", &BelId::index); class_("WireId").def_readwrite("index", &WireId::index); - class_("PipId").def_readwrite("index", &PipId::index); + class_("PipId").def_readwrite("index", &PipId::index); class_("BelPin").def_readwrite("bel", &BelPin::bel).def_readwrite("pin", &BelPin::pin); diff --git a/xc7/arch_pybindings.h b/xc7/arch_pybindings.h index 070c2396..c2c67aa2 100644 --- a/xc7/arch_pybindings.h +++ b/xc7/arch_pybindings.h @@ -48,6 +48,13 @@ template <> struct string_converter std::string to_str(Context *ctx, WireId id) { return ctx->getWireName(id).str(ctx); } }; +template <> struct string_converter +{ + WireId from_str(Context *ctx, std::string name) { return ctx->getWireByName(ctx->id(name)); } + + std::string to_str(Context *ctx, WireId id) { return ctx->getWireName(id).str(ctx); } +}; + template <> struct string_converter { PipId from_str(Context *ctx, std::string name) { return ctx->getPipByName(ctx->id(name)); }