Add simple BEL graphics
This commit is contained in:
parent
26f23e3121
commit
4396a646a7
@ -21,6 +21,7 @@
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
#include "embed.h"
|
||||
#include "gfx.h"
|
||||
#include "nextpnr.h"
|
||||
#include "placer1.h"
|
||||
#include "placer_heap.h"
|
||||
@ -449,6 +450,79 @@ bool Arch::route()
|
||||
return result;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
std::vector<GraphicElement> Arch::getDecalGraphics(DecalId decal) const
|
||||
{
|
||||
std::vector<GraphicElement> ret;
|
||||
if (decal.type == DecalId::TYPE_WIRE) {
|
||||
WireId wire;
|
||||
wire.index = decal.z;
|
||||
wire.location = decal.location;
|
||||
auto wire_type = getWireType(wire);
|
||||
int x = decal.location.x;
|
||||
int y = decal.location.y;
|
||||
GraphicElement::style_t style = decal.active ? GraphicElement::STYLE_ACTIVE : GraphicElement::STYLE_INACTIVE;
|
||||
GfxTileWireId tilewire = GfxTileWireId(tile_info(wire)->wire_data[wire.index].tile_wire);
|
||||
gfxTileWire(ret, x, y, chip_info->width, chip_info->height, wire_type, tilewire, style);
|
||||
} else if (decal.type == DecalId::TYPE_PIP) {
|
||||
PipId pip;
|
||||
pip.index = decal.z;
|
||||
pip.location = decal.location;
|
||||
WireId src_wire = getPipSrcWire(pip);
|
||||
WireId dst_wire = getPipDstWire(pip);
|
||||
int x = decal.location.x;
|
||||
int y = decal.location.y;
|
||||
GfxTileWireId src_id = GfxTileWireId(tile_info(src_wire)->wire_data[src_wire.index].tile_wire);
|
||||
GfxTileWireId dst_id = GfxTileWireId(tile_info(dst_wire)->wire_data[dst_wire.index].tile_wire);
|
||||
GraphicElement::style_t style = decal.active ? GraphicElement::STYLE_ACTIVE : GraphicElement::STYLE_HIDDEN;
|
||||
gfxTilePip(ret, x, y, chip_info->width, chip_info->height, src_wire, getWireType(src_wire), src_id, dst_wire,
|
||||
getWireType(dst_wire), dst_id, style);
|
||||
} else if (decal.type == DecalId::TYPE_BEL) {
|
||||
BelId bel;
|
||||
bel.index = decal.z;
|
||||
bel.location = decal.location;
|
||||
auto bel_type = getBelType(bel);
|
||||
int x = decal.location.x;
|
||||
int y = decal.location.y;
|
||||
int z = tile_info(bel)->bel_data[bel.index].z;
|
||||
GraphicElement::style_t style = decal.active ? GraphicElement::STYLE_ACTIVE : GraphicElement::STYLE_INACTIVE;
|
||||
gfxTileBel(ret, x, y, z, chip_info->width, chip_info->height, bel_type, style);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
DecalXY Arch::getBelDecal(BelId bel) const
|
||||
{
|
||||
DecalXY decalxy;
|
||||
decalxy.decal.type = DecalId::TYPE_BEL;
|
||||
decalxy.decal.location = bel.location;
|
||||
decalxy.decal.z = bel.index;
|
||||
decalxy.decal.active = getBoundBelCell(bel) != nullptr;
|
||||
return decalxy;
|
||||
}
|
||||
|
||||
DecalXY Arch::getWireDecal(WireId wire) const
|
||||
{
|
||||
DecalXY decalxy;
|
||||
decalxy.decal.type = DecalId::TYPE_WIRE;
|
||||
decalxy.decal.location = wire.location;
|
||||
decalxy.decal.z = wire.index;
|
||||
decalxy.decal.active = getBoundWireNet(wire) != nullptr;
|
||||
return decalxy;
|
||||
}
|
||||
|
||||
DecalXY Arch::getPipDecal(PipId pip) const
|
||||
{
|
||||
DecalXY decalxy;
|
||||
decalxy.decal.type = DecalId::TYPE_PIP;
|
||||
decalxy.decal.location = pip.location;
|
||||
decalxy.decal.z = pip.index;
|
||||
decalxy.decal.active = getBoundPipNet(pip) != nullptr;
|
||||
return decalxy;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
bool Arch::isBelLocationValid(BelId bel, bool explain_invalid) const
|
||||
|
@ -643,6 +643,13 @@ struct Arch : BaseArch<ArchRanges>
|
||||
bool place() override;
|
||||
bool route() override;
|
||||
|
||||
// Graphics
|
||||
std::vector<GraphicElement> getDecalGraphics(DecalId decal) const override;
|
||||
|
||||
DecalXY getBelDecal(BelId bel) const override;
|
||||
DecalXY getWireDecal(WireId wire) const override;
|
||||
DecalXY getPipDecal(PipId pip) const override;
|
||||
|
||||
// Placer
|
||||
bool isBelLocationValid(BelId bel, bool explain_invalid = false) const override;
|
||||
|
||||
|
@ -107,8 +107,31 @@ struct PipId
|
||||
unsigned int hash() const { return mkhash(location.hash(), index); }
|
||||
};
|
||||
|
||||
struct DecalId
|
||||
{
|
||||
enum
|
||||
{
|
||||
TYPE_NONE,
|
||||
TYPE_BEL,
|
||||
TYPE_WIRE,
|
||||
TYPE_PIP,
|
||||
TYPE_GROUP
|
||||
} type = TYPE_NONE;
|
||||
Location location;
|
||||
uint32_t z = 0;
|
||||
bool active = false;
|
||||
bool operator==(const DecalId &other) const
|
||||
{
|
||||
return type == other.type && location == other.location && z == other.z && active == other.active;
|
||||
}
|
||||
bool operator!=(const DecalId &other) const
|
||||
{
|
||||
return type != other.type || location != other.location || z != other.z || active != other.active;
|
||||
}
|
||||
unsigned int hash() const { return mkhash(location.hash(), mkhash(z, int(type))); }
|
||||
};
|
||||
|
||||
typedef IdString GroupId;
|
||||
typedef IdString DecalId;
|
||||
typedef IdString BelBucketId;
|
||||
typedef IdString ClusterId;
|
||||
|
||||
|
98
machxo2/gfx.cc
Normal file
98
machxo2/gfx.cc
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* nextpnr -- Next Generation Place and Route
|
||||
*
|
||||
* Copyright (C) 2023 Miodrag Milanovic <micko@yosyshq.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 "gfx.h"
|
||||
|
||||
NEXTPNR_NAMESPACE_BEGIN
|
||||
|
||||
const float slice_x1 = 0.800;
|
||||
const float slice_x2_comb = 0.927;
|
||||
//const float slice_x1_ff = 0.933;
|
||||
const float slice_x2 = 0.94;
|
||||
const float slice_y1 = 0.60;
|
||||
const float slice_y2 = 0.65 + 0.1 / 4;
|
||||
const float slice_pitch = 0.1;
|
||||
|
||||
const float io_cell_v_x1 = 0.76;
|
||||
const float io_cell_v_x2 = 0.95;
|
||||
const float io_cell_v_y1 = 0.05;
|
||||
const float io_cell_gap = 0.10;
|
||||
const float io_cell_h_x1 = 0.05;
|
||||
const float io_cell_h_y1 = 0.05;
|
||||
const float io_cell_h_y2 = 0.24;
|
||||
|
||||
|
||||
void gfxTileBel(std::vector<GraphicElement> &g, int x, int y, int z, int w, int h, IdString bel_type,
|
||||
GraphicElement::style_t style)
|
||||
{
|
||||
GraphicElement el;
|
||||
el.type = GraphicElement::TYPE_BOX;
|
||||
el.style = style;
|
||||
if (bel_type == id_FACADE_SLICE) {
|
||||
el.x1 = x + slice_x1;
|
||||
el.x2 = x + slice_x2_comb;
|
||||
el.y1 = y + slice_y1 + z * slice_pitch;
|
||||
el.y2 = y + slice_y2 + z * slice_pitch;
|
||||
g.push_back(el);
|
||||
/* } else if (bel_type == id_FACADE_FF) {
|
||||
el.x1 = x + slice_x1_ff;
|
||||
el.x2 = x + slice_x2;
|
||||
el.y1 = y + slice_y1 + z * slice_pitch;
|
||||
el.y2 = y + slice_y2 + z * slice_pitch;
|
||||
g.push_back(el);*/
|
||||
} else if (bel_type.in(id_FACADE_IO)) {
|
||||
bool top_bottom = (y == 0 || y == (h - 1));
|
||||
if (top_bottom) {
|
||||
el.x1 = x + io_cell_h_x1 + (z + 2) * io_cell_gap;
|
||||
el.x2 = x + io_cell_h_x1 + (z + 2) * io_cell_gap + 0.08f;
|
||||
if (y == h - 1) {
|
||||
el.y1 = y + 1 - io_cell_h_y1;
|
||||
el.y2 = y + 1 - io_cell_h_y2;
|
||||
} else {
|
||||
el.y1 = y + io_cell_h_y1;
|
||||
el.y2 = y + io_cell_h_y2;
|
||||
}
|
||||
} else {
|
||||
if (x == 0) {
|
||||
el.x1 = x + 1 - io_cell_v_x1;
|
||||
el.x2 = x + 1 - io_cell_v_x2;
|
||||
} else {
|
||||
el.x1 = x + io_cell_v_x1;
|
||||
el.x2 = x + io_cell_v_x2;
|
||||
}
|
||||
el.y1 = y + io_cell_v_y1 + z * io_cell_gap;
|
||||
el.y2 = y + io_cell_v_y1 + z * io_cell_gap + 0.08f;
|
||||
}
|
||||
g.push_back(el);
|
||||
}
|
||||
}
|
||||
|
||||
void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, int w, int h, IdString wire_type, GfxTileWireId tilewire,
|
||||
GraphicElement::style_t style)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void gfxTilePip(std::vector<GraphicElement> &g, int x, int y, int w, int h, WireId src, IdString src_type,
|
||||
GfxTileWireId src_id, WireId dst, IdString dst_type, GfxTileWireId dst_id,
|
||||
GraphicElement::style_t style)
|
||||
{
|
||||
}
|
||||
|
||||
NEXTPNR_NAMESPACE_END
|
42
machxo2/gfx.h
Normal file
42
machxo2/gfx.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* nextpnr -- Next Generation Place and Route
|
||||
*
|
||||
* Copyright (C) 2023 Miodrag Milanovic <micko@yosyshq.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 MACHXO2_GFX_H
|
||||
#define MACHXO2_GFX_H
|
||||
|
||||
#include "nextpnr.h"
|
||||
|
||||
NEXTPNR_NAMESPACE_BEGIN
|
||||
|
||||
enum GfxTileWireId
|
||||
{
|
||||
TILE_WIRE_NONE,
|
||||
};
|
||||
|
||||
void gfxTileBel(std::vector<GraphicElement> &g, int x, int y, int z, int w, int h, IdString bel_type,
|
||||
GraphicElement::style_t style);
|
||||
void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, int w, int h, IdString wire_type, GfxTileWireId tilewire,
|
||||
GraphicElement::style_t style);
|
||||
void gfxTilePip(std::vector<GraphicElement> &g, int x, int y, int w, int h, WireId src, IdString src_type,
|
||||
GfxTileWireId src_id, WireId dst, IdString dst_type, GfxTileWireId dst_id,
|
||||
GraphicElement::style_t style);
|
||||
|
||||
NEXTPNR_NAMESPACE_END
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user