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

Digital Logic Design (ES216) Lec 4-6

Uploaded by

rodili8762
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)
15 views42 pages

Digital Logic Design (ES216) Lec 4-6

Uploaded by

rodili8762
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

Digital Logic Design (ES216)

Department of Mechatronic
Engineering

Lec # 4-6

Engr. Muhammad Arsalan Jalees


Abro

[email protected]
Lecture contents
• Decimal numbering system (Base 10) • Hexadecimal number systems

• Binary numbering system (Base 2) • Binary to Hexadecimal conversion

• Binary to decimal conversion • Hexadecimal to Binary conversion

• Decimal to binary conversion • Decimal to Hexadecimal conversion

• How to write binary sequence? • Hexadecimal to Decimal conversion

• Octal numbering system (Base 8) • How to write Hexadecimal Sequences?

• Binary to octal conversion • Binary-coded decimal system

• Decimal to octal conversion • Comparison of BCD & Binary

• Octal to decimal conversion • Alphanumeric codes

• How to write Octal Sequence? • Parity Method for Error Detection


Number Systems
• A number system is defined as a system of writing
to express numbers. It is the mathematical notation
for representing numbers of a given set by using
digits or other symbols in a consistent manner.
• A positional (numeral) system is a system for the
representation of numbers by an ordered set of
numerals symbols (called digits) in which the value
of a numeral symbol depends on its position.

Positional Notation
Positional Notation
• Value of the number is determined by multiplying each digit by
weight and then summing it:
a3a2 a1a0 .a−1a−2 =
−1 −2
a3  r + a2  r + a1  r + a0  r + a−1  r
3 2 1 0
+ a− 2  r

• The weight of each digit is a POWER of the RADIX (also called


BASE) and is determined by position.
Radix (Base) of a Number System
• Decimal Number System (Radix = 10)
Eg:- 1234 = 1x103+2x102+3x101+4x100

• Binary Number System (Radix = 2)


Eg:- 101 = 1x22 + 0x11 +1x20

• Octal number system (Radix = 8)

• Hexadecimal number system (Radix = 16)


Decimal number system
• The decimal number system contains ten digits from 0 to 9 (base 10).
• Here, the successive place value or position, left to the decimal point holds units,
tens, hundreds, thousands, and so on.
• For example, the decimal number 2541 consist of the digit 1 in the unit position, 4
in the tens position, 5 in the hundreds position, and 2 in the thousand positions and
the value will be written as:
Binary number system
• Generally, a binary number system is used in the digital computers. In this number system, it
carries only two digits, either 0 or 1.
• A four-bit collection (1101) is known as a nibble, and a collection of eight bits (11001010) is
known as a byte.
• The location of a digit in a binary number represents a specific power of the base (2)

Characteristics:
1. It holds only two values, i.e., either 0 or 1.
2. It is also known as the base 2 number system.
3. The position of the right digit represents the 0 power of the base(2). Example: 20
4. The position of the last left digit represents the x power of the base(2).
Binary number system
Example
126 + 125 + 124 + 123 + 022 + 121
+ 120
10110110
= 164 + 132 + 116 + 18 + 04 + 12
+ 11
= 123
127 + 026 + 125 + 124 + 023 + 122 + 121 + 120
Binary to decimal conversion
010101102
27*0 + 26*1 + 25*0 + 24*1+ 23*0+22*1+21*1+20*0
= 86 Answer

1011.10102
23*1+ 22*0+21*1+20*1 . 2-1*1 +2-2*0 +2-3*1 +2-4*0
8 + 0 + 2 + 1 . 1/2 + 0 + 1/8 + 0
=11.625 Answer
11112
23*1 +22*1 +21*1 +20*1
8*1+ 4*1+ 2*1+ 1*1
8+4+2+1=15 Answer
Binary Numbers
• Each binary digit (called bit) is either 1 or 0
• Bits having no inherent meaning, can represent
• Unsigned and signed integers Most Least
• Characters Significant Bit Significant Bit

• Floating-point numbers 7 6 5 4 3 2 1 0

• Images, sound, etc. 1 0 0 1 1 1 0 1


27 26 25 24 23 22 21 20

• Bit Numbering
• Least significant bit (LSB) is rightmost (bit 0)
• Most significant bit (MSB) is leftmost (bit 7 in an 8-bit number)
Binary number chain
Bytes (Collection of Nibbles)

Double Words (Collection of Nibbles/Bytes/Words)

Words (Collection of Nibbles or Bytes)


Decimal to binary conversion (successive division)
Convert the binary numbers back to decimal
numbers from the previous slide.
Binary sequence 2bit seq
22=4
3-bit seq
23=8
4-bit seq
24=16
00 000 0000
01 001 0001
• How to write binary sequences? 10 010 0010
• Formula of counting range 2n=M. 11 011 0011
100 0100
• Where n is the number of bits and 101 0101
110 0110
M is the length of the sequence. 111 0111
1000
• H.W: Write the binary sequence 1001
for 5, 6, and 7 bits with the help of 1010
1011
the formula. 1100
1101
1110
1111
Some common powers of 2

Some common
powers of 2
A thought
Why is any number to the power 0 equal 1?

Answer: The reason that any number to the zero power is one is because any
number to the zero power is just the product of no numbers at all, which is the
multiplicative identity, 1.
Octal number system (Base 8):
• The octal number system has base 8(means it has only eight digits from 0 to 7).
• With the help of only three bits, an octal number is represented.
• Each set of bits has a distinct value between 0 and 7.
• Characteristics:
1.An octal number system carries eight digits starting from 0, 1, 2, 3, 4, 5, 6, and 7.
2.It is also known as the base 8 number system.
3.The position of a digit represents the 0 power of the base(8). Example: 80
4.The position of the last digit represents the x power of the base(8).
Octal number system (Base 8):
Binary to octal conversion:
Group the binary positions in groups of 3

Convert 0111012 to octal:


011 101
3 5

(35)8 Answer

Convert 101110012 to octal:


010 111 001
2 7 1

(271)8 Answer
Octal to Binary conversion
• Open every octal digit in 3 bits

Convert 6248 to binary:

6 2 4
110 010 100

(110010100)2 Answer

Convert 2718 to binary:

2 7 1
010 111 001
(010111001)2 Answer
Octal to Decimal Conversion and vice versa
Convert 6248 to Decimal
= 6x82+2x81+4x80
= 384 + 16 + 4
= 40410

Decimal to Octal Conversion


Writing Octal Sequence
Decimal Octal Binary
0 0 0000
1 1 0001
2 2 0010
3 3 0011
4 4 0100
5 5 0101
6 6 0110
7 7 0111
8 10 1000
9 11 1001
10 12 1010
11 13 1011
12 14 1100
13 15 1101
14 16 1110
15 17 1111
SO ON
Hexadecimal number system
• The number system has a base of 16 means there are a total of 16 symbols (0, 1, 2, 3, 4, 5, 6, 7, 8,
9, A, B, C, D, E, F) used for representing a number.
• The single-bit representation of decimal values 10, 11, 12, 13, 14, and 15 are represented by A, B,
C, D, E, and F.
• Only 4 bits are required for representing a number in a hexadecimal number.
Characteristics:
1. It has ten digits from 0 to 9 and 6 letters from A to F.
2. The letters from A to F defines numbers from 10 to 15.
3. It is also known as the base 16 number system.
4. In hexadecimal number, the position of a digit represents the 0 power of the base(16).
Example: 160
5. In hexadecimal number, the position of the last digit represents the x power of the base(16).
Writing Hexadecimal Sequence
Decimal Hexadecimal Binary
0 0H 00000
1 1H 00001
2 2H 00010
. . .
. . .
.
. .

9 9H 01001
10 AH 01010
11 BH 01011
12 CH 01100
13 DH 01101
14 EH 01110
15 FH 01111
16 10H 10000
17 11H 10001
18 12H 10010
19 13H 10011
20 14H 10100
21 15H 10101
Binary to Hexadecimal conversion & vice versa
Convert 010101012 into (?)16 Convert 1010111112 into (?)16
0101 0101 0001 0101 1111
55H Answer 15FH Answer

Hexadecimal to Binary Conversions


Convert A916 into Binary Convert BA616 into Binary
A 9 B A 6
1010 1001 Answer 1011 1010 0110 Answer
Decimal to
hexadecimal
Conversion
Hexadecimal to Decimal Conversion
2A616 = (?)10
2*162 + 10*161 + 6*160
512+160+6
67810 Answer
1BC216= (?)10
1*163 + 11*162 +12*161 + 2*160
4096+2816+192+2
710610 Answer
Binary Coded Decimal (BCD) system
Code: a system of symbols (such as letters or numbers) used to represent an assigned message.
Example: Morse Code (represents characters, numbers, and alphabets)
What is meant by encoded data?

“Encoding” is the process of converting the data or a given sequence of characters, symbols, alphabets etc., into
a specified format, for the secured transmission of data.

“Decoding” is the reverse process of encoding which is to extract the information from the converted format.
Examples of code systems: BCD, ASCII, etc.
When a decimal number is represented by its equivalent binary number, we call it (straight binary
coding).

Binary-coded decimal is a system of writing numerals that assigns a four-digit binary code to each digit
0 through 9 in a decimal (base 10) number. Simply put, binary-coded decimal is a way to convert decimal numbers
into their binary equivalents.
Binary coded decimal system
• Example: convert 49610 to BCD.
4 9 6
0100 1001 0110 = 010010010110BCD
• Each decimal digit is changed to its straight binary equivalent.
• Note that four bits are always used for each digit.
• BCD codes do not use the numbers 1010,1011,1100,1101,1110, &
1111, so if they are included means it’s an invalid BCD number.
Binary coded decimal system
• Convert 0101 1001 0010BCD to decimal.

0101 1001 0010


5 9 2 = 59210 Answer

Convert 0100 0110 1101BCD to decimal.


0100 0110 1101
4 6 ?

This conversion is impossible because 1101 is not a


valid BCD. It is not in the range of 0 to 9. Answer
Comparison of BCD & Binary
• BCD is NOT another number system like binary, octal, or hex.
• 13710 = 100010012 (Binary)
= 0001 0011 0111BCD (BCD)
• BCD consumes 12 bits whereas, Binary consumes 8 bits.
• The main advantage of BCD code is the relative ease of converting the decimal values.
• It is easier to remember a four-bit code group representing 0 through 9.
• This ease of conversion is especially important from a hardware standpoint because, in a
digital system, it is the logic circuits that perform the conversions to and from decimal
system.
Class Task
Decimal Binary Octal Hexadecimal BCD

0 0 0 0 0000

19 1111

23

51

24

59

01

823

Your roll number


plus 87
Questions
Q: How many bytes and nibbles are in 64-bit string?
A: 64/8 = 8 bytes; 64/4 = 16 nibbles or 8x2 = 16

Q: What is the largest decimal value that can be represented in binary using two
bytes?
A: 2 bytes = 16bits
2n = M => 216 = 65536
But as the range of binary numbers is from 0 to 2n-1
So 2n – 1 = 65535

Q: How many bytes are needed to represent the decimal value 846,569 in BCD?
A: 1000 0100 0110 0101 0110 1001 = 3 bytes
Parity Method for Error Detection
• Whenever information is transmitted from one device (the tx) to another device (the rx), there is a
possibility that errors.
• Errors can include loss of data, incorrect information, etc.
• Most modern digital equipment is designed to be relatively error-free, and the probability of errors
such as the one shown in the figure is very low.

• Digital systems often transmit thousands, even millions of bits/sec so even a very low rate of
occurrence of errors can produce an occasional error that might be bothersome, if not disastrous.
Parity Method for Error Detection
• One of the simplest & most widely used schemes for error detection is the parity check also known
as the Vertical Redundancy Check (VRC)
• A parity bit is an extra bit that is attached to a code group that is being transferred from one
location to another.
• The parity bit is made either 0 or 1, depending on the number of 1s that are contained in the code
group.
• Two different methods are used
1. Even parity
2. Odd parity
• In the Even parity method, the value of the parity bit is chosen so that the total number of 1s in
the code group (including the parity bit) is an even number.
• For eg: suppose that the group is 1000011 (ASCII of C).
Parity Method for Error Detection
• The code group has three 1s. Therefore, we will add a parity bit of 1 to make the total number of 1s
an even number. The new code group including the parity bit, thus becomes
• 1 1000011

Added parity bit

• Parity bit can be placed at either end of the code group, but it is usually placed to the left of MSB.
• If the code group contains an even number of 1s to begin with, the parity bit is given a value of 0.
• For eg: 1000001 (ASCII of A)
• 0 1000001

Added parity bit


Parity Method for Error Detection
• The odd parity method is used in exactly the same way except that the parity bit is
chosen so that the total number of 1s (including the parity bit) is an odd number.
• For eg: 1000001 with odd parity becomes
• 11000001

Added parity bit

• 1000011 with odd parity becomes


• 0 1000011

Added parity bit


Parity Method for Error Detection
• When the receiver circuit receives this code, it will check that the code contains an odd
number of 1s. If so, the receiver will assume that the code has been correctly received.
Now, suppose that because of some noise or malfunction the receiver actually receives
• 11000000
• The Rx will find that this code has an even number of 1s which means there must be an
error in the code because presumably the tx and rx have agreed to use odd parity.
• There is no way, however, that the Rx can tell which bit is in error because it does not
know what the code is supposed to be.
• Note that this parity method would not work if two bits were in error, because two errors
would not change the “oddness” or “evenness” of the number of 1s in the code.
Parity Check (1-bit error)
Parity check (2-bit error)

erroneous
Example
Example: Computers often communicate with other remote computers over telephone lines. For e.g.: this
is how dial-up communication over the internet takes place. When one computer is transmitting a message
to another the information is usually encoded in ASCII. What actual bit strings would a PC transmit to
send the message, HELLO, using ASCII with even parity?

Solution:
H= 0 1001000
E= 1 1000101
L= 1 1001100
L= 1 1001100
O= 1 1001111

You might also like