exp_3
exp_3
exp_3
Resources Required:
Theory
A group of flip flops which is used to store multiple bits of data and the data is moved from one flip
flop to another is known as shift register. The bits stored in registers shifted when the clock pulse is
applied within and inside or outside the registers. A Shift Register can shift the bits either to the left or
to the right. A Shift Register, which shifts the bit to the left, is known as "Shift left register", and it
shifts the bit to the right, known as "Right left register".
Verilog Code: -
RTL Design
`timescale 1ns / 1ps
module shift_reg(
input clk,
input clr,
input shift,
input ld,
input[7:0] Din,
input SI,
output reg [7:0]Dout
);
always@(posedge clk)
begin
if(clr) Dout<=0;
else if(ld) Dout<=Din;
else if(shift) Dout<={Dout[6:0],SI};
end
endmodule
Testbench
module test_shift;
initial
begin
Din=8'b00000001;
1
clr =1'b0;
ld=1'b1;
#20 ld =1'b0;
SI=1'b1;
shift=1'b1;
#20 ld =1'b0;
SI=1'b1;
shift=1'b1;
#20 $finish;
end
endmodule
OUTPUT: -
Figure 1. and Figure 2. shows the Simulation Waveform and RTL Design of the above Verilog
code respectively
Results:
Verilog Code for Shift Register is simulated, and RTL schematic was also generated.