2 // test case taken from amber23 Verilog code
3 module a23_barrel_shift_fpga_rotate(i_in, direction, shift_amount, rot_prod);
7 input [4:0] shift_amount;
8 output [31:0] rot_prod;
10 // Generic rotate. Theoretical cost: 32x5 4-to-1 LUTs.
11 // Practically a bit higher due to high fanout of "direction".
14 for (i = 0; i < 5; i = i + 1)
18 for (j = 0; j < 32; j = j + 1)
21 out[j] = in[j] & (~shift_amount[i] ^ direction) |
22 in[wrap(j, i)] & (shift_amount[i] ^ direction);
26 // Order is reverted with respect to volatile shift_amount[0]
27 assign netgen[4].in = i_in;
28 for (i = 1; i < 5; i = i + 1)
30 assign netgen[i-1].in = netgen[i].out;
35 assign rot_prod = netgen[0].out;
42 out = pos - (1 << level);