Fa19 Eee 025 (DSD Lab05)
Fa19 Eee 025 (DSD Lab05)
Design and Implementation of a Four Digit Decimal Counter on Nexys2 FPGA Board
Lab Assessment
Introduction:
The lab aimed to implement up/down counter with terminal count and reset on FPGA. We were
able to learn how to use the internal clock of FPGA and implement clock divisor. The counter
value will be displayed on 7-segment displays of Nexys2 board so we implement scanning
display controller to control multiple 7-segment displays because they have a common data bus
(CA – DP).The 4 seven segments of Nexys 2 board are common anode in configuration. A clock
divisor circuit was designed that converts internal 20nsec clock to 40ns to visualize the results on
seven segments as FPGA clock 20ns can’t be seen toggling due to persistence of vision. As 4-
digit 7-segment displays have a common data bus so multiplexer is used to select one data and
segment id at a time of refresh period. Seven segment display controller was also designed that
Page |2
helps to illuminate all four digits continuously. The results are displayed on FPGA 7 segments
and shown to the instructor.
Pre-Lab Task:
always@(BCD)
begin
case (BCD)
0 : segreg = 7'b0000001;
1 : segreg = 7'b1001111;
2 :segreg = 7'b0010010;
3 :segreg = 7'b0000110;
4 :segreg = 7'b1001100;
5 :segreg = 7'b0100100;
Page |3
Counter Module:
module COUNTER(clk,rst,en,UPcounter,count,tc);
input clk;
input rst;
input en;
input UPcounter;
if(rst) begin
Page |4
module MUXfourxone(
input [3:0] A,
input [3:0] B,
input [3:0] C,
input [3:0] D,
input [1:0] S,
module BinaryToBCD(binary,ones,tens,hundreds,thousands);
parameter n = 14;
input [n-1:0] binary; output reg [3:0] ones; output reg [3:0] tens;
thousands = 4'd0;
hundreds = 4'd0;
tens = 4'd0;
ones = 4'd0;
Page |6
Main Module:
module main(
input clk,
input rst,
input en,
input UPcounter,
);
Page |7
FPGA Implementation:
Module:
module tb_reset_counter;
// Inputs
reg clk;
reg En;
reg UD;
reg [7:0] S;
// Outputs
wire [24:0] count;
wire sclk;
wire rst;
Fig11: Simulation
Critical Analysis/Conclusion:
In this lab we were assigned task to design up/down counter that counts the number in decimal
digits from 0 to 9999 and the results are displayed on 4 seven segments of Nexys 2 board which
are common anode in configuration. A clock divisor circuit was designed that converts internal
20nsec clock to 40ns to visualize the results on seven segments. As 4-digit 7-segment displays
have a common data bus so multiplexer is used to select one data and segment id at a time of
refresh period. Seven segment display controller was also designed that helps to illuminate all
four digits continuously. The results are displayed on FPGA 7 segments and shown to the
instructor.
P a g e | 11
THE END