[go: up one dir, main page]

0% found this document useful (0 votes)
60 views42 pages

Digital System Codes

System Codes

Uploaded by

Wence Lataquin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views42 pages

Digital System Codes

System Codes

Uploaded by

Wence Lataquin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

ELX 212

DIGITAL TECHNIQUES 1
WEEK 6-8

cga23241stterm ELX 212B - Electronic Instruments 1


Week 6-8 Topic Outline
Week Topics
No.

6 Digital System Codes: Weighted and Non-weighted Codes,


Reflective Codes, Gray Codes, and BCD Codes

7 Digital Logic Families: DL, RTL, DTL, TTL, ECL, MOS, CMOS
8 Logic Gates: OR, AND, INVERTER, EX-OR, NAND, NOR, EX-
NOR, BUFFER

9 Mid-Term Examination
cga23241stterm ELX 212B - Electronic Instruments 2
Digital System Codes
Weighted and Non-weighted Codes
Reflective Codes
Gray Codes
BCD Code

cga23241stterm ELX 212B - Electronic Instruments 3


Expected Competencies
At the end of the lesson, the student should be able to:

1. classify the different binary codes;


2. convert decimal and binary number to their Binary
Coded Decimal (BCD), and/or Excess-3 and/or Gray
Code equivalents

cga23241stterm ELX 212B - Electronic Instruments 4


Key Terms

Alphanumeric. Consisting of numerals, letters, and


other characters
ASCII. American Standard Code for Information
Interchange; the most widely used alphanumeric
code
BCD. Binary Coded Decimal, a digital code in which
each of the decimal digits, 0 through 9, is
represented by a group of four bits.
cga23241stterm ELX 212B - Electronic Instruments 5
Key Terms

Byte . A group of eight bits


Floating-point number. A number representation
based on scientific notation in which the number
consists of exponent and a mantissa.
Hamming Code. A type of error correction code
Hexadecimal. Describes a number system with a
base of 16

cga23241stterm ELX 212B - Electronic Instruments 6


Key Terms

LSB . Least Significant Bit. The right-most bit in a


binary whole number or code
MSB. Most Significant Bit. The left-most bit in a
binary whole number or code.
Octal. Describes the number system with a base of
eight.
Parity. In relation to binary codes, the condition of
evenness or oddness of the number of 1s in a
code group.
cga23241stterm ELX 212B - Electronic Instruments 7
BINARY CODES, (Anil, 2007)

➢Special codes developed to represent larger decimal


numbers.
➢Can also perform many other special functions.

cga23241stterm ELX 212B - Electronic Instruments 8


Classification of Binary Codes
1. Weighted Code – each position of the binary digit has a
specific value. Ex. BCD Code.
2. Reflection Code – a code is said to be reflective if 0 is
the complement of 9; 1 is the complement of 8; 2 is
the complement of 7; 3 is the complement of 6; 4 is
the complement of 5. Ex. 2421 Code, 5211 Code,
Excess 3 Code.
3. Non-Weighted Code – each position of the binary digit
does not have any specific value. Ex. Gray Code.
cga23241stterm ELX 212B - Electronic Instruments 9
Classification of Binary Codes
4. Sequential Codes - A code is said to be sequential when
two subsequent codes, seen as numbers in binary
representation, differ by one. This greatly aids
mathematical manipulation of data. The 8421 and
Excess-3 codes are sequential, whereas the 2421 and
5211 codes are not.
5. Binary-Coded Decimal (BCD). Ex. 8421 code, 2421 code,
5211 Code, Excess 3 Code.
cga23241stterm ELX 212B - Electronic Instruments 10
Classification of Binary Codes
6. Gray Code - The gray code belongs to a class of codes called
minimum change codes, in which only one bit in the
code changes when moving from one code to the next.
The Gray code is non-weighted code, as the position of
bit does not contain any weight. The gray code is a
reflective digital code which has the special property that
any two subsequent numbers codes differ by only one
bit. This is also called a unit- distance code. In digital
Gray code has got a special place.
cga23241stterm ELX 212B - Electronic Instruments 11
Classification of Binary Codes
7. Excess-3 Code - Excess-3 is a non-weighted code used to
express decimal numbers. The code derives its name
from the fact that each binary code is the
corresponding 8421 code plus 0011 or (3).
8. Alpha-Numeric Codes. Ex. ASCII, EBCDIC.
9. Seven-Segment Display Code
10. Error Detection and Correction Codes. Ex. Parity Code,
Hamming Code.
cga23241stterm ELX 212B - Electronic Instruments 12
Binary Coded Decimal (BCD)
❖The Binary Coded Decimal (BCD) is a way to express each of
the decimal digits with a binary code.
❖BCD code provides an excellent interface to binary systems.
❖The BCD equivalent of a decimal number is written by
replacing each decimal digit in the integer and fractional
parts with its four-bit binary equivalent.
❖Example, the BCD equivalent of (84.25)10 is written as (1000
0100.0010 0101)BCD.
cga23241stterm ELX 212B - Electronic Instruments 13
Binary Coded Decimal (BCD)
❖The Binary Coded Decimal (BCD) is a way to express each of
the decimal digits with a binary code.
❖BCD code provides an excellent interface to binary systems.
❖The BCD equivalent of a decimal number is written by
replacing each decimal digit in the integer and fractional
parts with its four-bit binary equivalent.
DECIMAL 0 1 2 3 4 5 6 7 8 9
DIGIT
BCD 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001
cga23241stterm ELX 212B - Electronic Instruments 14
Binary Coded Decimal (BCD)
❖EXAMPLE: (84.25)10 = (1000 0100.0010 0101)BCD.
❖The BCD code described is more precisely known as
the 8421 BCD code, with 8, 4, 2, and 1 representing the
weights of different bits in the four-bit groups, starting
from MSB and proceeding towards LSB. This feature
makes it a weighted code, in the four-bit group
representing a given decimal digit has an assigned
weight.
cga23241stterm ELX 212B - Electronic Instruments 15
BCD – Invalid Codes (8421)
❖0000 through 1111 = 16 numbers
❖8421 code – only 10 numbers are used (0000 – 1001
❖Invalid Codes (1010, 1011, 1100, 1101, 1110, 1111

cga23241stterm ELX 212B - Electronic Instruments 16


BCD-to-Binary Conversion
A given BCD number can be converted into an equivalent binary
number by first writing its decimal equivalent and then
converting it into its binary equivalent.
Example: Find the binary equivalent of the BCD8421 number
0010 1001.0111 0101:
BCD8421 number: 0010 1001.0111 0101.
Corresponding decimal number: 29.75.
The binary equivalent of 29.75 can be determined to be 11101 for
the integer part and .11 for the fractional part.
Therefore, (0010 1001.0111 0101)BCD8421 = (11101.11)2.
cga23241stterm ELX 212B - Electronic Instruments 17
Binary-to-BCD Conversion
❖The process of binary-to-BCD(8421) conversion is the same as
the process of BCD-to-binary conversion executed in reverse
order.
❖A given binary number can be converted into an equivalent
BCD number by first determining its decimal equivalent and
then writing the corresponding BCD equivalent.
❖Example, find the BCD equivalent of the binary number
10101010.001:
(170.125)10 = (0001 0111 0000.0001 0010 0101)BCD8421
cga23241stterm ELX 212B - Electronic Instruments 18
Binary-to-BCD, BDC to Binary Conversions
❖Convert each of the following decimal numbers to BCD:
a) 35 b) 98 c) 170 d) 2469 e)9673

❖Convert each of the following BCD codes to decimal:


a) 10000110 b) 001101010001
c) 100101000111000 d) 10000010001001110110

cga23241stterm ELX 212B - Electronic Instruments 19


BCD Addition
❖BCD is a numerical code and can be used in arithmetic
operations.
❖Addition is the most important operation because the other
operations can be accomplished by the use of addition.
❖Steps:
1. Add the two BCD numbers, using the rules for binary addition.
2. If a 4-bit sum is equal to or less than 9, it is a valid BCD number.
3. If a 4-bit sum is greater than 9, or if a carry out of 4-bit group is
generated, it is an invalid result. Add 6 (0110) to the 4-bit
sum in order to skip the six invalid states and return to the
code to 8421. If a carry results when 6 is added, simply add
the carry to the next 4-bit group.
cga23241stterm ELX 212B - Electronic Instruments 20
BCD Addition Examples
❖Add the following BCD numbers
a) 0011 + 0100
b) 10000110 + 00010011
c) 010001010000 + 010000010111
d) 1001 + 0100
e) 00010110 + 00010101

cga23241stterm ELX 212B - Electronic Instruments 21


DIGITAL CODES
Alphanumeric codes

cga23241stterm ELX 212B - Electronic Instruments 22


The Gray Code
• The Gray Code is unweighted and is not an arithmetic code;
that is, there is no specific weight assignment to the bit
position.
• The important feature of the Gray Code is that it exhibits only
a single bit change from one code word to the next in
sequence.
• This property is important in many applications, such as shaft
position encoders, where error susceptibility increases with
the number of bit changes between adjacent numbers in
sequence.
cga23241stterm ELX 212B - Electronic Instruments 23
The Gray Code
• Table Listing of
the 4-bit Gray
code for
decimal
numbers 0
through 15.

cga23241stterm ELX 212B - Electronic Instruments 24


Binary to Gray Code Conversion
• Conversion between binary code and Gray code is
sometimes useful.
1. The MSB in Gray code is the same as the MSB in the
binary number.
2. Going from left to right, add each adjacent pair of
Binary code bits to get the next Gray code bit.
Discard carries.

cga23241stterm ELX 212B - Electronic Instruments 25


Binary to Gray Code Conversion
• Example: Convert binary number 10110 to Gray code.

• The Gray Code is 11101.


cga23241stterm ELX 212B - Electronic Instruments 26
Gray Code to Binary Conversion
• To convert from Gray code to binary, use a similar method;
however, there are some differences. The following rules
apply.
1. The MSB in the Gray code is the same as the corresponding
Binary code.
2. Add each binary code bit generated to the gray code bit in the
next adjacent position. Discard carries.

cga23241stterm ELX 212B - Electronic Instruments 27


Gray Code to Binary Conversion
• Example: Convert Gray code word 11011 to binary code.

• The binary number is 10010.


cga23241stterm ELX 212B - Electronic Instruments 28
The Gray Code Advantage
• The Gray Code is used to eliminate the error problem
which is inherent in the binary code.
• The Gray Code assures that only one bit will change for
every event.

cga23241stterm ELX 212B - Electronic Instruments 29


Alphanumeric Codes
• Alphanumeric codes, also called character codes, are binary
codes used to represent alphanumeric data.
• The codes write alphanumeric data, including letters of the
alphabet, numbers, mathematical symbols, and punctuation
marks, in a form that is understandable and processable by a
computer.
• Two widely used alphanumeric codes include the ASCII and the
EBCDIC codes.
• While the former is popular with microcomputers and is used on
nearly all personal computers and workstations, the latter is
mainly used with larger systems (Anil, 2007).
cga23241stterm ELX 212B - Electronic Instruments 30
ASCII Code
• The ASCII (American Standard Code for Information
Interchange), pronounced ‘ask-ee’, is strictly a seven-bit
code based on the English alphabet.
• ASCII codes are used to represent alphanumeric data in
computers, communications equipment and other
related devices.
• ASCII has 128 characters and symbols represented by a
7-bit binary code, but can actually be presented as an 8-
bit code with the MSB always 0.
cga23241stterm ELX 212B - Electronic Instruments 31
cga23241stterm ELX 212B - Electronic Instruments 32
EBCDIC Code
• The EBCDIC (Extended Binary Coded Decimal
Interchange Code), pronounced ‘eb-si-dik’, is another
widely used alphanumeric code, mainly popular with
larger systems. The code was created by IBM to extend
the binary coded decimal that existed at that time. All
IBM mainframe computer peripherals and operating
systems use EBCDIC code, and their operating systems
provide ASCII and Unicode modes to allow translation
between different encodings (Anil, 2007).
cga23241stterm ELX 212B - Electronic Instruments 33
Seven-segment Display Code
• Seven-segment displays are very common and are
found almost everywhere, from pocket calculators,
digital clocks and electronic test equipment to petrol
pumps. A single seven-segment display or a stack of
such displays invariably meets our display
requirement. There are both LED and LCD types of
seven-segment display.

cga23241stterm ELX 212B - Electronic Instruments 34


Seven-
segment
Display
Code

cga23241stterm ELX 212B - Electronic Instruments 35


Error Detection and
Correction Codes
Parity and Hamming Codes

cga23241stterm ELX 212B - Electronic Instruments 36


Error Detection and Correction Codes
• When we talk about digital systems, be it a digital
computer or a digital communication set-up, the issue of
error detection and correction is of great practical
significance. Errors creep into the bit stream owing to noise
or other impairments during the course of its transmission
from the transmitter to the receiver.
• Two methods for adding bits to codes to either detect a
single-bit error or detect and correct a single-bit error are
represented as the Parity and Hamming Methods
respectively.
cga23241stterm ELX 212B - Electronic Instruments 37
Parity Code
• A parity bit is an extra bit added to a string of data bits
in order to detect any error that might have crept into it
while it was being stored or processed and moved from
one place to another in a digital system.
• In parity codes, every data byte, or nibble (according to
how user wants to use it) is checked if they have even
number of ones or even number of zeros. Based on this
information an additional bit is appended to the
original data. Thus, if we consider 8-bit data, adding the
parity bit will make it 9 bit long.
cga23241stterm ELX 212B - Electronic Instruments 38
Parity Code
• At the receiver side, once again parity is calculated and
matched with the received parity (bit 9), and if they
match, data is ok, otherwise data is corrupt.
• There are two types of parity:
• Even parity: Checks if there is an even number of ones; if so,
parity bit is zero. When the number of ones is odd then
parity bit is set to 1.
• Odd Parity: Checks if there is an odd number of ones; if so,
parity bit is zero. When number of ones is even then parity
bit is set to 1.
cga23241stterm ELX 212B - Electronic Instruments 39
Parity Method for Error Detection
• Many systems use a parity bit as a means for bit error detection.
Any group of bits contains either an even or an odd number of 1s.
• A parity bit is attached to a group of bits to make the total number
of 1s in a group always even or always odd.
• An even parity bit makes the total number of 1s even, and the odd
parity bit makes the total odd.
• A given system operates with even or odd parity, but not both.
• The parity bit can be attached to the code at either the beginning
or the end, depending on the system design.
cga23241stterm ELX 212B - Electronic Instruments 40
Parity Code: Detecting an Error
• Let’s assume that we wish ti transmit the BCD
Code 0101. (Parity can be used with any number
of bits.)
• The total code transmitted, including the even
parity bit, is

• Then, let’s assume that an error occurs in the third


bit from the left

• When this code is received, the parity check


circuitry determines that there is only a single 1
(odd number) when there should be an even
number of 1s. Because an even number of 1s does
not appear in the code when it is received, an
error is indicated.
cga23241stterm ELX 212B - Electronic Instruments 41
The Hamming Error Correction Code

• Hamming code adds a minimum number of bits to the


data transmitted in a noisy channel, to be able to
correct every possible one-bit error. It can detect (not
correct) two-bits errors and cannot distinguish
between 1-bit and 2-bits inconsistencies. It can't - in
general - detect 3(or more)-bits errors.
• The Hamming code provides for single-error detection
and correction only.

cga23241stterm ELX 212B - Electronic Instruments 42

You might also like