Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Lab7 DLD Final

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Namal University Mianwali

Department of Electrical Engineering


Digital Logic Design

EE-272L

Lab # 7 Manual

BCD, Gray Codes, 9’s Complement and 7-segment Display


Name

Roll No

Marks Obtained

Date Performed

Instructor: Ms. Naureen Shaukat

Lab Engineer: Engr. Maria Rehman


Fall 2023 DLD Lab 07 Version 2.0

Version 1.0-Prepared by Dr. Syed Asad Alam


Version 2.0-Dr. Majid Ali
1. Objectives
The main objective of this lab is to gain an understanding of binary coded decimal (BCD) codes and gray
codes. Students will also design a circuit to covert gray codes to binary. They will also use 7-segment
displays and will implement logical circuits using Proteus software.

2. Learning Outcomes
This lab satisfies the following learning outcomes of the course:

CLO1: Build Digital Circuits, complex and real-world examples.

CLO3: Present concise yet comprehensive technical reports.

3. Equipment & Components


• Computer System
4. Instructions
• There will be no concept of make-up labs. If missed, the lab may be performed later for practice and
knowledge required for the coming labs on your own and will be graded for partial marks unless there
is any valid reason.
• Plagiarism cases would be sent to the student disciplinary committee (SDC) without any prior
warnings.

Page | 1
Fall 2023 DLD Lab 07 Version 2.0
5. Introduction
BCD and Grey codes are the binary codes of decimal numbers where each digit is represented by fixed
number of bits. In this lab students will perform 3 lab experiments. In the first task students will use SSD
(7-segment) decoder to display the decimal digits which were represented by fixed number of bits. This
schematic will be displayed on Proteus.
In the second task students will design a circuit to convert 4 bit grey code to binary number and will display
the BCD and Grey code on two SSDs. This circuit will be implemented on hardware.

Third task is based on error checking. In this task students will design a system that will check for any error
in the BCD. 9‘s complement will be used for error detection and logic 1 and logic 0 will highlight the errors
if any.

5.1. Binary Coded Decimal Numbers


Decimal number system is the most common number system used by humans. However, the computer only
understands the binary number system. Thus to represent the decimal numbers, one needs to convert them
into binary codes. A n-bit binary code can represent up to 2n different combinations. So a four bit binary
code can represent 16 combinations, which can be determined from the count from 0 to 15 (0 to 2n − 1). It
is not necessary that all 2n combinations represent some element when the number of elements is not a
power of two. The ten decimal digits form such a set. To represent the ten decimal digits, we need four
binary bits and one such code is called the binary coded decimal (BCD), as shown in Table 1 [1].

So the representation of, for e.g., 65 in BCD will be 01100101.

5.2. Grey Codes


Gray codes are another way of representing numbers, invented by Frank Gray. They have an advantage that
successive values differ in only one bit position. These codes are also termed as reflected binary code
(RBC). Gray codes are beneficial in circuits that are sensitive to glitches because the larger the difference
between successive binary codes, the larger the glitch when switching between them. Gray codes can also
have a positive effect on power consumption as it is also dependent on the switching of bits. The relationship
between decimal, binary and gray codes is given in Table 2.

Page | 2
Fall 2023 DLD Lab 07 Version 2.0

5.3. 7-segment display


A 7-segment LED display contains 7 LEDs. An LED is a light emitting diode which emits light when it is
forward biased. Within a 7-segment LED display, each segment is identified through letters (a, b, c, d, e, f,
g), as shown in Fig. 1. Various combinations of the seven segments are turned ON to display a certain digit.
The display has seven inputs, each connected to an LED segment. To represent BCD codes using this
display, they need to be converted to a representation suitable for use with this display. Typically such a
circuit is called a BCD to 7-segment decoder.

7-segment displays come in two different types, as shown in Fig. 3 [5]:

• The common cathode display (CCD): In the common cathode display, all the cathode connections
of the LEDs are joined together to logic “0” or ground. The individual segments are illuminated by
application of a “HIGH”, logic “1” signal to the individual Anode terminals.

• The common anode display (CAD): In the common anode display, all the anode connections of the
LEDs are joined together to logic “1” and the individual segments are illuminated by connecting the
individual Cathode terminals to a “LOW”, logic “0” signal.
So in order to display the number 3 for example, segments a, b, c, d and g needs to be illuminated. A truth
table showing which segments needs to be illuminated is given in Table 3 where “x” denotes which of the
segment is to be highlighted. Whether they are highlighted by applying logic “1” or “0” depends on their
type.

Page | 3
Fall 2023 DLD Lab 07 Version 2.0

5.4. 9’s and 10’s complement


The 1’s and 2’s complement number system introduced in the lectures are part of the larger family called
methods of complement. It is a technique which is used to subtract one number from another number using
only addition of positive numbers. Part of this family is the 9’s complement, the relation of which to a
decimal digit is given in Table 4. To obtain the 9’s complement of any number, just subtract the number
from 9. So, for e.g., the 9’s complement of 459 will be 540. The 10’s complement can be simply achieved
by adding a 1 to the 9’s complement number. Thus the 10’s complement of 459 will be 540 + 1 = 541.

Page | 4
Fall 2023 DLD Lab 07 Version 2.0
6. Procedure

6.1. Task 1: BCD to Gray Code Converter

1. Based on Table 2, design a combinational circuit with 4 inputs and 4 outputs that converts a four-bit gray
code number into an equivalent four-bit binary number. Use Karnaugh map technique for simplification.

Page | 5
Fall 2023 DLD Lab 07 Version 2.0
2. Implement it on trainer board. Show all the working and use two 7-segment displays on the trainer board
to display both the binary and gray code number.

3. Why does the 7-segment display displays alphabets instead of numbers beyond 9?
Note: The two 7-segment displays on the trainer board only requires 4-inputs. It has a built in decoder.
The output of gray code can be directly applied to the inputs of the 7-segment display on the trainer
board.

Page | 6
Fall 2023 DLD Lab 07 Version 2.0
6.2 Task 2 Using the above combinational circuit from part 1, Write the Verilog code and verify it.

6.3. Task 3: BCD to 9’s Complement using Verilog HDL

1. Implement a system which takes in a four-bit input signal in BCD format and outputs its 9’s complement
using Verilog. Provide a fifth output that detects an error in the input BCD number. This output should be
equal to logic 1 when the four inputs have one of the unused combinations of the BCD code. In such a case,
the four bit 9’s complement number shall be pulled high (in the Z state). For e.g., if the input to such a
system is 0010, then the output shall be 0111 with the error signal equal to logic “0”. However, if the input
is 1100, then the output shall be ZZZZ and the error signal will be equal to logic “1”.

Page | 7
Lab Rubrics

Marking Rubric

Performance Excellent 20-17 Good 16-13 Average 12-8 Poor-0 Marks


Successfully performed but
Successfully completed in Not completed about
not with a clear Had difficulty in
time with complete completing the tasks, can half of the tasks, does
Performance understanding, can use lab
understanding, was good in use some lab equipment not know how to use
equipment with minor lab equipment.
using lab equipment. with errors.
errors.
Students answered questions
Students gave outstanding and comprehensively. Not able to answer to
Exhibited confidence in Students provide basic asked questions, and
detailed answers.
answers. Strong answers to questions. was not confident.
Showed exceptional
Lab Viva understanding of the Somewhere confident, Significant gaps
confidence in responses. No
subject matter. Minimal limited gaps in in knowledge
significant gaps in knowledge and
gap in knowledge and and
knowledge and comprehension.
comprehension. comprehension.
comprehension.
Not very clear
Clean and clear without any Clean and clear but slight Not very clear and and clean, and
match with fellow students overlap with other students most of the
Report clean and partial content
overlap with fellow students overlapping with
fellow students
• Method of Evaluation: Reports submitted by students
• Measured Learning Outcomes:
CLO1: Build Digital Circuits, complex and real-world examples.
CLO3: Present concise yet comprehensive technical reports.

You might also like