api: add explain_invalid option to isBelLocationValid
Signed-off-by: gatecat <gatecat@ds0.me>
This commit is contained in:
parent
d1afd6c0f1
commit
603b60da8d
@ -135,7 +135,7 @@ template <typename R> struct ArchAPI : BaseCtx
|
|||||||
virtual BelBucketId getBelBucketByName(IdString name) const = 0;
|
virtual BelBucketId getBelBucketByName(IdString name) const = 0;
|
||||||
virtual BelBucketId getBelBucketForBel(BelId bel) const = 0;
|
virtual BelBucketId getBelBucketForBel(BelId bel) const = 0;
|
||||||
virtual BelBucketId getBelBucketForCellType(IdString cell_type) const = 0;
|
virtual BelBucketId getBelBucketForCellType(IdString cell_type) const = 0;
|
||||||
virtual bool isBelLocationValid(BelId bel) const = 0;
|
virtual bool isBelLocationValid(BelId bel, bool explain_invalid = false) const = 0;
|
||||||
virtual typename R::CellTypeRangeT getCellTypes() const = 0;
|
virtual typename R::CellTypeRangeT getCellTypes() const = 0;
|
||||||
virtual typename R::BelBucketRangeT getBelBuckets() const = 0;
|
virtual typename R::BelBucketRangeT getBelBuckets() const = 0;
|
||||||
virtual typename R::BucketBelRangeT getBelsInBucket(BelBucketId bucket) const = 0;
|
virtual typename R::BucketBelRangeT getBelsInBucket(BelBucketId bucket) const = 0;
|
||||||
|
@ -127,8 +127,8 @@ fn_wrapper_0a<Context, decltype(&Context::archId), &Context::archId, conv_to_str
|
|||||||
fn_wrapper_2a_v<Context, decltype(&Context::writeSVG), &Context::writeSVG, pass_through<std::string>,
|
fn_wrapper_2a_v<Context, decltype(&Context::writeSVG), &Context::writeSVG, pass_through<std::string>,
|
||||||
pass_through<std::string>>::def_wrap(ctx_cls, "writeSVG");
|
pass_through<std::string>>::def_wrap(ctx_cls, "writeSVG");
|
||||||
|
|
||||||
fn_wrapper_1a<Context, decltype(&Context::isBelLocationValid), &Context::isBelLocationValid, pass_through<bool>,
|
fn_wrapper_2a<Context, decltype(&Context::isBelLocationValid), &Context::isBelLocationValid, pass_through<bool>,
|
||||||
conv_from_str<BelId>>::def_wrap(ctx_cls, "isBelLocationValid");
|
conv_from_str<BelId>, pass_through<bool>>::def_wrap(ctx_cls, "isBelLocationValid");
|
||||||
|
|
||||||
// const\_range\<BelBucketId\> getBelBuckets() const
|
// const\_range\<BelBucketId\> getBelBuckets() const
|
||||||
fn_wrapper_0a<Context, decltype(&Context::getBelBuckets), &Context::getBelBuckets,
|
fn_wrapper_0a<Context, decltype(&Context::getBelBuckets), &Context::getBelBuckets,
|
||||||
|
@ -357,7 +357,7 @@ template <typename R> struct BaseArch : ArchAPI<R>
|
|||||||
{
|
{
|
||||||
return getBelBucketByName(cell_type);
|
return getBelBucketByName(cell_type);
|
||||||
};
|
};
|
||||||
virtual bool isBelLocationValid(BelId bel) const override { return true; }
|
virtual bool isBelLocationValid(BelId bel, bool explain_invalid = false) const override { return true; }
|
||||||
virtual typename R::CellTypeRangeT getCellTypes() const override
|
virtual typename R::CellTypeRangeT getCellTypes() const override
|
||||||
{
|
{
|
||||||
NPNR_ASSERT(cell_types_initialised);
|
NPNR_ASSERT(cell_types_initialised);
|
||||||
|
@ -173,7 +173,7 @@ class SAPlacer
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx->bindBel(bel, cell, STRENGTH_USER);
|
ctx->bindBel(bel, cell, STRENGTH_USER);
|
||||||
if (!ctx->isBelLocationValid(bel)) {
|
if (!ctx->isBelLocationValid(bel, /* explain_invalid */ true)) {
|
||||||
IdString bel_type = ctx->getBelType(bel);
|
IdString bel_type = ctx->getBelType(bel);
|
||||||
log_error("Bel \'%s\' of type \'%s\' is not valid for cell "
|
log_error("Bel \'%s\' of type \'%s\' is not valid for cell "
|
||||||
"\'%s\' of type \'%s\'\n",
|
"\'%s\' of type \'%s\'\n",
|
||||||
@ -404,7 +404,7 @@ class SAPlacer
|
|||||||
ctx->yield();
|
ctx->yield();
|
||||||
for (auto bel : ctx->getBels()) {
|
for (auto bel : ctx->getBels()) {
|
||||||
CellInfo *cell = ctx->getBoundBelCell(bel);
|
CellInfo *cell = ctx->getBoundBelCell(bel);
|
||||||
if (!ctx->isBelLocationValid(bel)) {
|
if (!ctx->isBelLocationValid(bel, /* explain_invalid */ true)) {
|
||||||
std::string cell_text = "no cell";
|
std::string cell_text = "no cell";
|
||||||
if (cell != nullptr)
|
if (cell != nullptr)
|
||||||
cell_text = std::string("cell '") + ctx->nameOf(cell) + "'";
|
cell_text = std::string("cell '") + ctx->nameOf(cell) + "'";
|
||||||
|
@ -327,7 +327,7 @@ class HeAPPlacer
|
|||||||
bool any_bad_placements = false;
|
bool any_bad_placements = false;
|
||||||
for (auto bel : ctx->getBels()) {
|
for (auto bel : ctx->getBels()) {
|
||||||
CellInfo *cell = ctx->getBoundBelCell(bel);
|
CellInfo *cell = ctx->getBoundBelCell(bel);
|
||||||
if (!ctx->isBelLocationValid(bel)) {
|
if (!ctx->isBelLocationValid(bel, /* explain_invalid */ true)) {
|
||||||
std::string cell_text = "no cell";
|
std::string cell_text = "no cell";
|
||||||
if (cell != nullptr)
|
if (cell != nullptr)
|
||||||
cell_text = std::string("cell '") + ctx->nameOf(cell) + "'";
|
cell_text = std::string("cell '") + ctx->nameOf(cell) + "'";
|
||||||
@ -434,7 +434,7 @@ class HeAPPlacer
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx->bindBel(bel, cell, STRENGTH_USER);
|
ctx->bindBel(bel, cell, STRENGTH_USER);
|
||||||
if (!ctx->isBelLocationValid(bel)) {
|
if (!ctx->isBelLocationValid(bel, /* explain_invalid */ true)) {
|
||||||
IdString bel_type = ctx->getBelType(bel);
|
IdString bel_type = ctx->getBelType(bel);
|
||||||
log_error("Bel \'%s\' of type \'%s\' is not valid for cell "
|
log_error("Bel \'%s\' of type \'%s\' is not valid for cell "
|
||||||
"\'%s\' of type \'%s\'\n",
|
"\'%s\' of type \'%s\'\n",
|
||||||
|
@ -698,11 +698,15 @@ return the same value regardless if other cells are placed within the fabric.
|
|||||||
|
|
||||||
*BaseArch default: returns `cell_type == getBelType(bel)`*
|
*BaseArch default: returns `cell_type == getBelType(bel)`*
|
||||||
|
|
||||||
### bool isBelLocationValid(BelId bel) const
|
### bool isBelLocationValid(BelId bel, bool explain_invalid = false) const
|
||||||
|
|
||||||
Returns true if a bel in the current configuration is legal (for example,
|
Returns true if a bel in the current configuration is legal (for example,
|
||||||
a flipflop's clock signal is correctly shared with all bels in a slice.)
|
a flipflop's clock signal is correctly shared with all bels in a slice.)
|
||||||
|
|
||||||
|
If and only if `explain_invalid` is set to true, then a message using
|
||||||
|
`log_nonfatal_error` should be printed explaining why the placement is invalid
|
||||||
|
to the end user.
|
||||||
|
|
||||||
*BaseArch default: returns true*
|
*BaseArch default: returns true*
|
||||||
|
|
||||||
### static const std::string defaultPlacer
|
### static const std::string defaultPlacer
|
||||||
|
@ -64,7 +64,7 @@ X(F)
|
|||||||
```c++
|
```c++
|
||||||
bool checkBelAvail(BelId bel) const;
|
bool checkBelAvail(BelId bel) const;
|
||||||
bool isValidBelForCellType(IdString cell_type, BelId bel) const;
|
bool isValidBelForCellType(IdString cell_type, BelId bel) const;
|
||||||
bool isBelLocationValid(BelId bel) const;
|
bool isBelLocationValid(BelId bel, bool explain_invalid = false) const;
|
||||||
bool checkWireAvail(WireId wire) const;
|
bool checkWireAvail(WireId wire) const;
|
||||||
bool checkPipAvail(PipId pip) const;
|
bool checkPipAvail(PipId pip) const;
|
||||||
bool checkPipAvailForNet(PipId pip, NetInfo *net) const;
|
bool checkPipAvailForNet(PipId pip, NetInfo *net) const;
|
||||||
|
@ -1010,7 +1010,7 @@ struct Arch : BaseArch<ArchRanges>
|
|||||||
|
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
// Placement validity checks
|
// Placement validity checks
|
||||||
bool isBelLocationValid(BelId bel) const override;
|
bool isBelLocationValid(BelId bel, bool explain_invalid = false) const override;
|
||||||
|
|
||||||
// Helper function for above
|
// Helper function for above
|
||||||
bool slices_compatible(LogicTileStatus *lts) const;
|
bool slices_compatible(LogicTileStatus *lts) const;
|
||||||
|
@ -178,7 +178,7 @@ bool Arch::slices_compatible(LogicTileStatus *lts) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Arch::isBelLocationValid(BelId bel) const
|
bool Arch::isBelLocationValid(BelId bel, bool explain_invalid) const
|
||||||
{
|
{
|
||||||
IdString bel_type = getBelType(bel);
|
IdString bel_type = getBelType(bel);
|
||||||
if (bel_type.in(id_TRELLIS_COMB, id_TRELLIS_FF, id_TRELLIS_RAMW)) {
|
if (bel_type.in(id_TRELLIS_COMB, id_TRELLIS_FF, id_TRELLIS_RAMW)) {
|
||||||
|
@ -851,7 +851,7 @@ struct Arch : ArchAPI<ArchRanges>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return true whether all Bels at a given location are valid
|
// Return true whether all Bels at a given location are valid
|
||||||
bool isBelLocationValid(BelId bel) const final
|
bool isBelLocationValid(BelId bel, bool explain_invalid = false) const final
|
||||||
{
|
{
|
||||||
auto iter = tileStatus.find(bel.tile);
|
auto iter = tileStatus.find(bel.tile);
|
||||||
if (iter == tileStatus.end()) {
|
if (iter == tileStatus.end()) {
|
||||||
|
@ -693,10 +693,10 @@ TimingClockingInfo Arch::getPortClockingInfo(const CellInfo *cell, IdString port
|
|||||||
return tmg.clockingInfo.at(port).at(index);
|
return tmg.clockingInfo.at(port).at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Arch::isBelLocationValid(BelId bel) const
|
bool Arch::isBelLocationValid(BelId bel, bool explain_invalid) const
|
||||||
{
|
{
|
||||||
if (uarch)
|
if (uarch)
|
||||||
return uarch->isBelLocationValid(bel);
|
return uarch->isBelLocationValid(bel, explain_invalid);
|
||||||
std::vector<const CellInfo *> cells;
|
std::vector<const CellInfo *> cells;
|
||||||
Loc loc = getBelLocation(bel);
|
Loc loc = getBelLocation(bel);
|
||||||
for (auto tbel : getBelsByTile(loc.x, loc.y)) {
|
for (auto tbel : getBelsByTile(loc.x, loc.y)) {
|
||||||
|
@ -386,7 +386,7 @@ struct Arch : BaseArch<ArchRanges>
|
|||||||
{
|
{
|
||||||
return uarch ? uarch->isValidBelForCellType(cell_type, bel) : cell_type == getBelType(bel);
|
return uarch ? uarch->isValidBelForCellType(cell_type, bel) : cell_type == getBelType(bel);
|
||||||
}
|
}
|
||||||
bool isBelLocationValid(BelId bel) const override;
|
bool isBelLocationValid(BelId bel, bool explain_invalid = false) const override;
|
||||||
|
|
||||||
static const std::string defaultPlacer;
|
static const std::string defaultPlacer;
|
||||||
static const std::vector<std::string> availablePlacers;
|
static const std::vector<std::string> availablePlacers;
|
||||||
|
@ -62,7 +62,7 @@ struct ExampleImpl : ViaductAPI
|
|||||||
|
|
||||||
void prePlace() override { assign_cell_info(); }
|
void prePlace() override { assign_cell_info(); }
|
||||||
|
|
||||||
bool isBelLocationValid(BelId bel) const override
|
bool isBelLocationValid(BelId bel, bool explain_invalid) const override
|
||||||
{
|
{
|
||||||
Loc l = ctx->getBelLocation(bel);
|
Loc l = ctx->getBelLocation(bel);
|
||||||
if (is_io(l.x, l.y)) {
|
if (is_io(l.x, l.y)) {
|
||||||
|
@ -81,7 +81,10 @@ struct FabulousImpl : ViaductAPI
|
|||||||
}
|
}
|
||||||
|
|
||||||
void prePlace() override { assign_cell_info(); }
|
void prePlace() override { assign_cell_info(); }
|
||||||
bool isBelLocationValid(BelId bel) const override { return blk_trk->check_validity(bel, cfg, cell_tags); }
|
bool isBelLocationValid(BelId bel, bool explain_invalid) const override
|
||||||
|
{
|
||||||
|
return blk_trk->check_validity(bel, cfg, cell_tags);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FabricConfig cfg; // TODO: non-default config
|
FabricConfig cfg; // TODO: non-default config
|
||||||
|
@ -64,7 +64,7 @@ struct OkamiImpl : ViaductAPI
|
|||||||
|
|
||||||
void prePlace() override { assign_cell_info(); }
|
void prePlace() override { assign_cell_info(); }
|
||||||
|
|
||||||
bool isBelLocationValid(BelId bel) const override
|
bool isBelLocationValid(BelId bel, bool explain_invalid) const override
|
||||||
{
|
{
|
||||||
Loc l = ctx->getBelLocation(bel);
|
Loc l = ctx->getBelLocation(bel);
|
||||||
if (is_io(l.x, l.y)) {
|
if (is_io(l.x, l.y)) {
|
||||||
|
@ -67,7 +67,7 @@ struct ViaductAPI
|
|||||||
virtual BelBucketId getBelBucketForBel(BelId bel) const;
|
virtual BelBucketId getBelBucketForBel(BelId bel) const;
|
||||||
virtual BelBucketId getBelBucketForCellType(IdString cell_type) const;
|
virtual BelBucketId getBelBucketForCellType(IdString cell_type) const;
|
||||||
virtual bool isValidBelForCellType(IdString cell_type, BelId bel) const;
|
virtual bool isValidBelForCellType(IdString cell_type, BelId bel) const;
|
||||||
virtual bool isBelLocationValid(BelId bel) const { return true; }
|
virtual bool isBelLocationValid(BelId bel, bool explain_invalid = false) const { return true; }
|
||||||
|
|
||||||
// --- Wire and pip functions ---
|
// --- Wire and pip functions ---
|
||||||
// Called when a wire/pip is placed/unplaced (with net=nullptr for a unbind)
|
// Called when a wire/pip is placed/unplaced (with net=nullptr for a unbind)
|
||||||
|
@ -2028,7 +2028,7 @@ TimingClockingInfo Arch::getPortClockingInfo(const CellInfo *cell, IdString port
|
|||||||
return tmg.clockingInfo.at(port).at(index);
|
return tmg.clockingInfo.at(port).at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Arch::isBelLocationValid(BelId bel) const
|
bool Arch::isBelLocationValid(BelId bel, bool explain_invalid) const
|
||||||
{
|
{
|
||||||
Loc loc = getBelLocation(bel);
|
Loc loc = getBelLocation(bel);
|
||||||
|
|
||||||
|
@ -458,7 +458,7 @@ struct Arch : BaseArch<ArchRanges>
|
|||||||
// Get the TimingClockingInfo of a port
|
// Get the TimingClockingInfo of a port
|
||||||
TimingClockingInfo getPortClockingInfo(const CellInfo *cell, IdString port, int index) const override;
|
TimingClockingInfo getPortClockingInfo(const CellInfo *cell, IdString port, int index) const override;
|
||||||
|
|
||||||
bool isBelLocationValid(BelId bel) const override;
|
bool isBelLocationValid(BelId bel, bool explain_invalid = false) const override;
|
||||||
|
|
||||||
static const std::string defaultPlacer;
|
static const std::string defaultPlacer;
|
||||||
static const std::vector<std::string> availablePlacers;
|
static const std::vector<std::string> availablePlacers;
|
||||||
|
@ -840,7 +840,7 @@ struct Arch : BaseArch<ArchRanges>
|
|||||||
// implemented in arch_place.cc)
|
// implemented in arch_place.cc)
|
||||||
|
|
||||||
// Return true whether all Bels at a given location are valid
|
// Return true whether all Bels at a given location are valid
|
||||||
bool isBelLocationValid(BelId bel) const override;
|
bool isBelLocationValid(BelId bel, bool explain_invalid = false) const override;
|
||||||
|
|
||||||
// Helper function for above
|
// Helper function for above
|
||||||
bool logic_cells_compatible(const CellInfo **it, const size_t size) const;
|
bool logic_cells_compatible(const CellInfo **it, const size_t size) const;
|
||||||
|
@ -82,7 +82,7 @@ static inline bool _io_pintype_need_clk_en(unsigned pin_type)
|
|||||||
return _io_pintype_need_clk_in(pin_type) || _io_pintype_need_clk_out(pin_type);
|
return _io_pintype_need_clk_in(pin_type) || _io_pintype_need_clk_out(pin_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Arch::isBelLocationValid(BelId bel) const
|
bool Arch::isBelLocationValid(BelId bel, bool explain_invalid) const
|
||||||
{
|
{
|
||||||
if (getBelType(bel) == id_ICESTORM_LC) {
|
if (getBelType(bel) == id_ICESTORM_LC) {
|
||||||
std::array<const CellInfo *, 8> bel_cells;
|
std::array<const CellInfo *, 8> bel_cells;
|
||||||
|
@ -451,7 +451,7 @@ bool Arch::route()
|
|||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
|
|
||||||
bool Arch::isBelLocationValid(BelId bel) const
|
bool Arch::isBelLocationValid(BelId bel, bool explain_invalid) const
|
||||||
{
|
{
|
||||||
// FIXME: Same deal as isValidBelForCell.
|
// FIXME: Same deal as isValidBelForCell.
|
||||||
return true;
|
return true;
|
||||||
|
@ -643,7 +643,7 @@ struct Arch : BaseArch<ArchRanges>
|
|||||||
bool route() override;
|
bool route() override;
|
||||||
|
|
||||||
// Placer
|
// Placer
|
||||||
bool isBelLocationValid(BelId bel) const override;
|
bool isBelLocationValid(BelId bel, bool explain_invalid = false) const override;
|
||||||
|
|
||||||
static const std::string defaultPlacer;
|
static const std::string defaultPlacer;
|
||||||
static const std::vector<std::string> availablePlacers;
|
static const std::vector<std::string> availablePlacers;
|
||||||
|
@ -182,7 +182,7 @@ IdStringList Arch::getBelName(BelId bel) const
|
|||||||
return IdStringList(ids);
|
return IdStringList(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Arch::isBelLocationValid(BelId bel) const
|
bool Arch::isBelLocationValid(BelId bel, bool explain_invalid) const
|
||||||
{
|
{
|
||||||
auto &data = bel_data(bel);
|
auto &data = bel_data(bel);
|
||||||
if (data.type.in(id_MISTRAL_COMB, id_MISTRAL_MCOMB)) {
|
if (data.type.in(id_MISTRAL_COMB, id_MISTRAL_MCOMB)) {
|
||||||
|
@ -333,7 +333,7 @@ struct Arch : BaseArch<ArchRanges>
|
|||||||
PortType getBelPinType(BelId bel, IdString pin) const override { return bel_data(bel).pins.at(pin).dir; }
|
PortType getBelPinType(BelId bel, IdString pin) const override { return bel_data(bel).pins.at(pin).dir; }
|
||||||
std::vector<IdString> getBelPins(BelId bel) const override;
|
std::vector<IdString> getBelPins(BelId bel) const override;
|
||||||
|
|
||||||
bool isBelLocationValid(BelId bel) const override;
|
bool isBelLocationValid(BelId bel, bool explain_invalid = false) const override;
|
||||||
|
|
||||||
void bindBel(BelId bel, CellInfo *cell, PlaceStrength strength) override
|
void bindBel(BelId bel, CellInfo *cell, PlaceStrength strength) override
|
||||||
{
|
{
|
||||||
|
@ -1322,7 +1322,7 @@ struct Arch : BaseArch<ArchRanges>
|
|||||||
// implemented in arch_place.cc)
|
// implemented in arch_place.cc)
|
||||||
|
|
||||||
// Return true whether all Bels at a given location are valid
|
// Return true whether all Bels at a given location are valid
|
||||||
bool isBelLocationValid(BelId bel) const override;
|
bool isBelLocationValid(BelId bel, bool explain_invalid = false) const override;
|
||||||
|
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ bool Arch::nexus_logic_tile_valid(LogicTileStatus <s) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Arch::isBelLocationValid(BelId bel) const
|
bool Arch::isBelLocationValid(BelId bel, bool explain_invalid) const
|
||||||
{
|
{
|
||||||
if (bel_tile_is(bel, LOC_LOGIC)) {
|
if (bel_tile_is(bel, LOC_LOGIC)) {
|
||||||
LogicTileStatus *lts = tileStatus[bel.tile].lts;
|
LogicTileStatus *lts = tileStatus[bel.tile].lts;
|
||||||
|
Loading…
Reference in New Issue
Block a user