frontend: don't connect a const net to ports connected to `x`. (#1447)

prjunnamed normalizes ports that are not present in the primitive
to be all-x. On iCE40, this can cause a false placement conflict
between `SB_IO` cells where one's clock input is `x` and another's is
some other net.
This commit is contained in:
Catherine 2025-01-31 08:29:58 +00:00 committed by GitHub
parent 81ccada239
commit b64bf018ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -472,7 +472,10 @@ template <typename FrontendType> struct GenericFrontend
ci->ports[port_bit_ids].type = dir; ci->ports[port_bit_ids].type = dir;
// Resolve connectivity // Resolve connectivity
NetInfo *net; NetInfo *net;
if (impl.is_vector_bit_constant(bits, i)) { if (impl.is_vector_bit_undef(bits, i)) {
// Don't connect it if it's an `x`
continue;
} else if (impl.is_vector_bit_constant(bits, i)) {
// Create a constant driver if one is needed // Create a constant driver if one is needed
net = create_constant_net(m, inst_name.str(ctx) + "." + port_bit_name + "$const", net = create_constant_net(m, inst_name.str(ctx) + "." + port_bit_name + "$const",
impl.get_vector_bit_constval(bits, i)); impl.get_vector_bit_constval(bits, i));

View File

@ -161,6 +161,12 @@ struct JsonFrontendImpl
int get_vector_length(BitVectorDataType &bits) const { return int(bits.size()); } int get_vector_length(BitVectorDataType &bits) const { return int(bits.size()); }
bool is_vector_bit_undef(BitVectorDataType &bits, int i) const
{
NPNR_ASSERT(i < int(bits.size()));
return bits[i] == "x";
}
bool is_vector_bit_constant(BitVectorDataType &bits, int i) const bool is_vector_bit_constant(BitVectorDataType &bits, int i) const
{ {
NPNR_ASSERT(i < int(bits.size())); NPNR_ASSERT(i < int(bits.size()));