From 45462ef3a714c0d98fe570d96e6761e2b298c7d0 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Fri, 13 Jul 2018 14:29:03 +0200 Subject: Fix Ui/Decal handling of active/inactive arch objects Signed-off-by: Clifford Wolf --- generic/arch.cc | 12 +++++++++++- ice40/arch.cc | 14 +++++++++++--- ice40/arch.h | 11 +++++++++++ ice40/archdefs.h | 1 + 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/generic/arch.cc b/generic/arch.cc index ec2443f2..390830aa 100644 --- a/generic/arch.cc +++ b/generic/arch.cc @@ -181,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) @@ -188,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(); } @@ -236,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) @@ -243,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(); } @@ -282,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) @@ -290,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(); } diff --git a/ice40/arch.cc b/ice40/arch.cc index 786bf686..9b058aa0 100644 --- a/ice40/arch.cc +++ b/ice40/arch.cc @@ -455,6 +455,7 @@ DecalXY Arch::getFrameDecal() const { DecalXY decalxy; decalxy.decal.type = DecalId::TYPE_FRAME; + decalxy.decal.active = true; return decalxy; } @@ -463,6 +464,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; } @@ -471,18 +473,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; }; @@ -509,8 +518,7 @@ std::vector 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); @@ -525,7 +533,7 @@ std::vector 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 + diff --git a/ice40/arch.h b/ice40/arch.h index 04de5178..b6c64de4 100644 --- a/ice40/arch.h +++ b/ice40/arch.h @@ -371,6 +371,7 @@ struct Arch : BaseCtx bel_to_cell[bel.index] = cell; cells[cell]->bel = bel; cells[cell]->belStrength = strength; + refreshUiBel(bel); } void unbindBel(BelId bel) @@ -380,6 +381,7 @@ struct Arch : BaseCtx cells[bel_to_cell[bel.index]]->bel = BelId(); cells[bel_to_cell[bel.index]]->belStrength = STRENGTH_NONE; bel_to_cell[bel.index] = IdString(); + refreshUiBel(bel); } bool checkBelAvail(BelId bel) const @@ -473,6 +475,7 @@ struct Arch : BaseCtx wire_to_net[wire.index] = net; nets[net]->wires[wire].pip = PipId(); nets[net]->wires[wire].strength = strength; + refreshUiWire(wire); } void unbindWire(WireId wire) @@ -488,10 +491,12 @@ struct Arch : BaseCtx if (pip != PipId()) { pip_to_net[pip.index] = IdString(); switches_locked[chip_info->pip_data[pip.index].switch_index] = IdString(); + refreshUiPip(pip); } net_wires.erase(it); wire_to_net[wire.index] = IdString(); + refreshUiWire(wire); } bool checkWireAvail(WireId wire) const @@ -542,6 +547,9 @@ struct Arch : BaseCtx wire_to_net[dst.index] = net; nets[net]->wires[dst].pip = pip; nets[net]->wires[dst].strength = strength; + + refreshUiPip(pip); + refreshUiWire(dst); } void unbindPip(PipId pip) @@ -558,6 +566,9 @@ struct Arch : BaseCtx pip_to_net[pip.index] = IdString(); switches_locked[chip_info->pip_data[pip.index].switch_index] = IdString(); + + refreshUiPip(pip); + refreshUiWire(dst); } bool checkPipAvail(PipId pip) const diff --git a/ice40/archdefs.h b/ice40/archdefs.h index 2bb718f1..75df678a 100644 --- a/ice40/archdefs.h +++ b/ice40/archdefs.h @@ -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); } -- cgit v1.2.3