A barrel shifter is a digital circuit that can shift a data word by a specified number of bits without use of any sequential logic, only pure combinational logic
[1]. There are 3 type of bitwise shift operation: logical shift, arithmetic shift, and circular shift (rotate). We can shift the data to the left as well as to the right. The barrel shifter in this tutorial is a multifunction barrel shifter that can perform left or right circular shift. The basic barrel shifter in this tutorial is based on this book: FPGA Prototyping by Verilog Example by Pong P. Chu. You can also learn the basic of Verilog language from this book.
The multifunction barrel shifter in this tutorial is actually a suggested experiment from chapter 3 of the book. There are 2 design that will be implemented in this tutorial. The first design is using 1 rotate-left circuit, 1 rotate-right circuit, and one 2-to-1 multiplexer to select the desired result. The top level schematic of the first design is like this:
The second design is implemented using 1 rotate-left shifter with pre- and post- reversing circuit. The reversing circuit either pass the original input or reverses the input bitwise. For example, if the input is a7,a6,a5,a4,a3,a2,a1,a0 then the reversed result become a0,a1,a2,a3,a4,a5,a6,a7. The top level schematic of the second design is like this: