From b64bf018eae9aa97f850dde0823a5ed33fbfc863 Mon Sep 17 00:00:00 2001 From: Catherine Date: Fri, 31 Jan 2025 08:29:58 +0000 Subject: [PATCH] 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. --- frontend/frontend_base.h | 5 ++++- frontend/json_frontend.cc | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/frontend/frontend_base.h b/frontend/frontend_base.h index cd26349f..66977658 100644 --- a/frontend/frontend_base.h +++ b/frontend/frontend_base.h @@ -472,7 +472,10 @@ template struct GenericFrontend ci->ports[port_bit_ids].type = dir; // Resolve connectivity 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 net = create_constant_net(m, inst_name.str(ctx) + "." + port_bit_name + "$const", impl.get_vector_bit_constval(bits, i)); diff --git a/frontend/json_frontend.cc b/frontend/json_frontend.cc index 6004ee17..3351c98e 100644 --- a/frontend/json_frontend.cc +++ b/frontend/json_frontend.cc @@ -161,6 +161,12 @@ struct JsonFrontendImpl 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 { NPNR_ASSERT(i < int(bits.size()));