Bidirectional Shift Registers: Definition, Working and Applications

💡
Key learnings:
  • Bidirectional Shift Register Definition: A bidirectional shift register is defined as a storage device that can shift data right or left depending on the selected mode.
  • Shift Register Function: A shift register uses a series of flip-flops to store and move data bits either serially or in parallel.
  • Direction Control: Bidirectional shift registers use mode control inputs to determine the direction of data shifts—right when high, left when low.
  • Applications: They are used in data manipulation, arithmetic operations, serial communication, and data conversion.
  • Data Operations: They enable complex data operations like reversing, rotating, and encrypting by shifting bits in specified patterns.

A bidirectional shift register is defined as a storage device that shifts data right or left based on the mode selected. It supports both serial and parallel input and output operations. It is used for data manipulation, arithmetic operations, serial communication, data conversion, and encryption.

What is a Shift Register?

A shift register is a cascade of flip-flops where one flop’s output pin Q is connected to the next data input pin D. Because all flops work on the same clock, the bit array stored in the shift register will shift by one position. For example, if a 5-bit right shift register has an initial value of 10110 and the input to the shift register is tied to 0, then the next pattern will be 01011 and the next 00101.

There are different types of shift registers based on the input and output modes, such as:

  • Serial In Serial Out (SISO) shift register: The data is shifted in and out serially, one bit at a time.
  • Serial In Parallel Out (SIPO) shift register: The data is shifted in serially but read out in parallel, all bits at once.
  • Parallel In Serial Out (PISO) shift register: The data is loaded in parallel but shifted out serially, one bit at a time.
  • Parallel In Parallel Out (PIPO) shift register: The data is loaded and read out in parallel, all bits at once.

How Does a Bidirectional Shift Register Work?

A bidirectional shift register can perform both left and right shifts depending on the mode selected. It has two serial inputs: Data Right (DR) and Data Left (DL), and one mode control input (M). When the data needs to be shifted right, the input is given to DR. When the data needs to be shifted left, the input is given to DL. When M is high (1), the data will be shifted right. When M is low (0), the data will be shifted left.

An n-bit bidirectional shift register can load and retrieve data serially. First, all flip-flops are reset by driving their clear pins high. Then, the R/L̅ control line is set to low or high to choose left-shift or right-shift of the data bits.

bidirectional shift registers

If R/L̅ = 1, then the A1 gates of all the combinational circuits get activated while the A2 gates will get disabled at the same time. Due to this, the outputs of each flip-flop appear at the inputs of the very-next flip-flop via OR gate output (except for the last flip-flop FFn).

For example, Q1 appears at D2 via the output of OR gate 1 (O1), Q2 appears at D3 via the output of OR gate 2 (O2), … and Qn-1 appears at Dn via the output of OR gate n (On) (red lines). At this instant, if the positive edge of the clock pulse appears, then the outputs of the respective flip-flops reflect their inputs. Thus Q1 = D1, Q2 = Q1,… and Qn = Qn-1. This is nothing but a right shift of the data by a single bit within the register. Following on the same grounds, one can note that for every rising edge of the clock, the data within the register shifts right by a single bit as long as R/L̅ remains high.

On the other hand, if R/L̅ goes low, then the A2 gates of the combinational circuits get enabled while the A1 gates get deactivated. This causes the outputs of each flip-flop to appear at the input pins of the very-previous flip-flop through their OR gate outputs (except for the first flip-flop FF1). For example, Qn appears at Dn-1 through the output of OR gate n-1 (On-1), … Q3 appears at D2 via the output of OR gate 2 (O2), and Q2 appears at D1 via the output of OR gate 1 (O1). These input bits are latched onto their respective output pins as soon as the leading edge of the clock pulse appears, and thus Qn-1 = Qn, …Q2 = Q3 and Q1 = Q2 (green lines). This means that for every clock tick, the data within the register moves left by one bit, provided R/L̅ line is zero.

The working of such a bidirectional register can be summarized in Table I and can be further explained by the output waveforms shown in Figure 2.

data movement in bidirectional shift register


output waveform of n-bit bidirectional shift register


What are Some Applications of Bidirectional Shift Registers?


Bidirectional shift registers have many applications in digital systems, such as:


  • Data manipulation: Bidirectional shift registers can be used to perform various operations on data bits, such as reversing, rotating, shuffling, and swapping. For example, a bidirectional shift register can reverse the order of bits by shifting them left or right alternatively until they reach the opposite ends.

  • Arithmetic operations: Bidirectional shift registers can be used to perform multiplication and division by shifting the data left or right by a certain number of positions. For example, a bidirectional shift register can multiply a binary number by 2^n by shifting it left by n positions or divide it by 2^n by shifting it right by n positions.

  • Serial communication: Bidirectional shift registers can be used to convert parallel data into serial data or vice versa for transmitting or receiving data over a single wire. For example, a bidirectional shift register can act as a parallel-to-serial converter by loading the parallel data into its flip-flops and shifting them out serially through its output pin or as a serial-to-parallel converter by shifting in the serial data through its input pin and reading them out in parallel from its flip-flops.

  • Data conversion: Bidirectional shift registers can be used to convert binary data into other formats, such as binary-coded decimal (BCD), gray code, or ASCII code. For example, a bidirectional shift register can convert a binary number into BCD by shifting it right four times and adding 3 to each group of four bits if they are greater than 4.

  • Encryption: Bidirectional shift registers can be used to encrypt or decrypt data by shifting them with a certain pattern or key. For example, a bidirectional shift register can encrypt a message by shifting it left or right according to a secret sequence of bits or decrypt it by reversing the process.


Verilog Code for Bidirectional Shift Register


The following code shows how to implement an n-bit bidirectional shift register using Verilog. The design is parameterized using the parameter MSB to signify the width of the shift register. If n is 4, then it becomes a 4-bit shift register. If n is 8, then it becomes an 8-bit shift register. This shift register has a few key features:


  • It can be enabled or disabled by driving en pin.

  • It can shift to the left as well as right when dir is driven.

  • If rstn is pulled low, it will reset the shift register, and output will become 0.

  • The input data value of the shift register can be controlled by the d pin.


Conclusion


Bidirectional shift registers are useful devices that can store and manipulate data bits by shifting them either right or left, depending on the mode selected. They have many applications in digital systems, such as data manipulation, arithmetic operations, serial communication, data conversion, and encryption. They can be implemented using flip-flops and logic gates and can be designed using Verilog code. Bidirectional shift registers are an important concept in digital logic and electronics.

Want To Learn Faster? 🎓
Get electrical articles delivered to your inbox every week.
No credit card required—it’s 100% free.

About Electrical4U

Electrical4U is dedicated to the teaching and sharing of all things related to electrical and electronics engineering.