← ProblemsCircuits / Combinational Logic / Multiplexers
256-to-1 4-bit multiplexer
15%muxvectorsBuild a 4-bit wide, 256-to-1 multiplexer. The 256 four-bit words are packed into one 1024-bit input vector:
sel = 0selectsin[3:0],sel = 1selectsin[7:4],sel = 2selectsin[11:8], and so on up tosel = 255selectingin[1023:1020].
The catch: a classic part-select like in[sel*4+3 : sel*4] is illegal because both bounds are variable. Verilog-2001's indexed part select exists precisely for this — a variable starting position with a constant width.