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

MKT2802 Logic Circuits

Dr. Kadir ERKAN


Mechatronics Engineering Department

Spring : 2021

3/21/2021 Logic Circuits 1


Digital Codes
Coding is the process of altering the characteristics of information to make it
more suitable for intended application

Coding schemes depend on When numbers, letters, or


 Security requirements words are represented by a
 Complexity of the medium of transmission special group of symbols, we
 Levels of error tolerated say that they are being
 Need for standardization encoded, and the group of
symbols is called a code.
Information is coded to facilitate
 Efficient transmission
 Error detection
 Error correction
Decoding is the process of reconstructing source information from the received
encoded information
Decoding can be more complex than coding if there is no prior knowledge of
coding schemes

3/21/2021 Logic Circuits 2


Bit Combinations

3/21/2021 Logic Circuits 3


Binary Codes

3/21/2021 Logic Circuits 4


Binary Codes
Example: Coding of alphanumeric information

3/21/2021 Logic Circuits 5


Binary Codes
Some codes for consideration

3/21/2021 Logic Circuits 6


Binary Codes : Binary coded decimal codes (BCD)

If each digit of a decimal number is represented by its binary equivalent,


the result is a code called binary-coded decimal (hereafter abbreviated
BCD).

3/21/2021 Logic Circuits 7


Binary Codes : Binary coded decimal codes (BCD)

Since a decimal digit


can be as large as 9,
four bits are required
to code each digit
(the binary code for 9
is 1001).

3/21/2021 Logic Circuits 8


Binary Codes : Binary coded decimal codes (BCD)
EXAMPLE – Give the BCD representation for the decimal numbers 90 and 873.

3/21/2021 Logic Circuits 9


Comparison of BCD and binary

 It is important to realize that BCD is not another number system like


binary, decimal, and hexadecimal.
 In fact, it is the decimal system with each digit encoded in its binary
equivalent. It is also important to understand that a BCD number is not the
same as a straight binary number.
 A straight binary number takes the complete decimal number and
represents it in binary; the BCD code converts each decimal digit to binary
individually. To illustrate, take the number 137 and compare its straight
binary and BCD codes:

3/21/2021 Logic Circuits 10


The Gray Code

 Digital systems operate at very fast speeds and respond to changes that
occur in the digital inputs. Just as in life, when multiple input conditions are
changing at the same time, the situation can be misinterpreted and cause
an erroneous reaction.
 In order to reduce the likelihood of a digital circuit misinterpreting a
changing input, the Gray code has been developed as a way to represent
a sequence of numbers.
 The unique aspect of the Gray code is that only one bit ever changes
between two successive numbers in the sequence.

3/21/2021 Logic Circuits 11


The Gray Code

3/21/2021 Logic Circuits 12


The Gray Code Conversion

SAME  0
DIFFERENT 1

3/21/2021 Logic Circuits 13


The Gray Code Conversion

SAME  0
DIFFERENT 1

3/21/2021 Logic Circuits 14


Excess-3 (+3) Coding

In excess-3 coding, digit codes is obtained from their binary equivalent after adding 3.
Thus the code of a decimal 0 is 0011, that of 6 is 1001, etc

Decimal BCD Excess-3

0 0000 0011

1 0001 0100

2 0010 0101

3 0011 0110

4 0100 0111

5 0101 1000

6 0110 1001

7 0111 1010

8 1000 1011

9 1001 1100

3/21/2021 Logic Circuits 15


Parity Method for Error Detection
 Whenever information is transmitted from one device (the transmitter) to another
device (the receiver), there is a possibility that errors can occur such that the
receiver does not receive the identical information that was sent by the transmitter.
 The major cause of any transmission errors is electrical noise, which consists of
spurious fluctuations in voltage or current that are present in all electronic systems
to varying degrees.

A parity bit tells if the number of 1s is odd or even.

3/21/2021 Logic Circuits 16


Parity Method for Error Detection
 A parity bit provides for the detection of a single bit error (or any odd number of
errors, which is very unlikely) but cannot check for two errors in one group
let’s assume that we wish to transmit the Now let’s assume that an error occurs
BCD code 0101 in the third bit from the left (the 1
becomes a 0).

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.

3/21/2021 Logic Circuits 17


Parity Method for Error Detection

3/21/2021 Logic Circuits 18


Parity Method for Error Detection

There are some other codes to check whether the transmitted is off error-free;

cyclic redundancy check (CRC)

Hamming code

…

3/21/2021 Logic Circuits 19


Alphanumeric Codes
In addition to numerical data, a computer must be able to handle nonnumerical
information. In other words, a computer should recognize codes that represent letters of
the alphabet, punctuation marks, and other special characters as well as numbers.
These codes are called alphanumeric codes.
The most widely used alphanumeric code is the American Standard Code for
information interchange (ASCII). The ASCII (pronounced “askee”) code is a seven-bit
code, and so it has 27 = 128 possible code groups. (0↔127)

3/21/2021 Logic Circuits 20


Arithmetic Operations on Binary Numbers

3/21/2021 Logic Circuits 21


Arithmetic Operations on Binary Numbers

3/21/2021 Logic Circuits 22


Arithmetic Operations on Binary Numbers

3/21/2021 Logic Circuits 23


Complement Representation

3/21/2021 Logic Circuits 24


Complement Representation

3/21/2021 Logic Circuits 25


Complement Representation

3/21/2021 Logic Circuits 26


Complement Arithmetic

3/21/2021 Logic Circuits 27


Complement Arithmetic

3/21/2021 Logic Circuits 28


Complement Arithmetic

3/21/2021 Logic Circuits 29


Complement Arithmetic

3/21/2021 Logic Circuits 30


1’s-Complement Form
The 1’s complement of a binary number is obtained by changing each 0 to a
1 and each 1 to a 0. In other words, change each bit in the number to its
complement. The process is shown below.

3/21/2021 Logic Circuits 31


2’s-Complement Form
The 2’s complement of a binary number is formed by taking the 1’s
complement of the number and adding 1 to the least-significant-bit position.
The process is illustrated below for (101101)2 = (45)10.

Here’s another example of converting a binary number to its 2’s- complement


representation:

3/21/2021 Logic Circuits 32


Key terms

3/21/2021 Logic Circuits 33

You might also like