make gui run
This commit is contained in:
parent
212b03999b
commit
f2fecc3c69
10
common/log.h
10
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<NEXTPNR_NAMESPACE_PREFIX LogLevel>
|
||||
{
|
||||
std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX LogLevel &loglevel) const noexcept
|
||||
{
|
||||
return std::hash<int>()((int)loglevel);
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
#endif
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
1
gui/xc7/family.cmake
Normal file
1
gui/xc7/family.cmake
Normal file
@ -0,0 +1 @@
|
||||
include_directories(/opt/torc/src)
|
51
gui/xc7/mainwindow.cc
Normal file
51
gui/xc7/mainwindow.cc
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* nextpnr -- Next Generation Place and Route
|
||||
*
|
||||
* Copyright (C) 2018 Miodrag Milanovic <miodrag@symbioticeda.com>
|
||||
*
|
||||
* 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> 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
|
45
gui/xc7/mainwindow.h
Normal file
45
gui/xc7/mainwindow.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* nextpnr -- Next Generation Place and Route
|
||||
*
|
||||
* Copyright (C) 2018 Miodrag Milanovic <miodrag@symbioticeda.com>
|
||||
*
|
||||
* 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> 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
|
2
gui/xc7/nextpnr.qrc
Normal file
2
gui/xc7/nextpnr.qrc
Normal file
@ -0,0 +1,2 @@
|
||||
<RCC>
|
||||
</RCC>
|
163
xc7/arch.cc
163
xc7/arch.cc
@ -455,6 +455,12 @@ PortType Arch::getBelPinType(BelId bel, IdString pin) const
|
||||
return PORT_INOUT;
|
||||
}
|
||||
|
||||
std::vector<std::pair<IdString, std::string>> Arch::getBelAttrs(BelId bel) const
|
||||
{
|
||||
std::vector<std::pair<IdString, std::string>> ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
WireId Arch::getBelPinWire(BelId bel, IdString pin) const
|
||||
{
|
||||
auto pin_name = pin.str(this);
|
||||
@ -533,14 +539,14 @@ std::vector<IdString> Arch::getBelPins(BelId bel) const
|
||||
{
|
||||
std::vector<IdString> 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<std::pair<IdString, std::string>> Arch::getWireAttrs(WireId wire) const
|
||||
{
|
||||
std::vector<std::pair<IdString, std::string>> 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<std::pair<IdString, std::string>> Arch::getPipAttrs(PipId pip) const
|
||||
{
|
||||
std::vector<std::pair<IdString, std::string>> 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<GroupId> Arch::getGroups() const
|
||||
{
|
||||
std::vector<GroupId> 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<GroupId> Arch::getGroups() const
|
||||
ret.push_back(group);
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -843,137 +863,6 @@ DecalXY Arch::getGroupDecal(GroupId group) const
|
||||
std::vector<GraphicElement> Arch::getDecalGraphics(DecalId decal) const
|
||||
{
|
||||
std::vector<GraphicElement> 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;
|
||||
}
|
||||
|
||||
|
@ -625,6 +625,8 @@ struct Arch : BaseCtx
|
||||
return torc_info->site_index_to_type[site_index];
|
||||
}
|
||||
|
||||
std::vector<std::pair<IdString, std::string>> getBelAttrs(BelId bel) const;
|
||||
|
||||
WireId getBelPinWire(BelId bel, IdString pin) const;
|
||||
PortType getBelPinType(BelId bel, IdString pin) const;
|
||||
std::vector<IdString> getBelPins(BelId bel) const;
|
||||
@ -640,6 +642,7 @@ struct Arch : BaseCtx
|
||||
}
|
||||
|
||||
IdString getWireType(WireId wire) const;
|
||||
std::vector<std::pair<IdString, std::string>> 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<std::pair<IdString, std::string>> getPipAttrs(PipId pip) const;
|
||||
|
||||
uint32_t getPipChecksum(PipId pip) const { return pip.index; }
|
||||
|
||||
|
@ -31,21 +31,11 @@ void arch_wrap_python()
|
||||
using namespace PythonConversion;
|
||||
class_<ArchArgs>("ArchArgs").def_readwrite("type", &ArchArgs::type);
|
||||
|
||||
enum_<decltype(std::declval<ArchArgs>().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>("BelId").def_readwrite("index", &BelId::index);
|
||||
|
||||
class_<WireId>("WireId").def_readwrite("index", &WireId::index);
|
||||
|
||||
class_<PipId>("PipId").def_readwrite("index", &PipId::index);
|
||||
class_<PipId>("PipId").def_readwrite("index", &PipId::index);
|
||||
|
||||
class_<BelPin>("BelPin").def_readwrite("bel", &BelPin::bel).def_readwrite("pin", &BelPin::pin);
|
||||
|
||||
|
@ -48,6 +48,13 @@ template <> struct string_converter<WireId>
|
||||
std::string to_str(Context *ctx, WireId id) { return ctx->getWireName(id).str(ctx); }
|
||||
};
|
||||
|
||||
template <> struct string_converter<const WireId>
|
||||
{
|
||||
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>
|
||||
{
|
||||
PipId from_str(Context *ctx, std::string name) { return ctx->getPipByName(ctx->id(name)); }
|
||||
|
Loading…
Reference in New Issue
Block a user