Professional Documents
Culture Documents
EEE 304 - Exp8
EEE 304 - Exp8
EEE 304 - Exp8
BANGLADESH UNIVERSITY OF ENGINEERING & TECHNOLOGY
EEE 304 : Digital Electronics Laboratory
EXPT NO. 8: DESIGN, SIMULATION AND TEST OF SEQUENTIAL
CIRCUITS USING VERILOG AND IMPLEMENTATION IN FPGA.
Objective: The objective of this experiment is to design sequential circuit with
CAD tools by using verilog HDL. We will learn various techniques to write
verilog codes for sequential circuits.
PRELAB
Submit your Prelab before starting the experiment.
1. Write the verilog code of a D type Flipflop with asynchronous reset.
Also draw its logic circuit diagram.
2. Write the verilog code of a D type Flipflop with synchronous reset. Also
draw its logic circuit diagram.
3. Write the verilog code of a T type flipflop with synchronous reset. Also
draw its logic circuit diagram.
4. Write the verilog code of a 4 bit up counter with asynchronous reset. Also
draw its logic circuit diagram.
5. Write down the verilog code of a 4bit counter which has three control
inputs for operations: Up, Down and Load. The order of precedence is
Load, Up and Down.
Problem 1 Design, simulation and implementation of basic flipflop’s in FPGA.
Write a verilog program which will generate a D fillip flop with asynchronous reset &
negative edge clock, a D flipflop with synchronous reset & positive edge clock, and a
T flip flop with synchronous reset & positive edge clock as shown below.
D0 Q0 D1 Q1 T Q2
47 7 48 8 49 9
RST RST RST
56 62 63
clk0 clk1 clk2
54 124 126
© A.B.M. Harunur Rashid 20/12/2006
1
Simulate and test the circuit using Quartus II software. Select the Flex 10K device
EPF10K10TC1444. The timing diagram must be checked after Fitter and Assembler is
run. Implement the circuit in FPGA board LP2900. Assign the pins as shown in the
diagram above. .
Show the functionality of the fabricated circuit to your instructor and take signature in
the data sheet.
Write a verilog program which will generate a 4bit up counter with negative edge
asynchronous reset and positive edge clock. Simulate and test the circuit using Quratus
II software. Select the Flex 10K device EPF10K10TC1444. The timing diagram must be
checked after Fitter and Assembler is run. Implement the circuit in FPGA board
LP2900. Assign the pins as shown in the figure below.
Q3:Q0
RST
5 7,8,9,10
CLK
124
Show the functionality of the fabricated circuit to your instructor and take signature in
the data sheet.
Problem 3 Design, simulation , test and FPGA implementation of a 4 bit binary up
down counter.
Write the verilog code of a binary updown counter with provision to load data. The
order of precedence is Load, Up and Down. Simulate and test the circuit using Quratus
II software. Select the Flex 10K device EPF10K10TC1444. The timing diagram must be
checked after Fitter and Assembler is run. Implement the circuit in FPGA board
LP2900. Assign the pins as shown in the figure below.
In3 : In0
47,48,49,51 Q3:Q0
Load
59 7,8,9,10
Up
60
Down
62
CLK
63
© A.B.M. Harunur Rashid 20/12/2006
2
Show the functionality of the fabricated circuit to your instructor and take signature in
the data sheet.
Problem 4 Design, simulation, test and FPGA implementation of a 4bit end around
shift register.
Write the verilog code of a 4bit end around shift register. The register right shift the
data one bit at the positive edge of the clock when the load signal L is low. It load data
at the positive edge of the clock when the L signal is high. Simulate and test the circuit
using Quratus II software. Select the Flex 10K device EPF10K10TC1444. The timing
diagram must be checked after Fitter and Assembler is run. Implement the circuit in
FPGA board LP2900. Assign the pins as shown in the figure below.
D3 D2 D1 D0
D3 Q3 D2 Q2 D1 Q1 D0 Q0
47 7 48 8 49 9 51 10
L L L L
6
CLK CLK CLK CLK
6
REPORT
For each of the four problems above`` provide the following in your report.
• The verilog source code of the problem.
• The simulated waveform done in Quartus II
• The data sheet with signature from the instructor.
• Discussions and comment
Additional questions
(1) Write the verilog code of a nbit end around shift register with provision to load
data depending on a control signal sel.
(2) Propose a digital scheme which will detect the number of 1’s in a 4bit number and
it will do end around left shift total number of 1s’ times. e. g. If the number is 0101, it
will do end around left shift twice. If it is 1011, it will end around left shift thrice. This
is NOT a verilog problem. You will have to draw logic circuit.
© A.B.M. Harunur Rashid 20/12/2006
3
Reviewed By: Md. Imran Momtaz
© A.B.M. Harunur Rashid 20/12/2006
4
Problem1
module DT(D0,D1,T,RST0,CLK0,RST1,CLK1,RST2,CLK2,Q0,Q1,Q2,LED_COM);
input D0,D1,T,RST0,RST1, RST2,CLK0,CLK1,CLK2;
output Q0,Q1,Q2;
inout LED_COM;
D_FFASYN(D0,RST0,CLK0,Q0);
D_FFSYN(D1,RST1,CLK1,Q1);
T_FFSYN(T,RST2,CLK2,Q2);
assign LED_COM=1;
endmodule
module D_FFASYN(D0,RST0,CLK0,Q);
input D0, RST0, CLK0;
output Q;
reg Q;
always@(negedge CLK0 or negedge RST0)
begin
if(RST0==0) Q=0;
else Q=D0;
end
endmodule
module D_FFSYN(D1,RST1,CLK1,Q);
input D1, RST1, CLK1;
output Q;
reg Q;
always@(posedge CLK1)
begin
if(RST1==0) Q=0;
else Q=D1;
end
endmodule
module T_FFSYN(T,RST2,CLK2,Q);
input T, RST2, CLK2;
output Q;
reg Q;
always@(posedge CLK2)
begin
if(RST2==0) Q=0;
else begin
if (T)Q=~Q;
else Q=Q;
end
end
© A.B.M. Harunur Rashid 20/12/2006
5
endmodule
Problem2
module upcounter(rst, clk, Q, LED_COM);
input rst, clk;
output [3:0] Q;
inout LED_COM;
reg [3:0] Q;
always@(posedge clk or negedge rst) begin
if (rst==0)Q=0;
else Q=Q+1;
end
assign LED_COM=1;
endmodule
Problem3
module counter (up,down,load,clk,In,Q,LED_COM);
input up,down,load,clk;
input [3:0]In;
output [3:0]Q;
reg [3:0] Q;
inout LED_COM;
always@(posedge clk)
begin
if(load)
Q=In;
else if (up)
Q=Q+1;
else if (down)
Q=Q1;
else
Q=Q;
end
assign LED_COM=1;
endmodule
Problem4
module ShiftR4(D,L,Clock,Q,LED_COM);
input [3:0]D;
input L,Clock;
output [3:0]Q;
reg [3:0] Q;
inout LED_COM;
assign LED_COM=1;
always@(posedge Clock)
© A.B.M. Harunur Rashid 20/12/2006
6
if (L)
Q=D;
else
Q[3:0]={Q[0],Q[3:1]};
endmodule
© A.B.M. Harunur Rashid 20/12/2006
7