machxo2: Implement getByName/getName for Wires and Pips.
This commit is contained in:
parent
e4a6fd3571
commit
9a9054188c
@ -277,9 +277,30 @@ BelId Arch::getPackagePinBel(const std::string &pin) const
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
WireId Arch::getWireByName(IdString name) const { return WireId(); }
|
||||
WireId Arch::getWireByName(IdString name) const
|
||||
{
|
||||
WireId ret;
|
||||
|
||||
IdString Arch::getWireName(WireId wire) const { return IdString(); }
|
||||
auto it = wire_by_name.find(name);
|
||||
if (it != wire_by_name.end())
|
||||
return it->second;
|
||||
|
||||
Location loc;
|
||||
std::string basename;
|
||||
std::tie(loc.x, loc.y, basename) = split_identifier_name(name.str(this));
|
||||
ret.location = loc;
|
||||
|
||||
const TileTypePOD *tilei = tileInfo(ret);
|
||||
for (int i = 0; i < tilei->num_wires; i++) {
|
||||
if (std::strcmp(tilei->wire_data[i].name.get(), basename.c_str()) == 0) {
|
||||
ret.index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ret.index >= 0)
|
||||
wire_by_name[name] = ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
IdString Arch::getWireType(WireId wire) const { return IdString(); }
|
||||
|
||||
@ -307,11 +328,46 @@ const std::vector<WireId> &Arch::getWires() const { return wire_id_dummy; }
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
PipId Arch::getPipByName(IdString name) const { return PipId(); }
|
||||
PipId Arch::getPipByName(IdString name) const
|
||||
{
|
||||
PipId ret;
|
||||
|
||||
IdString Arch::getPipName(PipId pip) const { return IdString(); }
|
||||
auto it = pip_by_name.find(name);
|
||||
if (it != pip_by_name.end())
|
||||
return it->second;
|
||||
|
||||
IdString Arch::getPipType(PipId pip) const { return IdString(); }
|
||||
Location loc;
|
||||
std::string basename;
|
||||
std::tie(loc.x, loc.y, basename) = split_identifier_name(name.str(this));
|
||||
ret.location = loc;
|
||||
|
||||
const TileTypePOD *tilei = tileInfo(ret);
|
||||
for (int i = 0; i < tilei->num_pips; i++) {
|
||||
PipId curr;
|
||||
curr.location = loc;
|
||||
curr.index = i;
|
||||
pip_by_name[getPipName(curr)] = curr;
|
||||
}
|
||||
if (pip_by_name.find(name) == pip_by_name.end())
|
||||
NPNR_ASSERT_FALSE_STR("no pip named " + name.str(this));
|
||||
return pip_by_name[name];
|
||||
}
|
||||
|
||||
IdString Arch::getPipName(PipId pip) const
|
||||
{
|
||||
NPNR_ASSERT(pip != PipId());
|
||||
|
||||
int x = pip.location.x;
|
||||
int y = pip.location.y;
|
||||
|
||||
std::string src_name = getWireName(getPipSrcWire(pip)).str(this);
|
||||
std::replace(src_name.begin(), src_name.end(), '/', '.');
|
||||
|
||||
std::string dst_name = getWireName(getPipDstWire(pip)).str(this);
|
||||
std::replace(dst_name.begin(), dst_name.end(), '/', '.');
|
||||
|
||||
return id("X" + std::to_string(x) + "/Y" + std::to_string(y) + "/" + src_name + ".->." + dst_name);
|
||||
}
|
||||
|
||||
const std::map<IdString, std::string> &Arch::getPipAttrs(PipId pip) const { return attrs_dummy; }
|
||||
|
||||
@ -337,10 +393,6 @@ const std::vector<PipId> &Arch::getPips() const { return pip_id_dummy; }
|
||||
|
||||
Loc Arch::getPipLocation(PipId pip) const { return Loc(); }
|
||||
|
||||
WireId Arch::getPipSrcWire(PipId pip) const { return WireId(); }
|
||||
|
||||
WireId Arch::getPipDstWire(PipId pip) const { return WireId(); }
|
||||
|
||||
DelayInfo Arch::getPipDelay(PipId pip) const { return DelayInfo(); }
|
||||
|
||||
const std::vector<PipId> &Arch::getPipsDownhill(WireId wire) const { return pip_id_dummy; }
|
||||
|
@ -464,6 +464,8 @@ struct Arch : BaseCtx
|
||||
|
||||
std::vector<CellInfo *> bel_to_cell;
|
||||
mutable std::unordered_map<IdString, BelId> bel_by_name;
|
||||
mutable std::unordered_map<IdString, WireId> wire_by_name;
|
||||
mutable std::unordered_map<IdString, PipId> pip_by_name;
|
||||
|
||||
// Placeholders to be removed.
|
||||
std::unordered_map<Loc, BelId> bel_by_loc;
|
||||
@ -512,6 +514,7 @@ struct Arch : BaseCtx
|
||||
|
||||
// Bels
|
||||
BelId getBelByName(IdString name) const;
|
||||
|
||||
IdString getBelName(BelId bel) const
|
||||
{
|
||||
NPNR_ASSERT(bel != BelId());
|
||||
@ -611,7 +614,15 @@ struct Arch : BaseCtx
|
||||
|
||||
// Wires
|
||||
WireId getWireByName(IdString name) const;
|
||||
IdString getWireName(WireId wire) const;
|
||||
|
||||
IdString getWireName(WireId wire) const
|
||||
{
|
||||
NPNR_ASSERT(wire != WireId());
|
||||
std::stringstream name;
|
||||
name << "X" << wire.location.x << "/Y" << wire.location.y << "/" << tileInfo(wire)->bel_data[wire.index].name.get();
|
||||
return id(name.str());
|
||||
}
|
||||
|
||||
IdString getWireType(WireId wire) const;
|
||||
const std::map<IdString, std::string> &getWireAttrs(WireId wire) const;
|
||||
uint32_t getWireChecksum(WireId wire) const;
|
||||
@ -628,7 +639,8 @@ struct Arch : BaseCtx
|
||||
// Pips
|
||||
PipId getPipByName(IdString name) const;
|
||||
IdString getPipName(PipId pip) const;
|
||||
IdString getPipType(PipId pip) const;
|
||||
|
||||
IdString getPipType(PipId pip) const { return IdString(); }
|
||||
const std::map<IdString, std::string> &getPipAttrs(PipId pip) const;
|
||||
uint32_t getPipChecksum(PipId pip) const;
|
||||
void bindPip(PipId pip, NetInfo *net, PlaceStrength strength);
|
||||
@ -639,8 +651,25 @@ struct Arch : BaseCtx
|
||||
NetInfo *getConflictingPipNet(PipId pip) const;
|
||||
const std::vector<PipId> &getPips() const;
|
||||
Loc getPipLocation(PipId pip) const;
|
||||
WireId getPipSrcWire(PipId pip) const;
|
||||
WireId getPipDstWire(PipId pip) const;
|
||||
|
||||
WireId getPipSrcWire(PipId pip) const
|
||||
{
|
||||
WireId wire;
|
||||
NPNR_ASSERT(pip != PipId());
|
||||
wire.index = tileInfo(pip)->pips_data[pip.index].src_idx;
|
||||
wire.location = pip.location + tileInfo(pip)->pips_data[pip.index].src;
|
||||
return wire;
|
||||
}
|
||||
|
||||
WireId getPipDstWire(PipId pip) const
|
||||
{
|
||||
WireId wire;
|
||||
NPNR_ASSERT(pip != PipId());
|
||||
wire.index = tileInfo(pip)->pips_data[pip.index].dst_idx;
|
||||
wire.location = pip.location + tileInfo(pip)->pips_data[pip.index].dst;
|
||||
return wire;
|
||||
}
|
||||
|
||||
DelayInfo getPipDelay(PipId pip) const;
|
||||
const std::vector<PipId> &getPipsDownhill(WireId wire) const;
|
||||
const std::vector<PipId> &getPipsUphill(WireId wire) const;
|
||||
|
Loading…
Reference in New Issue
Block a user