← ProblemsCircuits / Combinational Logic / Basic Gates

Even longer vectors

36%vectorsbasics

The same neighbour-relationship circuit as before, scaled up to a 100-bit input in[99:0]:

  • out_both[98:0] — bit i is 1 when in[i] and in[i+1] are both 1 (bit 99 has no higher neighbour).
  • out_any[99:1] — bit i is 1 when in[i] or in[i-1] is 1 (bit 0 has no lower neighbour; the output is declared with range [99:1]).
  • out_different[99:0] — bit i is 1 when in[i] differs from its higher neighbour, treating the vector as circular (bit 99's higher neighbour is bit 0).

At this size, writing 100 single-bit assignments is hopeless — use part-selects, so each output stays a one-line bitwise expression.