Prev Problem
Next Problem

70. Universal Barrel Shifter

Shift/rotate an 8-bit word by a variable amount (0–7). Supports logical left/right, arithmetic right, rotate left/right, and pass-through.

Requirements

  • Module: univ_barrel8
  • Inputs: x[7:0], sh[2:0], mode[2:0]
  • Outputs: y[7:0]
  • Keep it fully combinational (no clocks, no delays).

Behavior

  • Inputs: x[7:0], sh[2:0], mode[2:0]
  • Output: y[7:0]
  • Modes (unsigned unless noted):
    • 3'b000PASS
    • 3'b001LSL (logical left)
    • 3'b010LSR (logical right)
    • 3'b011ASR (arithmetic right, sign-extend)
    • 3'b100ROL (rotate left)
    • 3'b101ROR (rotate right)
    • 3'b110/111reserved (treat as PASS in reference)