BCD To 7 Segment
BCD To 7 Segment
BCD To 7 Segment
Title: Time: Author: Updated: BCD-to-7 Segment Decoder Design using VHDL (CPLD) 180 minutes December5, 2002 by A. Liddicoat April 30, 2003 by A. Liddicoat November 15, 2003 by A. Liddicoat Pentium 4 Computer and Digilab XCR Plus Development Board Xilinx ISE and ModelSim Xilinx CoolRunner XPLA3 CPLD (on development board)
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 3input 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.
library ieee;
-- The library statement allows access to a pre-made -- library (in this case the ieee library). -- The use statement allows you to use a package within -- a library for your design. In this case, we are using all -- of the std_logic_1164 package within the ieee library. -- All VHDL files need to have an entity declaration. The -- entity declaration is the black box view of your circuit -- that declares the inputs and outputs of the circuit. -- Inputs a,b,c, and d are declared as type std_logic. -- Std_logic is contained in the ieee library we included above -- and allows a signal to take on typical logic values such -- as '0' or '1'. -- Outputs y and z are declared as type std_logic. -- This ends the entity declaration.
use ieee.std_logic_1164.all;
a, b, c, d : in std_logic;
architecture <your architecture name> of <your entity name> is -- This begins the architecture section of your code, here -- you will specify the actual functionality of your circuit. signal sig1, sig2, sig3 : std_logic; -- The signal declaration is similar to the input and output -- declarations, except these signals are only visible to this -- architecture (like local variables). Signals can be thought -- of as names for internal nodes in your circuit, or as -- internal variables in a program. -- Begin starts the architecture description. -- This is a sample concurrent signal assignment equation -- in VHDL, notice that <= is the assignment operator. -- The value of a ANDed with b is assigned to sig1. -- Assigning constants to signals
-- Note that at some point you should have your final -- values assigned to your outputs.
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 7Segment 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 e d
Figure 2: Seven Segment Display and Circuit
b c
AA 820O
AB 820O
AC 820O
AD 820O
AE 820O
AF 820O
AG 820O
CAT2
Off = 0 On = 1
Figure 3: Seven Segment Display Circuit on the Development Board (AA-AG and CAT2 are driven by CPLD output pins)
AA AB AC AD AE AF AG
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1
0 0 0 0 1 1 1 1 0 0 0 0 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
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 7-Segment 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 (a 3, 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. Remember that each student must write an individual summary and conclusion.