Universal Shift Register
Introduction to Universal Shift Register
The Universal Shift Register is a digital
circuit that can shift data both left and right.
It can also perform parallel loading of data.
The shift register is a vital component in
many applications, including data
communication and storage systems.
2
Basic Operation of Universal Shift Register
The Universal Shift Register consists of a set
of flip-flops connected in series.
The shift register has two modes of
operation: serial and parallel.
In the serial mode, data is shifted in or out
one bit at a time.
In the parallel mode, data is loaded all flip-
flops of a register at one time.
3
Serial and Parallel Loading
In serial loading, data is shifted in or out one
bit at a time.
In parallel loading, all bits are loaded
simultaneously.
The loading mode is controlled by the
shift/load control signal.
4
Verilog Code for Universal Shift Register
Here is an example of Verilog code for a universal shift
register:
module usr(dataout,clock,reset,mode,datain);
output reg[3:0]dataout;
input clock,reset;
input [1:0]mode;
input [3:0]datain;
always@(posedge clock)
begin
if(reset)
dataout<=0;
else
begin
case(mode)
2'b00:dataout<=dataout;
2'b01:dataout<={datain[0],datain[3:1]};
2'b10:dataout<={datain[2:0],datain[3]};
2'b11:dataout<=datain;
endcase
end
end
endmodule
5
Verilog Code for Universal Shift Register
Here is an testbench code for a universal shift register:
module usr_testbench();
reg [3:0]datain;
reg clock,reset;
reg [1:0]mode;
wire [3:0]dataout;
usr m1(dataout,clock,reset,mode,datain);
initial begin
clock=0;
repeat(100)
#20 clock=~clock;
end
initial begin
datain=4'b1010;
mode=2'b00;
reset=1'b0;
#20;
datain=4'b1010;
mode=2'b01;
reset=1'b0;
#20;
datain=4'b1010;
mode=2'b10;
reset=1'b0;
#20;
datain=4'b1010;
mode=2'b11;
reset=1'b0;
#20;
$finish();
end
endmodule
6
Applications of Universal Shift Register
Universal shift registers are commonly used
in serial data communication systems.
They are also used in storage devices like
shift registers and memory units.
The flexibility of universal shift registers
makes them suitable for various applications.