diff options
Diffstat (limited to 'ice40')
-rw-r--r-- | ice40/arch.cc | 89 | ||||
-rw-r--r-- | ice40/arch.h | 29 | ||||
-rw-r--r-- | ice40/arch_pybindings.cc | 5 | ||||
-rw-r--r-- | ice40/archdefs.h | 3 | ||||
-rw-r--r-- | ice40/chipdb.py | 2 | ||||
-rw-r--r-- | ice40/gfx.cc | 103 | ||||
-rw-r--r-- | ice40/main.cc | 3 | ||||
-rw-r--r-- | ice40/pack.cc | 4 | ||||
-rw-r--r-- | ice40/pack.h | 32 |
9 files changed, 170 insertions, 100 deletions
diff --git a/ice40/arch.cc b/ice40/arch.cc index 7c6af263..af31e147 100644 --- a/ice40/arch.cc +++ b/ice40/arch.cc @@ -494,6 +494,7 @@ DecalXY Arch::getFrameDecal() const { DecalXY decalxy; decalxy.decal.type = DecalId::TYPE_FRAME; + decalxy.decal.active = true; return decalxy; } @@ -502,6 +503,7 @@ DecalXY Arch::getBelDecal(BelId bel) const DecalXY decalxy; decalxy.decal.type = DecalId::TYPE_BEL; decalxy.decal.index = bel.index; + decalxy.decal.active = bel_to_cell.at(bel.index) != IdString(); return decalxy; } @@ -510,18 +512,25 @@ DecalXY Arch::getWireDecal(WireId wire) const DecalXY decalxy; decalxy.decal.type = DecalId::TYPE_WIRE; decalxy.decal.index = wire.index; + decalxy.decal.active = wire_to_net.at(wire.index) != IdString(); return decalxy; } DecalXY Arch::getPipDecal(PipId pip) const { DecalXY decalxy; + decalxy.decal.type = DecalId::TYPE_PIP; + decalxy.decal.index = pip.index; + decalxy.decal.active = pip_to_net.at(pip.index) != IdString(); return decalxy; }; DecalXY Arch::getGroupDecal(GroupId group) const { DecalXY decalxy; + decalxy.decal.type = DecalId::TYPE_GROUP; + decalxy.decal.index = (group.type << 16) | (group.x << 8) | (group.y); + decalxy.decal.active = true; return decalxy; }; @@ -549,8 +558,7 @@ std::vector<GraphicElement> Arch::getDecalGraphics(DecalId decal) const int n = chip_info->wire_data[wire.index].num_segments; const WireSegmentPOD *p = chip_info->wire_data[wire.index].segments.get(); - GraphicElement::style_t style = - wire_to_net.at(wire.index) != IdString() ? GraphicElement::G_ACTIVE : GraphicElement::G_INACTIVE; + GraphicElement::style_t style = decal.active ? GraphicElement::G_ACTIVE : GraphicElement::G_INACTIVE; for (int i = 0; i < n; i++) gfxTileWire(ret, p[i].x, p[i].y, GfxTileWireId(p[i].index), style); @@ -565,7 +573,7 @@ std::vector<GraphicElement> Arch::getDecalGraphics(DecalId decal) const if (bel_type == TYPE_ICESTORM_LC) { GraphicElement el; el.type = GraphicElement::G_BOX; - el.style = bel_to_cell.at(bel.index) != IdString() ? GraphicElement::G_ACTIVE : GraphicElement::G_INACTIVE; + el.style = decal.active ? GraphicElement::G_ACTIVE : GraphicElement::G_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 + @@ -635,14 +643,42 @@ std::vector<GraphicElement> Arch::getDecalGraphics(DecalId decal) const } if (bel_type == TYPE_ICESTORM_RAM) { - GraphicElement el; - el.type = GraphicElement::G_BOX; - el.x1 = chip_info->bel_data[bel.index].x + 0.1; - el.x2 = chip_info->bel_data[bel.index].x + 0.9; - el.y1 = chip_info->bel_data[bel.index].y + 0.1; - el.y2 = chip_info->bel_data[bel.index].y + 1.9; - el.z = 0; - ret.push_back(el); + for (int i = 0; i < 2; i++) + { + int tx = chip_info->bel_data[bel.index].x; + int ty = chip_info->bel_data[bel.index].y + i; + + GraphicElement el; + el.type = GraphicElement::G_BOX; + el.style = decal.active ? GraphicElement::G_ACTIVE : GraphicElement::G_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; + el.y2 = chip_info->bel_data[bel.index].y + logic_cell_y2 + 7*logic_cell_pitch; + el.z = 0; + ret.push_back(el); + + // Main switchbox + GraphicElement main_sw; + main_sw.type = GraphicElement::G_BOX; + main_sw.style = GraphicElement::G_FRAME; + main_sw.x1 = tx + main_swbox_x1; + main_sw.x2 = tx + main_swbox_x2; + main_sw.y1 = ty + main_swbox_y1; + main_sw.y2 = ty + main_swbox_y2; + ret.push_back(main_sw); + + // Local tracks to LUT input switchbox + GraphicElement local_sw; + local_sw.type = GraphicElement::G_BOX; + local_sw.style = GraphicElement::G_FRAME; + local_sw.x1 = tx + local_swbox_x1; + local_sw.x2 = tx + local_swbox_x2; + local_sw.y1 = ty + local_swbox_y1; + local_sw.y2 = ty + local_swbox_y2; + local_sw.z = 0; + ret.push_back(local_sw); + } } } @@ -822,16 +858,6 @@ BelId ArchRProxyMethods::getBelByName(IdString name) const // ----------------------------------------------------------------------- -void ArchRWProxyMethods::bindWire(WireId wire, IdString net, PlaceStrength strength) -{ - NPNR_ASSERT(wire != WireId()); - NPNR_ASSERT(parent_->wire_to_net[wire.index] == IdString()); - - parent_->wire_to_net[wire.index] = net; - parent_->nets[net]->wires[wire].pip = PipId(); - parent_->nets[net]->wires[wire].strength = strength; -} - void ArchRWProxyMethods::bindBel(BelId bel, IdString cell, PlaceStrength strength) { NPNR_ASSERT(bel != BelId()); @@ -839,6 +865,7 @@ void ArchRWProxyMethods::bindBel(BelId bel, IdString cell, PlaceStrength strengt parent_->bel_to_cell[bel.index] = cell; parent_->cells[cell]->bel = bel; parent_->cells[cell]->belStrength = strength; + parent_->refreshUiBel(bel); } void ArchRWProxyMethods::unbindBel(BelId bel) @@ -848,6 +875,18 @@ void ArchRWProxyMethods::unbindBel(BelId bel) parent_->cells[parent_->bel_to_cell[bel.index]]->bel = BelId(); parent_->cells[parent_->bel_to_cell[bel.index]]->belStrength = STRENGTH_NONE; parent_->bel_to_cell[bel.index] = IdString(); + parent_->refreshUiBel(bel); +} + +void ArchRWProxyMethods::bindWire(WireId wire, IdString net, PlaceStrength strength) +{ + NPNR_ASSERT(wire != WireId()); + NPNR_ASSERT(parent_->wire_to_net[wire.index] == IdString()); + + parent_->wire_to_net[wire.index] = net; + parent_->nets[net]->wires[wire].pip = PipId(); + parent_->nets[net]->wires[wire].strength = strength; + parent_->refreshUiWire(wire); } void ArchRWProxyMethods::unbindWire(WireId wire) @@ -863,10 +902,12 @@ void ArchRWProxyMethods::unbindWire(WireId wire) if (pip != PipId()) { parent_->pip_to_net[pip.index] = IdString(); parent_->switches_locked[parent_->chip_info->pip_data[pip.index].switch_index] = IdString(); + parent_->refreshUiPip(pip); } net_wires.erase(it); parent_->wire_to_net[wire.index] = IdString(); + parent_->refreshUiWire(wire); } void ArchRWProxyMethods::bindPip(PipId pip, IdString net, PlaceStrength strength) @@ -884,6 +925,9 @@ void ArchRWProxyMethods::bindPip(PipId pip, IdString net, PlaceStrength strength parent_->wire_to_net[dst.index] = net; parent_->nets[net]->wires[dst].pip = pip; parent_->nets[net]->wires[dst].strength = strength; + + parent_->refreshUiPip(pip); + parent_->refreshUiWire(dst); } void ArchRWProxyMethods::unbindPip(PipId pip) @@ -900,6 +944,9 @@ void ArchRWProxyMethods::unbindPip(PipId pip) parent_->pip_to_net[pip.index] = IdString(); parent_->switches_locked[parent_->chip_info->pip_data[pip.index].switch_index] = IdString(); + + parent_->refreshUiPip(pip); + parent_->refreshUiWire(dst); } CellInfo *ArchRWProxyMethods::getCell(IdString cell) diff --git a/ice40/arch.h b/ice40/arch.h index 4462ce9e..36e34d7b 100644 --- a/ice40/arch.h +++ b/ice40/arch.h @@ -477,21 +477,6 @@ public: uint32_t getWireChecksum(WireId wire) const { return wire.index; } - - WireRange getWires() const - { - WireRange range; - range.b.cursor = 0; - range.e.cursor = chip_info->num_wires; - return range; - } - - // ------------------------------------------------- - - IdString getPipName(PipId pip) const; - - uint32_t getPipChecksum(PipId pip) const { return pip.index; } - AllPipRange getPips() const { AllPipRange range; @@ -499,6 +484,10 @@ public: range.e.cursor = chip_info->num_pips; return range; } + + IdString getPipName(PipId pip) const; + + uint32_t getPipChecksum(PipId pip) const { return pip.index; } WireId getPipSrcWire(PipId pip) const { @@ -551,6 +540,15 @@ public: return range; } + WireRange getWires() const + { + WireRange range; + range.b.cursor = 0; + range.e.cursor = chip_info->num_wires; + return range; + } + + BelId getPackagePinBel(const std::string &pin) const; std::string getBelPackagePin(BelId bel) const; @@ -575,6 +573,7 @@ public: // ------------------------------------------------- + bool pack(); bool place(); bool route(); diff --git a/ice40/arch_pybindings.cc b/ice40/arch_pybindings.cc index ac8c189a..fd5109b4 100644 --- a/ice40/arch_pybindings.cc +++ b/ice40/arch_pybindings.cc @@ -58,7 +58,10 @@ void arch_wrap_python() auto arch_cls = class_<Arch, Arch *, bases<BaseCtx>, boost::noncopyable>("Arch", init<ArchArgs>()); auto ctx_cls = class_<Context, Context *, bases<Arch>, boost::noncopyable>("Context", no_init) - .def("checksum", &Context::checksum); + .def("checksum", &Context::checksum) + .def("pack", &Context::pack) + .def("place", &Context::place) + .def("route", &Context::route); fn_wrapper_1a<Context, decltype(&Context::getBelType), &Context::getBelType, conv_to_str<BelType>, conv_from_str<BelId>>::def_wrap(ctx_cls, "getBelType"); diff --git a/ice40/archdefs.h b/ice40/archdefs.h index 3252dabf..75df678a 100644 --- a/ice40/archdefs.h +++ b/ice40/archdefs.h @@ -21,7 +21,7 @@ #error Include "archdefs.h" via "nextpnr.h" only. #endif -#include <boost/functional/hash_fwd.hpp> +#include <boost/functional/hash.hpp> NEXTPNR_NAMESPACE_BEGIN @@ -144,6 +144,7 @@ struct DecalId TYPE_GROUP } type = TYPE_NONE; int32_t index = -1; + bool active = false; bool operator==(const DecalId &other) const { return (type == other.type) && (index == other.index); } bool operator!=(const DecalId &other) const { return (type != other.type) || (index != other.index); } diff --git a/ice40/chipdb.py b/ice40/chipdb.py index f52a2283..51fe169c 100644 --- a/ice40/chipdb.py +++ b/ice40/chipdb.py @@ -77,7 +77,7 @@ with open(args.gfxh) as f: state = 1 elif state == 1 and line.startswith("};"): state = 0 - elif state == 1 and line.startswith("{"): + elif state == 1 and (line.startswith("{") or line.strip() == ""): pass elif state == 1: idx = len(gfx_wire_ids) diff --git a/ice40/gfx.cc b/ice40/gfx.cc index f4941750..19aaed13 100644 --- a/ice40/gfx.cc +++ b/ice40/gfx.cc @@ -31,17 +31,31 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id, if (id >= TILE_WIRE_SP4_H_L_36 && id <= TILE_WIRE_SP4_H_L_47) { int idx = (id - TILE_WIRE_SP4_H_L_36) + 48; - float y1 = y + 1.0 - (0.03 + 0.0025 * (60 - idx)); - el.x1 = x + 0.0; - el.x2 = x + 0.9; + float y1 = y + 1.0 - (0.03 + 0.0025 * (60 - (idx ^ 1))); + float y2 = y + 1.0 - (0.03 + 0.0025 * (60 - idx)); + + el.x1 = x; + el.x2 = x + 0.01; el.y1 = y1; el.y2 = y1; g.push_back(el); + el.x1 = x + 0.01; + el.x2 = x + 0.02; + el.y1 = y1; + el.y2 = y2; + g.push_back(el); + + el.x1 = x + 0.02; + el.x2 = x + 0.9; + el.y1 = y2; + el.y2 = y2; + g.push_back(el); + el.x1 = x + main_swbox_x1 + 0.0025 * (idx + 35); el.x2 = el.x1; - el.y1 = y1; + el.y1 = y2; el.y2 = y + main_swbox_y2; g.push_back(el); } @@ -91,17 +105,30 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id, if (id >= TILE_WIRE_SP4_V_T_36 && id <= TILE_WIRE_SP4_V_T_47) { int idx = (id - TILE_WIRE_SP4_V_T_36) + 48; - float x1 = x + 0.03 + 0.0025 * (60 - idx); + float x1 = x + 0.03 + 0.0025 * (60 - (idx ^ 1)); + float x2 = x + 0.03 + 0.0025 * (60 - idx); - el.y1 = y + 1.0; - el.y2 = y + 0.1; + el.y1 = y + 1.00; + el.y2 = y + 0.99; el.x1 = x1; el.x2 = x1; g.push_back(el); + el.y1 = y + 0.99; + el.y2 = y + 0.98; + el.x1 = x1; + el.x2 = x2; + g.push_back(el); + + el.y1 = y + 0.98; + el.y2 = y + 0.10; + el.x1 = x2; + el.x2 = x2; + g.push_back(el); + el.y1 = y + 1.0 - (0.03 + 0.0025 * (270 - idx)); el.y2 = el.y1; - el.x1 = x1; + el.x1 = x2; el.x2 = x + main_swbox_x1; g.push_back(el); } @@ -109,9 +136,9 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id, if (id >= TILE_WIRE_SP4_V_B_0 && id <= TILE_WIRE_SP4_V_B_47) { int idx = id - TILE_WIRE_SP4_V_B_0; - float x1 = x + 0.03 + 0.0025 * (60 - (idx ^ 1)); - float x2 = x + 0.03 + 0.0025 * (60 - idx); - float x3 = x + 0.03 + 0.0025 * (60 - idx - 12); + float x1 = x + 0.03 + 0.0025 * (60 - idx); + float x2 = x + 0.03 + 0.0025 * (60 - (idx ^ 1)); + float x3 = x + 0.03 + 0.0025 * (60 - (idx ^ 1) - 12); if (idx >= 12) { el.y1 = y + 1.00; @@ -139,13 +166,13 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id, el.x2 = x3; g.push_back(el); - el.y1 = y + 1.0 - (0.03 + 0.0025 * (145 - idx)); + el.y1 = y + 1.0 - (0.03 + 0.0025 * (145 - (idx ^ 1))); el.y2 = el.y1; el.x1 = x; el.x2 = x2; g.push_back(el); - el.y1 = y + 1.0 - (0.03 + 0.0025 * (270 - idx)); + el.y1 = y + 1.0 - (0.03 + 0.0025 * (270 - (idx ^ 1))); el.y2 = el.y1; el.x1 = x2; el.x2 = x + main_swbox_x1; @@ -157,17 +184,30 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id, if (id >= TILE_WIRE_SP12_H_L_22 && id <= TILE_WIRE_SP12_H_L_23) { int idx = (id - TILE_WIRE_SP12_H_L_22) + 24; - float y1 = y + 1.0 - (0.03 + 0.0025 * (90 - idx)); + float y1 = y + 1.0 - (0.03 + 0.0025 * (90 - (idx ^ 1))); + float y2 = y + 1.0 - (0.03 + 0.0025 * (90 - idx)); - el.x1 = x + 0.0; - el.x2 = x + 0.98333; + el.x1 = x; + el.x2 = x + 0.01; el.y1 = y1; el.y2 = y1; g.push_back(el); + el.x1 = x + 0.01; + el.x2 = x + 0.02; + el.y1 = y1; + el.y2 = y2; + g.push_back(el); + + el.x1 = x + 0.02; + el.x2 = x + 0.98333; + el.y1 = y2; + el.y2 = y2; + g.push_back(el); + el.x1 = x + main_swbox_x1 + 0.0025 * (idx + 5); el.x2 = el.x1; - el.y1 = y1; + el.y1 = y2; el.y2 = y + main_swbox_y2; g.push_back(el); } @@ -175,9 +215,9 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id, if (id >= TILE_WIRE_SP12_H_R_0 && id <= TILE_WIRE_SP12_H_R_23) { int idx = id - TILE_WIRE_SP12_H_R_0; - float y1 = y + 1.0 - (0.03 + 0.0025 * (90 - (idx ^ 1))); - float y2 = y + 1.0 - (0.03 + 0.0025 * (90 - idx)); - float y3 = y + 1.0 - (0.03 + 0.0025 * (90 - idx - 2)); + float y1 = y + 1.0 - (0.03 + 0.0025 * (90 - idx)); + float y2 = y + 1.0 - (0.03 + 0.0025 * (90 - (idx ^ 1))); + float y3 = y + 1.0 - (0.03 + 0.0025 * (90 - (idx ^ 1) - 2)); if (idx >= 2) { el.x1 = x; @@ -205,7 +245,7 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id, el.y2 = y3; g.push_back(el); - el.x1 = x + main_swbox_x1 + 0.0025 * (idx + 5); + el.x1 = x + main_swbox_x1 + 0.0025 * ((idx ^ 1) + 5); el.x2 = el.x1; el.y1 = y2; el.y2 = y + main_swbox_y2; @@ -217,7 +257,7 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id, if (id >= TILE_WIRE_SP4_R_V_B_0 && id <= TILE_WIRE_SP4_R_V_B_47) { int idx = id - TILE_WIRE_SP4_R_V_B_0; - float y1 = y + 1.0 - (0.03 + 0.0025 * (145 - idx)); + float y1 = y + 1.0 - (0.03 + 0.0025 * (145 - (idx ^ 1))); el.y1 = y1; el.y2 = y1; @@ -231,17 +271,30 @@ void gfxTileWire(std::vector<GraphicElement> &g, int x, int y, GfxTileWireId id, if (id >= TILE_WIRE_SP12_V_T_22 && id <= TILE_WIRE_SP12_V_T_23) { int idx = (id - TILE_WIRE_SP12_V_T_22) + 24; - float x1 = x + 0.03 + 0.0025 * (90 - idx); + float x1 = x + 0.03 + 0.0025 * (90 - (idx ^ 1)); + float x2 = x + 0.03 + 0.0025 * (90 - idx); el.y1 = y + 1.00; - el.y2 = y + 0.01667; + el.y2 = y + 0.99; el.x1 = x1; el.x2 = x1; g.push_back(el); + el.y1 = y + 0.99; + el.y2 = y + 0.98; + el.x1 = x1; + el.x2 = x2; + g.push_back(el); + + el.y1 = y + 0.98; + el.y2 = y + 0.01667; + el.x1 = x2; + el.x2 = x2; + g.push_back(el); + el.y1 = y + 1.0 - (0.03 + 0.0025 * (300 - idx)); el.y2 = el.y1; - el.x1 = x1; + el.x1 = x2; el.x2 = x + main_swbox_x1; g.push_back(el); } diff --git a/ice40/main.cc b/ice40/main.cc index 53cd7164..e77bdd34 100644 --- a/ice40/main.cc +++ b/ice40/main.cc @@ -39,7 +39,6 @@ #include "jsonparse.h" #include "log.h" #include "nextpnr.h" -#include "pack.h" #include "pcf.h" #include "place_legaliser.h" #include "timing.h" @@ -382,7 +381,7 @@ int main(int argc, char *argv[]) log_error("Loading PCF failed.\n"); } - if (!pack_design(ctx.get()) && !ctx->force) + if (!ctx->pack() && !ctx->force) log_error("Packing design failed.\n"); assign_budget(ctx.get()); ctx->check(); diff --git a/ice40/pack.cc b/ice40/pack.cc index d1be4a29..76a52be0 100644 --- a/ice40/pack.cc +++ b/ice40/pack.cc @@ -18,7 +18,6 @@ * */ -#include "pack.h" #include <algorithm> #include <iterator> #include <unordered_set> @@ -577,8 +576,9 @@ static void pack_special(Context *ctx) } // Main pack function -bool pack_design(Context *ctx) +bool Arch::pack() { + Context *ctx = getCtx(); try { log_break(); pack_constants(ctx); diff --git a/ice40/pack.h b/ice40/pack.h deleted file mode 100644 index cdebdd79..00000000 --- a/ice40/pack.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * nextpnr -- Next Generation Place and Route - * - * Copyright (C) 2018 Clifford Wolf <clifford@symbioticeda.com> - * Copyright (C) 2018 David Shah <david@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 PACK_H -#define PACK_H - -#include "nextpnr.h" - -NEXTPNR_NAMESPACE_BEGIN - -bool pack_design(Context *ctx); - -NEXTPNR_NAMESPACE_END - -#endif // ROUTE_H |