Chapter 7 The Shift Register
A shift register is another common building block for many designs. In this chapter, we look at an 8-bit barrel shifter that can shift any number of bits either left or right. This function can be useful for aligning microprocessor buses of different sizes.
7.1 Behavioral Code
The following behavioral code makes use of the fact that the load input takes priority over the other control inputs. An always block is used to look for changes in the load input. If the load input is asserted, the always block is executed, which then looks for the next rising clock edge. If the load input is still asserted at the clock edge, it forces the output to the value of the input. If the load gets deasserted, the always block will ...