From 603b60da8dcadf23eec8609ffc128f8f191c1122 Mon Sep 17 00:00:00 2001 From: gatecat Date: Wed, 7 Dec 2022 10:27:58 +0100 Subject: api: add explain_invalid option to isBelLocationValid Signed-off-by: gatecat --- ice40/arch.h | 2 +- ice40/arch_place.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'ice40') diff --git a/ice40/arch.h b/ice40/arch.h index 9d10cddf..d80d6f64 100644 --- a/ice40/arch.h +++ b/ice40/arch.h @@ -840,7 +840,7 @@ struct Arch : BaseArch // implemented in arch_place.cc) // 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 bool logic_cells_compatible(const CellInfo **it, const size_t size) const; diff --git a/ice40/arch_place.cc b/ice40/arch_place.cc index 5c3fa3c5..d8232571 100644 --- a/ice40/arch_place.cc +++ b/ice40/arch_place.cc @@ -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); } -bool Arch::isBelLocationValid(BelId bel) const +bool Arch::isBelLocationValid(BelId bel, bool explain_invalid) const { if (getBelType(bel) == id_ICESTORM_LC) { std::array bel_cells; -- cgit v1.2.3 From df99b4ff6c5ce88ce1a731dc8682ab1875b8c237 Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Sun, 30 Oct 2022 19:21:41 -0400 Subject: ice40: Add debugs to isBelLocationValid for SB_IO When there is a constraint conflict while placing IOs, the user gets an error message such as ERROR: Bel 'X0/Y27/io1' of type 'SB_IO' is not valid for cell 'my_pin' of type 'SB_IO' While this identifies the problematic cell, it does not explain why there is a problem. Add some verbose messages to allow users to determine where the problem is. This can result in something like Info: Net '$PACKER_VCC_NET' for cell 'my_pin' conflicts with net 'ce' for 'ce_pin' which provides something actionable. Signed-off-by: Sean Anderson --- ice40/arch_place.cc | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'ice40') diff --git a/ice40/arch_place.cc b/ice40/arch_place.cc index d8232571..1d69d62f 100644 --- a/ice40/arch_place.cc +++ b/ice40/arch_place.cc @@ -124,6 +124,8 @@ bool Arch::isBelLocationValid(BelId bel, bool explain_invalid) const return true; // Conflict + if (explain_invalid) + log_nonfatal_error("Cell '%s' conflicts with PLL cell '%s'\n", nameOf(cell), nameOf(pll_cell)); return false; } } @@ -135,18 +137,29 @@ bool Arch::isBelLocationValid(BelId bel, bool explain_invalid) const // Check LVDS pairing if (cell->ioInfo.lvds) { // Check correct z and complement location is free - if (ioLoc.z != 0) + if (ioLoc.z != 0) { + if (explain_invalid) + log_nonfatal_error("Bel '%s' can't be used for LVDS\n", getCtx()->nameOfBel(bel)); return false; + } BelId compBel = getBelByLocation(compLoc); CellInfo *compCell = getBoundBelCell(compBel); - if (compCell) + if (compCell) { + if (explain_invalid) + log_nonfatal_error("Cell '%s' LVDS complement occupied by cell '%s'\n", nameOf(cell), + nameOf(compCell)); return false; + } } else { // Check LVDS IO is not placed at complement location BelId compBel = getBelByLocation(compLoc); const CellInfo *compCell = getBoundBelCell(compBel); - if (compCell && compCell->ioInfo.lvds) + if (compCell && compCell->ioInfo.lvds) { + if (explain_invalid) + log_nonfatal_error("Cell '%s' can't occupy LVDS complement of cell '%s'\n", nameOf(cell), + nameOf(compCell)); return false; + } // Check for conflicts on shared nets // - CLOCK_ENABLE @@ -168,8 +181,13 @@ bool Arch::isBelLocationValid(BelId bel, bool explain_invalid) const }; for (int i = 0; i < 6; i++) - if (use[i] && (nets[i] != nets[i ^ 1]) && (use[i ^ 1] || (nets[i ^ 1] != nullptr))) + if (use[i] && (nets[i] != nets[i ^ 1]) && (use[i ^ 1] || (nets[i ^ 1] != nullptr))) { + if (explain_invalid) + log_nonfatal_error("Net '%s' for cell '%s' conflicts with net '%s' for '%s'\n", + nameOf(nets[i]), nameOf(cell), nameOf(nets[i ^ 1]), + nameOf(compCell)); return false; + } } } -- cgit v1.2.3