ecp5: Flatten bel_to_cell for performance
Signed-off-by: David Shah <davey1576@gmail.com>
This commit is contained in:
parent
72a9a475fa
commit
0b35cb4e60
@ -92,6 +92,8 @@ Arch::Arch(ArchArgs args) : args(args)
|
|||||||
|
|
||||||
if (!package_info)
|
if (!package_info)
|
||||||
log_error("Unsupported package '%s' for '%s'.\n", args.package.c_str(), getChipName().c_str());
|
log_error("Unsupported package '%s' for '%s'.\n", args.package.c_str(), getChipName().c_str());
|
||||||
|
|
||||||
|
bel_to_cell.resize(chip_info->height * chip_info->width * max_loc_bels, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
@ -436,7 +438,7 @@ DecalXY Arch::getBelDecal(BelId bel) const
|
|||||||
decalxy.decal.type = DecalId::TYPE_BEL;
|
decalxy.decal.type = DecalId::TYPE_BEL;
|
||||||
decalxy.decal.location = bel.location;
|
decalxy.decal.location = bel.location;
|
||||||
decalxy.decal.z = bel.index;
|
decalxy.decal.z = bel.index;
|
||||||
decalxy.decal.active = bel_to_cell.count(bel) && (bel_to_cell.at(bel) != nullptr);
|
decalxy.decal.active = (bel_to_cell.at(getBelFlatIndex(bel)) != nullptr);
|
||||||
return decalxy;
|
return decalxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
40
ecp5/arch.h
40
ecp5/arch.h
@ -404,7 +404,7 @@ struct Arch : BaseCtx
|
|||||||
mutable std::unordered_map<IdString, WireId> wire_by_name;
|
mutable std::unordered_map<IdString, WireId> wire_by_name;
|
||||||
mutable std::unordered_map<IdString, PipId> pip_by_name;
|
mutable std::unordered_map<IdString, PipId> pip_by_name;
|
||||||
|
|
||||||
std::unordered_map<BelId, CellInfo *> bel_to_cell;
|
std::vector<CellInfo *> bel_to_cell;
|
||||||
std::unordered_map<WireId, NetInfo *> wire_to_net;
|
std::unordered_map<WireId, NetInfo *> wire_to_net;
|
||||||
std::unordered_map<PipId, NetInfo *> pip_to_net;
|
std::unordered_map<PipId, NetInfo *> pip_to_net;
|
||||||
|
|
||||||
@ -443,11 +443,18 @@ struct Arch : BaseCtx
|
|||||||
|
|
||||||
uint32_t getBelChecksum(BelId bel) const { return bel.index; }
|
uint32_t getBelChecksum(BelId bel) const { return bel.index; }
|
||||||
|
|
||||||
|
const int max_loc_bels = 20;
|
||||||
|
int getBelFlatIndex(BelId bel) const
|
||||||
|
{
|
||||||
|
return (bel.location.y * chip_info->width + bel.location.x) * max_loc_bels + bel.index;
|
||||||
|
}
|
||||||
|
|
||||||
void bindBel(BelId bel, CellInfo *cell, PlaceStrength strength)
|
void bindBel(BelId bel, CellInfo *cell, PlaceStrength strength)
|
||||||
{
|
{
|
||||||
NPNR_ASSERT(bel != BelId());
|
NPNR_ASSERT(bel != BelId());
|
||||||
NPNR_ASSERT(bel_to_cell[bel] == nullptr);
|
int idx = getBelFlatIndex(bel);
|
||||||
bel_to_cell[bel] = cell;
|
NPNR_ASSERT(bel_to_cell.at(idx) == nullptr);
|
||||||
|
bel_to_cell[idx] = cell;
|
||||||
cell->bel = bel;
|
cell->bel = bel;
|
||||||
cell->belStrength = strength;
|
cell->belStrength = strength;
|
||||||
refreshUiBel(bel);
|
refreshUiBel(bel);
|
||||||
@ -456,10 +463,11 @@ struct Arch : BaseCtx
|
|||||||
void unbindBel(BelId bel)
|
void unbindBel(BelId bel)
|
||||||
{
|
{
|
||||||
NPNR_ASSERT(bel != BelId());
|
NPNR_ASSERT(bel != BelId());
|
||||||
NPNR_ASSERT(bel_to_cell[bel] != nullptr);
|
int idx = getBelFlatIndex(bel);
|
||||||
bel_to_cell[bel]->bel = BelId();
|
NPNR_ASSERT(bel_to_cell.at(idx) != nullptr);
|
||||||
bel_to_cell[bel]->belStrength = STRENGTH_NONE;
|
bel_to_cell[idx]->bel = BelId();
|
||||||
bel_to_cell[bel] = nullptr;
|
bel_to_cell[idx]->belStrength = STRENGTH_NONE;
|
||||||
|
bel_to_cell[idx] = nullptr;
|
||||||
refreshUiBel(bel);
|
refreshUiBel(bel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,31 +488,19 @@ struct Arch : BaseCtx
|
|||||||
bool checkBelAvail(BelId bel) const
|
bool checkBelAvail(BelId bel) const
|
||||||
{
|
{
|
||||||
NPNR_ASSERT(bel != BelId());
|
NPNR_ASSERT(bel != BelId());
|
||||||
auto found = bel_to_cell.find(bel);
|
return bel_to_cell[getBelFlatIndex(bel)] == nullptr;
|
||||||
if (found == bel_to_cell.end())
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return found->second == nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CellInfo *getBoundBelCell(BelId bel) const
|
CellInfo *getBoundBelCell(BelId bel) const
|
||||||
{
|
{
|
||||||
NPNR_ASSERT(bel != BelId());
|
NPNR_ASSERT(bel != BelId());
|
||||||
auto found = bel_to_cell.find(bel);
|
return bel_to_cell[getBelFlatIndex(bel)];
|
||||||
if (found == bel_to_cell.end())
|
|
||||||
return nullptr;
|
|
||||||
else
|
|
||||||
return found->second;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CellInfo *getConflictingBelCell(BelId bel) const
|
CellInfo *getConflictingBelCell(BelId bel) const
|
||||||
{
|
{
|
||||||
NPNR_ASSERT(bel != BelId());
|
NPNR_ASSERT(bel != BelId());
|
||||||
auto found = bel_to_cell.find(bel);
|
return bel_to_cell[getBelFlatIndex(bel)];
|
||||||
if (found == bel_to_cell.end())
|
|
||||||
return nullptr;
|
|
||||||
else
|
|
||||||
return found->second;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BelRange getBels() const
|
BelRange getBels() const
|
||||||
|
Loading…
Reference in New Issue
Block a user