Skip to content

Commit

Permalink
frontend: don't connect a const net to ports connected to x.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
whitequark committed Jan 30, 2025
1 parent 81ccada commit e1b59e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion frontend/frontend_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,10 @@ template <typename FrontendType> 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));
Expand Down
6 changes: 6 additions & 0 deletions frontend/json_frontend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down

0 comments on commit e1b59e5

Please sign in to comment.