Home / Learn Verilog / Barrel Shifter

Barrel Shifter

Shift by any amount in one step.

In shortShift by any amount in one step.

What's actually going on

Mux stagesstage 1: shift by 1?stage 2: shift by 2?stage 3: shift by 4?
Mux stages

Definition

A barrel shifter shifts or rotates by a variable amount using layers of muxes.

Why you need this

Fast shifts in CPUs and floating point.

How it works

Use the shift operator with a variable amount.

Where you'll see this

  • Everyday RTL design
  • FPGA and ASIC projects
  • Testbenches and debugging

Try it

Rotate leftVerilog: edit and run

Doubling the word makes rotation a slice.

Test what you just read

1. Barrel shifter shifts by...