diff options
Diffstat (limited to 'generic')
-rw-r--r-- | generic/arch.cc | 98 | ||||
-rw-r--r-- | generic/arch.h | 62 | ||||
-rw-r--r-- | generic/archdefs.h | 2 | ||||
-rw-r--r-- | generic/main.cc | 29 |
4 files changed, 143 insertions, 48 deletions
diff --git a/generic/arch.cc b/generic/arch.cc index 8f897604..390830aa 100644 --- a/generic/arch.cc +++ b/generic/arch.cc @@ -19,6 +19,8 @@ #include <math.h> #include "nextpnr.h" +#include "placer1.h" +#include "router1.h" NEXTPNR_NAMESPACE_BEGIN @@ -107,28 +109,48 @@ void Arch::addBelInout(IdString bel, IdString name, IdString wire) wires.at(wire).downhill_bel_pins.push_back(BelPin{bel, name}); } -void Arch::addFrameGraphic(const GraphicElement &graphic) +void Arch::addGroupBel(IdString group, IdString bel) { groups[group].bels.push_back(bel); } + +void Arch::addGroupWire(IdString group, IdString wire) { groups[group].wires.push_back(wire); } + +void Arch::addGroupPip(IdString group, IdString pip) { groups[group].pips.push_back(pip); } + +void Arch::addGroupGroup(IdString group, IdString grp) { groups[group].groups.push_back(grp); } + +void Arch::addDecalGraphic(DecalId decal, const GraphicElement &graphic) +{ + decal_graphics[decal].push_back(graphic); + refreshUi(); +} + +void Arch::setFrameDecal(DecalXY decalxy) { - frame_graphics.push_back(graphic); - frameGraphicsReload = true; + frame_decalxy = decalxy; + refreshUiFrame(); } -void Arch::addWireGraphic(WireId wire, const GraphicElement &graphic) +void Arch::setWireDecal(WireId wire, DecalXY decalxy) { - wires.at(wire).graphics.push_back(graphic); - wireGraphicsReload.insert(wire); + wires.at(wire).decalxy = decalxy; + refreshUiWire(wire); } -void Arch::addPipGraphic(PipId pip, const GraphicElement &graphic) +void Arch::setPipDecal(PipId pip, DecalXY decalxy) { - pips.at(pip).graphics.push_back(graphic); - pipGraphicsReload.insert(pip); + pips.at(pip).decalxy = decalxy; + refreshUiPip(pip); } -void Arch::addBelGraphic(BelId bel, const GraphicElement &graphic) +void Arch::setBelDecal(BelId bel, DecalXY decalxy) { - bels.at(bel).graphics.push_back(graphic); - belGraphicsReload.insert(bel); + bels.at(bel).decalxy = decalxy; + refreshUiBel(bel); +} + +void Arch::setGroupDecal(GroupId group, DecalXY decalxy) +{ + groups[group].decalxy = decalxy; + refreshUiGroup(group); } // --------------------------------------------------------------- @@ -159,6 +181,7 @@ void Arch::bindBel(BelId bel, IdString cell, PlaceStrength strength) bels.at(bel).bound_cell = cell; cells.at(cell)->bel = bel; cells.at(cell)->belStrength = strength; + refreshUiBel(bel); } void Arch::unbindBel(BelId bel) @@ -166,6 +189,7 @@ void Arch::unbindBel(BelId bel) cells.at(bels.at(bel).bound_cell)->bel = BelId(); cells.at(bels.at(bel).bound_cell)->belStrength = STRENGTH_NONE; bels.at(bel).bound_cell = IdString(); + refreshUiBel(bel); } bool Arch::checkBelAvail(BelId bel) const { return bels.at(bel).bound_cell == IdString(); } @@ -214,6 +238,7 @@ void Arch::bindWire(WireId wire, IdString net, PlaceStrength strength) wires.at(wire).bound_net = net; nets.at(net)->wires[wire].pip = PipId(); nets.at(net)->wires[wire].strength = strength; + refreshUiWire(wire); } void Arch::unbindWire(WireId wire) @@ -221,11 +246,14 @@ void Arch::unbindWire(WireId wire) auto &net_wires = nets[wires.at(wire).bound_net]->wires; auto pip = net_wires.at(wire).pip; - if (pip != PipId()) + if (pip != PipId()) { pips.at(pip).bound_net = IdString(); + refreshUiPip(pip); + } net_wires.erase(wire); wires.at(wire).bound_net = IdString(); + refreshUiWire(wire); } bool Arch::checkWireAvail(WireId wire) const { return wires.at(wire).bound_net == IdString(); } @@ -260,6 +288,8 @@ void Arch::bindPip(PipId pip, IdString net, PlaceStrength strength) wires.at(wire).bound_net = net; nets.at(net)->wires[wire].pip = pip; nets.at(net)->wires[wire].strength = strength; + refreshUiPip(pip); + refreshUiWire(wire); } void Arch::unbindPip(PipId pip) @@ -268,6 +298,8 @@ void Arch::unbindPip(PipId pip) nets.at(wires.at(wire).bound_net)->wires.erase(wire); pips.at(pip).bound_net = IdString(); wires.at(wire).bound_net = IdString(); + refreshUiPip(pip); + refreshUiWire(wire); } bool Arch::checkPipAvail(PipId pip) const { return pips.at(pip).bound_net == IdString(); } @@ -292,6 +324,28 @@ const std::vector<PipId> &Arch::getWireAliases(WireId wire) const { return wires // --------------------------------------------------------------- +GroupId Arch::getGroupByName(IdString name) const { return name; } + +IdString Arch::getGroupName(GroupId group) const { return group; } + +std::vector<GroupId> Arch::getGroups() const +{ + std::vector<GroupId> ret; + for (auto &it : groups) + ret.push_back(it.first); + return ret; +} + +const std::vector<BelId> &Arch::getGroupBels(GroupId group) const { return groups.at(group).bels; } + +const std::vector<WireId> &Arch::getGroupWires(GroupId group) const { return groups.at(group).wires; } + +const std::vector<PipId> &Arch::getGroupPips(GroupId group) const { return groups.at(group).pips; } + +const std::vector<GroupId> &Arch::getGroupGroups(GroupId group) const { return groups.at(group).groups; } + +// --------------------------------------------------------------- + void Arch::estimatePosition(BelId bel, int &x, int &y, bool &gb) const { x = bels.at(bel).grid_x; @@ -310,13 +364,23 @@ delay_t Arch::estimateDelay(WireId src, WireId dst) const // --------------------------------------------------------------- -const std::vector<GraphicElement> &Arch::getFrameGraphics() const { return frame_graphics; } +bool Arch::place() { return placer1(getCtx()); } + +bool Arch::route() { return router1(getCtx()); } + +// --------------------------------------------------------------- + +const std::vector<GraphicElement> &Arch::getDecalGraphics(DecalId decal) const { return decal_graphics.at(decal); } + +DecalXY Arch::getFrameDecal() const { return frame_decalxy; } + +DecalXY Arch::getBelDecal(BelId bel) const { return bels.at(bel).decalxy; } -const std::vector<GraphicElement> &Arch::getBelGraphics(BelId bel) const { return bels.at(bel).graphics; } +DecalXY Arch::getWireDecal(WireId wire) const { return wires.at(wire).decalxy; } -const std::vector<GraphicElement> &Arch::getWireGraphics(WireId wire) const { return wires.at(wire).graphics; } +DecalXY Arch::getPipDecal(PipId pip) const { return pips.at(pip).decalxy; } -const std::vector<GraphicElement> &Arch::getPipGraphics(PipId pip) const { return pips.at(pip).graphics; } +DecalXY Arch::getGroupDecal(GroupId group) const { return groups.at(group).decalxy; } // --------------------------------------------------------------- diff --git a/generic/arch.h b/generic/arch.h index e739cfab..5d7ac540 100644 --- a/generic/arch.h +++ b/generic/arch.h @@ -34,16 +34,16 @@ struct PipInfo IdString name, bound_net; WireId srcWire, dstWire; DelayInfo delay; - std::vector<GraphicElement> graphics; + DecalXY decalxy; }; struct WireInfo { IdString name, bound_net; - std::vector<GraphicElement> graphics; std::vector<PipId> downhill, uphill, aliases; BelPin uphill_bel_pin; std::vector<BelPin> downhill_bel_pins; + DecalXY decalxy; int grid_x, grid_y; }; @@ -58,11 +58,21 @@ struct BelInfo { IdString name, type, bound_cell; std::unordered_map<IdString, PinInfo> pins; - std::vector<GraphicElement> graphics; + DecalXY decalxy; int grid_x, grid_y; bool gb; }; +struct GroupInfo +{ + IdString name; + std::vector<BelId> bels; + std::vector<WireId> wires; + std::vector<PipId> pips; + std::vector<GroupId> groups; + DecalXY decalxy; +}; + struct Arch : BaseCtx { std::string chipName; @@ -70,11 +80,14 @@ struct Arch : BaseCtx std::unordered_map<IdString, WireInfo> wires; std::unordered_map<IdString, PipInfo> pips; std::unordered_map<IdString, BelInfo> bels; + std::unordered_map<GroupId, GroupInfo> groups; std::vector<IdString> bel_ids, wire_ids, pip_ids; std::unordered_map<IdString, std::vector<IdString>> bel_ids_by_type; - std::vector<GraphicElement> frame_graphics; + std::unordered_map<DecalId, std::vector<GraphicElement>> decal_graphics; + DecalXY frame_decalxy; + float grid_distance_to_delay; void addWire(IdString name, int x, int y); @@ -86,10 +99,17 @@ struct Arch : BaseCtx void addBelOutput(IdString bel, IdString name, IdString wire); void addBelInout(IdString bel, IdString name, IdString wire); - void addFrameGraphic(const GraphicElement &graphic); - void addWireGraphic(WireId wire, const GraphicElement &graphic); - void addPipGraphic(PipId pip, const GraphicElement &graphic); - void addBelGraphic(BelId bel, const GraphicElement &graphic); + void addGroupBel(IdString group, IdString bel); + void addGroupWire(IdString group, IdString wire); + void addGroupPip(IdString group, IdString pip); + void addGroupGroup(IdString group, IdString grp); + + void addDecalGraphic(DecalId decal, const GraphicElement &graphic); + void setFrameDecal(DecalXY decalxy); + void setWireDecal(WireId wire, DecalXY decalxy); + void setPipDecal(PipId pip, DecalXY decalxy); + void setBelDecal(BelId bel, DecalXY decalxy); + void setGroupDecal(GroupId group, DecalXY decalxy); // --------------------------------------------------------------- // Common Arch API. Every arch must provide the following methods. @@ -148,6 +168,14 @@ struct Arch : BaseCtx const std::vector<PipId> &getPipsUphill(WireId wire) const; const std::vector<PipId> &getWireAliases(WireId wire) const; + GroupId getGroupByName(IdString name) const; + IdString getGroupName(GroupId group) const; + std::vector<GroupId> getGroups() const; + const std::vector<BelId> &getGroupBels(GroupId group) const; + const std::vector<WireId> &getGroupWires(GroupId group) const; + const std::vector<PipId> &getGroupPips(GroupId group) const; + const std::vector<GroupId> &getGroupGroups(GroupId group) const; + void estimatePosition(BelId bel, int &x, int &y, bool &gb) const; delay_t estimateDelay(WireId src, WireId dst) const; delay_t getDelayEpsilon() const { return 0.01; } @@ -155,16 +183,16 @@ struct Arch : BaseCtx float getDelayNS(delay_t v) const { return v; } uint32_t getDelayChecksum(delay_t v) const { return 0; } - const std::vector<GraphicElement> &getFrameGraphics() const; - const std::vector<GraphicElement> &getBelGraphics(BelId bel) const; - const std::vector<GraphicElement> &getWireGraphics(WireId wire) const; - const std::vector<GraphicElement> &getPipGraphics(PipId pip) const; + bool pack() { return true; } + bool place(); + bool route(); - bool allGraphicsReload = false; - bool frameGraphicsReload = false; - std::unordered_set<BelId> belGraphicsReload; - std::unordered_set<WireId> wireGraphicsReload; - std::unordered_set<PipId> pipGraphicsReload; + const std::vector<GraphicElement> &getDecalGraphics(DecalId decal) const; + DecalXY getFrameDecal() const; + DecalXY getBelDecal(BelId bel) const; + DecalXY getWireDecal(WireId wire) const; + DecalXY getPipDecal(PipId pip) const; + DecalXY getGroupDecal(GroupId group) const; bool getCellDelay(const CellInfo *cell, IdString fromPort, IdString toPort, delay_t &delay) const; IdString getPortClock(const CellInfo *cell, IdString port) const; diff --git a/generic/archdefs.h b/generic/archdefs.h index 9e8462e0..9969014b 100644 --- a/generic/archdefs.h +++ b/generic/archdefs.h @@ -49,5 +49,7 @@ typedef IdString PortPin; typedef IdString BelId; typedef IdString WireId; typedef IdString PipId; +typedef IdString GroupId; +typedef IdString DecalId; NEXTPNR_NAMESPACE_END diff --git a/generic/main.cc b/generic/main.cc index d025d8d4..3b8b3fe6 100644 --- a/generic/main.cc +++ b/generic/main.cc @@ -90,24 +90,34 @@ int main(int argc, char *argv[]) return 1; } - Context ctx(ArchArgs{}); + std::unique_ptr<Context> ctx = std::unique_ptr<Context>(new Context(ArchArgs{})); if (vm.count("verbose")) { - ctx.verbose = true; + ctx->verbose = true; } if (vm.count("force")) { - ctx.force = true; + ctx->force = true; } if (vm.count("seed")) { - ctx.rngseed(vm["seed"].as<int>()); + ctx->rngseed(vm["seed"].as<int>()); } +#ifndef NO_GUI + if (vm.count("gui")) { + Application a(argc, argv); + MainWindow w(std::move(ctx)); + w.show(); + + return a.exec(); + } +#endif + #ifndef NO_PYTHON if (vm.count("run")) { init_python(argv[0], true); - python_export_global("ctx", ctx); + python_export_global("ctx", *ctx.get()); std::vector<std::string> files = vm["run"].as<std::vector<std::string>>(); for (auto filename : files) @@ -117,15 +127,6 @@ int main(int argc, char *argv[]) } #endif -#ifndef NO_GUI - if (vm.count("gui")) { - Application a(argc, argv); - MainWindow w; - w.show(); - - rc = a.exec(); - } -#endif return rc; } catch (log_execution_error_exception) { #if defined(_MSC_VER) |