← ProblemsVerilog Language / More Verilog Features

Vector reversal 2

36%loops-generatevectors

Given a 100-bit input vector in[99:0], output it with the bit order reversed: out[0] = in[99], out[1] = in[98], … out[99] = in[0].

A 100-term concatenation would technically work, but this is the moment to learn the looping constructs: write the connection pattern once and let a for loop (inside a combinational always @(*) block) or a generate loop repeat it 100 times.