From bfbb6dbf6955f0fd5e68928f27d1a2edd17b5646 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sun, 6 Oct 2019 11:26:56 +0200 Subject: Draw swbox, smaller slices, proper io --- ecp5/arch.cc | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++----- ecp5/arch.h | 14 +++---- ecp5/archdefs.h | 21 +++++++--- ecp5/gfx.h | 27 ++++++++++--- 4 files changed, 157 insertions(+), 28 deletions(-) (limited to 'ecp5') diff --git a/ecp5/arch.cc b/ecp5/arch.cc index 8ce0653c..9344ff5e 100644 --- a/ecp5/arch.cc +++ b/ecp5/arch.cc @@ -603,32 +603,60 @@ std::vector Arch::getDecalGraphics(DecalId decal) const { std::vector ret; + if (decal.type == DecalId::TYPE_GROUP) { + int type = decal.z; + int x = decal.location.x; + int y = chip_info->height - 1 - decal.location.y; + + if (type == GroupId::TYPE_SWITCHBOX) { + GraphicElement el; + el.type = GraphicElement::TYPE_BOX; + el.style = GraphicElement::STYLE_FRAME; + + el.x1 = x + switchbox_x1; + el.x2 = x + switchbox_x2; + el.y1 = y + switchbox_y1; + el.y2 = y + switchbox_y2; + ret.push_back(el); + } + } + if (decal.type == DecalId::TYPE_BEL) { BelId bel; bel.index = decal.z; bel.location = decal.location; - int z = locInfo(bel)->bel_data[bel.index].z; auto bel_type = getBelType(bel); + int x = decal.location.x; + int y = chip_info->height - 1 - decal.location.y; + int z = locInfo(bel)->bel_data[bel.index].z; if (bel_type == id_TRELLIS_SLICE) { GraphicElement el; el.type = GraphicElement::TYPE_BOX; el.style = decal.active ? GraphicElement::STYLE_ACTIVE : GraphicElement::STYLE_INACTIVE; - el.x1 = bel.location.x + logic_cell_x1; - el.x2 = bel.location.x + logic_cell_x2; - el.y1 = bel.location.y + logic_cell_y1 + (z)*logic_cell_pitch; - el.y2 = bel.location.y + logic_cell_y2 + (z)*logic_cell_pitch; + el.x1 = x + slice_x1; + el.x2 = x + slice_x2; + el.y1 = y + slice_y1 + (z)*slice_pitch; + el.y2 = y + slice_y2 + (z)*slice_pitch; ret.push_back(el); } if (bel_type == id_TRELLIS_IO) { + bool top_bottom = (y==0 || y==(chip_info->height-1)); GraphicElement el; el.type = GraphicElement::TYPE_BOX; el.style = decal.active ? GraphicElement::STYLE_ACTIVE : GraphicElement::STYLE_INACTIVE; - el.x1 = bel.location.x + logic_cell_x1; - el.x2 = bel.location.x + logic_cell_x2; - el.y1 = bel.location.y + logic_cell_y1 + (2 * z) * logic_cell_pitch; - el.y2 = bel.location.y + logic_cell_y2 + (2 * z + 0.5f) * logic_cell_pitch; + if (top_bottom) { + el.x1 = x + io_cell_h_x1 + (2 * (z+1)) * io_cell_h_pitch; + el.x2 = x + io_cell_h_x2 + (2 * (z+1) + 0.5f) * io_cell_h_pitch; + el.y1 = y + io_cell_h_y1; + el.y2 = y + io_cell_h_y2; + } else { + el.x1 = x + io_cell_v_x1; + el.x2 = x + io_cell_v_x2; + el.y1 = y + io_cell_v_y1 + (2 * z) * io_cell_v_pitch; + el.y2 = y + io_cell_v_y2 + (2 * z + 0.5f) * io_cell_v_pitch; + } ret.push_back(el); } } @@ -650,7 +678,15 @@ DecalXY Arch::getWireDecal(WireId wire) const { return {}; } DecalXY Arch::getPipDecal(PipId pip) const { return {}; }; -DecalXY Arch::getGroupDecal(GroupId pip) const { return {}; }; +DecalXY Arch::getGroupDecal(GroupId group) const +{ + DecalXY decalxy; + decalxy.decal.type = DecalId::TYPE_GROUP; + decalxy.decal.location = group.location; + decalxy.decal.z = group.type; + decalxy.decal.active = true; + return decalxy; +} // ----------------------------------------------------------------------- @@ -1068,4 +1104,71 @@ const std::vector Arch::availablePlacers = {"sa", #endif }; +// ----------------------------------------------------------------------- + +GroupId Arch::getGroupByName(IdString name) const +{ + for (auto g : getGroups()) + if (getGroupName(g) == name) + return g; + return GroupId(); +} + +IdString Arch::getGroupName(GroupId group) const +{ + std::string suffix; + + switch (group.type) { + case GroupId::TYPE_SWITCHBOX: + suffix = "switchbox"; + break; + default: + return IdString(); + } + + return id("X" + std::to_string(group.location.x) + "/Y" + std::to_string(group.location.y) + "/" + suffix); +} + +std::vector Arch::getGroups() const +{ + std::vector ret; + + for (int y = 1; y < chip_info->height-1; y++) { + for (int x = 1; x < chip_info->width-1; x++) { + GroupId group; + group.type = GroupId::TYPE_SWITCHBOX; + group.location.x = x; + group.location. y = y; + ret.push_back(group); + } + } + return ret; +} + +std::vector Arch::getGroupBels(GroupId group) const +{ + std::vector ret; + return ret; +} + +std::vector Arch::getGroupWires(GroupId group) const +{ + std::vector ret; + return ret; +} + +std::vector Arch::getGroupPips(GroupId group) const +{ + std::vector ret; + return ret; +} + +std::vector Arch::getGroupGroups(GroupId group) const +{ + std::vector ret; + return ret; +} + +// ----------------------------------------------------------------------- + NEXTPNR_NAMESPACE_END diff --git a/ecp5/arch.h b/ecp5/arch.h index a479abb6..94bd5f3a 100644 --- a/ecp5/arch.h +++ b/ecp5/arch.h @@ -930,13 +930,13 @@ struct Arch : BaseCtx // ------------------------------------------------- - GroupId getGroupByName(IdString name) const { return GroupId(); } - IdString getGroupName(GroupId group) const { return IdString(); } - std::vector getGroups() const { return std::vector(); } - std::vector getGroupBels(GroupId group) const { return std::vector(); } - std::vector getGroupWires(GroupId group) const { return std::vector(); } - std::vector getGroupPips(GroupId group) const { return std::vector(); } - std::vector getGroupGroups(GroupId group) const { return std::vector(); } + GroupId getGroupByName(IdString name) const; + IdString getGroupName(GroupId group) const; + std::vector getGroups() const; + std::vector getGroupBels(GroupId group) const; + std::vector getGroupWires(GroupId group) const; + std::vector getGroupPips(GroupId group) const; + std::vector getGroupGroups(GroupId group) const; // ------------------------------------------------- diff --git a/ecp5/archdefs.h b/ecp5/archdefs.h index da12eeaa..67c016cc 100644 --- a/ecp5/archdefs.h +++ b/ecp5/archdefs.h @@ -122,10 +122,15 @@ struct PipId struct GroupId { - int32_t index = -1; + enum : int8_t + { + TYPE_NONE, + TYPE_SWITCHBOX + } type = TYPE_NONE; + Location location; - bool operator==(const GroupId &other) const { return index == other.index; } - bool operator!=(const GroupId &other) const { return index != other.index; } + bool operator==(const GroupId &other) const { return (type == other.type) && (location == other.location); } + bool operator!=(const GroupId &other) const { return (type != other.type) || (location != other.location); } }; struct DecalId @@ -133,8 +138,11 @@ struct DecalId enum { TYPE_NONE, - TYPE_BEL - } type; + TYPE_BEL, + TYPE_WIRE, + TYPE_PIP, + TYPE_GROUP + } type = TYPE_NONE; Location location; uint32_t z = 0; bool active = false; @@ -216,7 +224,8 @@ template <> struct hash { std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX GroupId &group) const noexcept { - return std::hash()(group.index); + std::size_t seed = std::hash()(group.location); + return seed; } }; diff --git a/ecp5/gfx.h b/ecp5/gfx.h index 0290d2f6..ec867547 100644 --- a/ecp5/gfx.h +++ b/ecp5/gfx.h @@ -24,11 +24,28 @@ NEXTPNR_NAMESPACE_BEGIN -const float logic_cell_x1 = 0.76; -const float logic_cell_x2 = 0.95; -const float logic_cell_y1 = 0.05; -const float logic_cell_y2 = 0.15; -const float logic_cell_pitch = 0.125; +const float switchbox_x1 = 0.51; +const float switchbox_x2 = 0.90; +const float switchbox_y1 = 0.51; +const float switchbox_y2 = 0.90; + +const float slice_x1 = 0.92; +const float slice_x2 = 0.94; +const float slice_y1 = 0.71; +const float slice_y2 = 0.745; +const float slice_pitch = 0.04; + +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_v_y2 = 0.15; +const float io_cell_v_pitch = 0.125; + +const float io_cell_h_x1 = 0.05; +const float io_cell_h_x2 = 0.14; +const float io_cell_h_y1 = 0.05; +const float io_cell_h_y2 = 0.24; +const float io_cell_h_pitch = 0.125; NEXTPNR_NAMESPACE_END -- cgit v1.2.3