BCD To 7 Segment
BCD To 7 Segment
BCD To 7 Segment
Purpose
To introduce the student to the hardware description language VHDL, the digital system design
environment of Xilinx ISE, the Xilinx Coolrunner XPLA3 CPLD, and the Digilab XCR Plus
development board. The student will learn how to design, simulate, synthesize, download, and verify
a combinational logic circuit using programmable logic (CPLD). The student will design build and
test a BCD-7 Segment decoder using VHDL and the Xilinx ISE design environment and the Digilent
XCR Development Board.
Introduction
This experiment describes how to develop VHDL-based systems. The student is taken through the design
flow: the initial system specification, writing and simulating VHDL code, synthesizing the VHDL code
into a digital circuit implementation, downloading the circuit configuration into a programmable device
and then verifying the functionality of the circuit using the development board. The student is first asked
to follow a tutorial that takes them through the design flow with a simple combinational circuit, the 3 input NAND function. The VHDL hardware description language and Xilinx ISE VHDL development
environment is used to enter, compile, and simulate the design. After the student simulates the design
using the Xilinx ISE development environment, the VHDL code is synthesized (using CAD tools) into
a digital circuit appropriate for implementation with programmable logic. After synthesizing the design
into a hardware representation it is downloaded into the CoolRunner CPLD (Complex Programmable
Logic Device) on the development board for verification. Take your time following the tutorial and make
sure you understand the design process. After the student has become comfortable with the design flow
and the tutorial, they are asked to design, implement and verify a more difficult digital circuit.
a, b, c, d : in std_logic;
y, z : out std_logic);
end <your entity name>;
begin
sig2 <= 1 ;
sig3 <= 0;
Vcc
Switch Position
Up
4.7 kO
SWn ? CPLD Pin
Down
n = (1, 2, 3, 4, 5, 6, 7 or 8)
7-Segment Display
The 7-Segment display is used to illuminate the decimal digits from 0 -9. Each of the LED bars in the
display forms one of the segments. The segments are labeled a -g as shown below in figure 2. Applying a
positive voltage across one of the diode segments will cause the LED to light. The development board 7 Segment display circuit is shown in Figure 2. The signals AA-AG and CAT2 are wired to I/O pins on the
CPLD. Your BCD to 7 -Segment decoder should drive these signals to light the proper LED segments
and display the decimal digits 0 -9 when the appropriate BCD value is input into the decoder circuit. The
CAT2 signal drives an active pulldown transistor. The transistor operates as a voltage controlled switch. If
CAT2 has a high voltage then the switch between the LED Cathode and ground is closed. If CAT2 has a
low voltage this switch is open. So in order to light the LEDs in the 7 -Segment display, CAT2=1. There
is another similar transistor for the upper digit that is controlled by the signal CAT1. Since the same
CPLD I/O Pins AA-AG are used for both digits, CAT1 should be low to prevent the upper digit from
lighting, or CAT1=0.
a
f
d
Figure 2: Seven Segment Display and Circuit
AA
AB
820O
AC
820O
CAT2
Off = 0
On = 1
AD
820O
AE
820O
AF
820O
AG
820O
820O
0
0
0
0
0
0
0
1
1
1
1
1
1
0
0
0
0
0 1
1
1
1
1 0
0
0
0
1 1
1
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
AA AB AC AD AE AF AG
1 1 1 1 1 1 0
0 1 1 0 0 0 0
Procedure
P1 Getting Started with VHDL for CPLDs tutorial
Perform the Getting Started with VHDL for CPLDs tutorial. You can find the tutorial on the website
listed under the Tutorials link.
P2 BCD to-7 Segment Decoder Design Project
1)
Design the least cost BCD-to-7 Segment Decoder. The cost function for the project is to first minimize the
number of gates needed and second to minimize the total number of gate inputs needed to implement the
function. Document the design procedure in your lab report including all of your design work . The design
work should include completing the partially specified truth table found above. Then you will have to find
a minimum cost Boolean expression for each of the functions AA-AG that drive segments on the 7Segment display. Include the minimum cost Boolean expressions in your lab report. Note any software you
may have used for the design such as (Reduce1, MEV Tutorial ...). Include your own comments on the
design process and discuss how designing the BCD-to-7 Segment Decoder using SSI gates would differ.
2) Enter your design using VHDL and the Xilinx ISE Design Environment. Copy your VHDL
source code to the clipboard and paste it into your lab report. Include your own comments on the
design entry process and discuss how wiring the decoder using SSI gates would differ.
3) Simulate your project. Document how you simulated your design, including any software you
used to help you build it (i.e. Xilinx ISE, ModelSim ...). Also include in your report the
simulation waveforms that you used to validate your design. You can copy the simulation
waveforms to the clipboard by pushing the Alternate-Print_Screen keys simultaneously while
the simulation waveform window is selected and pasting the results into your lab report. Include
your own comments on the simulation process. How does simulation compare to debugging
circuits built with SSI gates.
4) Build the BCD-to-7-Segment Decoder System using the Digilent XCR Development Board.
Include a system schematic with any switches, 7-Segment Displays, Resistors, Transistors, and the
CPLD pins used on the development board. On the schematic, you only need to indicate pin
numbers for the CPLD but not the pin numbers for the other components. Submit a copy of your
VHDL source code. Your VHDL source code should have sufficient comments so that a peer can
understand your design. Include in the report, your own comments on the construction of the
circuit.
5) Test your circuit. To verify your circuit create a truth table that lists all combinations of the BCD
input parameter (a3, a2, a1, and a0) and the corresponding display output . Your report should
include your test results.
Conclusions
Discuss what you have learned from this experiment.