wire / wire-format / barrel-shifter

Barrel shifter

A barrel shifter shifts/rotates an n-bit value by any amount in a single cycle. It uses log2(n) stages of 2:1 multiplexers. Stage i shifts by 2^i if the corresponding bit of the shift amount is 1. Supports: SHL (shift left logical), SHR (shift right logical), SAR (shift right arithmetic), ROL (rotate left), ROR (rotate right).

wire-format kind wire-format status standard verification verified tier B wire-format@1

aka: Barrel shifter

wire format

spec: Digital logic design

A barrel shifter shifts/rotates an n-bit value by any amount in a single cycle. It uses log2(n) stages of 2:1 multiplexers. Stage i shifts by 2^i if the corresponding bit of the shift amount is 1. Supports: SHL (shift left logical), SHR (shift right logical), SAR (shift right arithmetic), ROL (rotate left), ROR (rotate right).

fieldsizemeaning
Stage 0n 2:1 muxesShift by 0 or 1 bit (controlled by shift_amount[0]).
Stage 1n 2:1 muxesShift by 0 or 2 bits (controlled by shift_amount[1]).
Stage in 2:1 muxesShift by 0 or 2^i bits (controlled by shift_amount[i]).
Total stageslog2(n)For 32-bit: 5 stages. For 64-bit: 6 stages.
Total muxesn * log2(n)For 32-bit: 32 * 5 = 160 muxes.
Shift amountlog2(n) bitsFor 32-bit: 5 bits (0-31). For 64-bit: 6 bits (0-63).

example:

00 00 00 00

Barrel shifter (placeholder)


provenance

agent: curl -H 'accept: application/json' wire.phall.io/wire-format/barrel-shifter or /wire-format/barrel-shifter.json