0% found this document useful (0 votes)
100 views

Cap2 - Digital Systems - Numeric Systems and Codes

Digital Systems - Numeric Systems and Codes

Uploaded by

Miguel
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)
100 views

Cap2 - Digital Systems - Numeric Systems and Codes

Digital Systems - Numeric Systems and Codes

Uploaded by

Miguel
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/ 34

Chapter 2

Numeric Systems and Codes

Adaptado de : João Carlos Martins


Ronald Tocci/Neal Widmer/Gregory Moss Escola Superiror de Tecnologia e Gestão
Digital Systems: Principles and Applications, 10e Instituto Politécnico de Beja
Pearson Education , 2007 2009
Introduction
 Hexadecimal number system.
 Conversion between number systems
 Binary codes used to represent different information.
 Digital transmission basics

Ronald Tocci/Neal Widmer/Gregory


Moss Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Columbus, OH 43235
Applications, 10e All rights reserved.
2-1 Binary to Decimal Conversion
 Convert binary to decimal by summing the
positions that contain a 1.

1 0 0 1 0 12
25 + 2 4 + 23 + 2 2 + 21 + 20 = 32 + 4 + 1 = 3710

Ronald Tocci/Neal Widmer/Gregory


Moss Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Columbus, OH 43235
Applications, 10e All rights reserved.
2-2 Decimal to Binary Conversion
 Two methods to convert decimal to binary:
 Reverse process described in 2-1
 Use repeated division

Ronald Tocci/Neal Widmer/Gregory


Moss Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Columbus, OH 43235
Applications, 10e All rights reserved.
2-2 Decimal to Binary Conversion
 Reverse process described in 2-1
 Note that all positions must be accounted for

3710 = 2 + 0 + 0 + 2 + 0 + 2
5 2 0

1 0 0 1 0 12

Ronald Tocci/Neal Widmer/Gregory


Moss Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Columbus, OH 43235
Applications, 10e All rights reserved.
2-2 Decimal to Binary Conversion
 Repeated division steps:
 Divide the decimal number by 2
 Write the remainder after each division until a
quotient of zero is obtained.
 The first remainder is the LSB and the last is the
MSB
 Note, when done on a calculator, a fractional answer
indicates a remainder of 1.

Ronald Tocci/Neal Widmer/Gregory


Moss Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Columbus, OH 43235
Applications, 10e All rights reserved.
2-2 Decimal to Binary Conversion
 Repeated division –
This flowchart
describes the process
and can be used to
convert from decimal
to any other number
system.
http://www.exploringbinary.com/binary-
converter/

https://www.jdoodle.com/c-online-compiler
___
Ronald Tocci/Neal Widmer/Gregory
Moss https://www.jdoodle.com/online-java-compiler Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Columbus, OH 43235
Applications, 10e All rights reserved.
2-3 Hexadecimal Number System
 Most digital systems deal with groups of bits in even
powers of 2 such as 8, 16, 32, and 64 bits.
 Hexadecimal uses groups of 4 bits.
 Base 16
 16 possible symbols
 0123456789ABCDEF
 N digits: 16N different values
 Allows for convenient handling of long binary
strings.
Ronald Tocci/Neal Widmer/Gregory
Moss Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Columbus, OH 43235
Applications, 10e All rights reserved.
2-3 Hexadecimal Number System
 Convert from hex to decimal by
multiplying each hex digit by its positional
weight.
Example:
16316 = 1× (16 2 ) + 6 × (161 ) + 3 × (160 )
= 1× 256 + 6 ×16 + 3 ×1
= 35510
Ronald Tocci/Neal Widmer/Gregory
Moss Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Columbus, OH 43235
Applications, 10e All rights reserved.
2-3 Hexadecimal Number System
 Convert from decimal to hex by using the
repeated division method used for decimal to
binary and decimal to octal conversion.
 Divide the decimal number by 16
 The first remainder is the LSB and the last is the
MSB.
 Note, when done on a calculator a decimal remainder
can be multiplied by 16 to get the result. If the
remainder is greater than 9, the letters A through F are
used.
Ronald Tocci/Neal Widmer/Gregory
Moss Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Columbus, OH 43235
Applications, 10e All rights reserved.
2-3 Hexadecimal Number System
Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Hexadecimal 0 1 2 3 4 5 6 7 8 9 A B C D E F
Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

 Example of hex to binary conversion:

9F216 = 9 F 2
1001 1111 0010 = 1001111100102

Ronald Tocci/Neal Widmer/Gregory


Moss Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Columbus, OH 43235
Applications, 10e All rights reserved.
2-3 Hexadecimal Number System
 Convert from binary to hex by grouping bits
in four starting with the LSB.
 Each group is then converted to the hex
equivalent
 Leading zeros can be added to the left of the
MSB to fill out the last group.

Ronald Tocci/Neal Widmer/Gregory


Moss Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Columbus, OH 43235
Applications, 10e All rights reserved.
2-3 Hexadecimal Number System
Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Hexadecimal 0 1 2 3 4 5 6 7 8 9 A B C D E F
Binary 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

 Example of binary to hex conversion.


(Note the addition of leading zeroes)

11101001102 = 0011 1010 0110


= 3 A 6
= 3A616
 Counting in hex requires a reset and carry after reaching
F.
Ronald Tocci/Neal Widmer/Gregory
Moss Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Columbus, OH 43235
Applications, 10e All rights reserved.
2-3 Hexadecimal Number System
 Hexadecimal is useful for representing long
strings of bits.
 Understanding the conversion process and
memorizing the 4 bit patterns for each
hexadecimal digit will prove valuable later.

Ronald Tocci/Neal Widmer/Gregory


Moss Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Columbus, OH 43235
Applications, 10e All rights reserved.
2-4 BCD
 Binary Coded Decimal (BCD) is another way
to present decimal numbers in binary form.
 BCD is widely used and combines features of
both decimal and binary systems.
 Each digit is converted to a binary equivalent.

Ronald Tocci/Neal Widmer/Gregory


Moss Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Columbus, OH 43235
Applications, 10e All rights reserved.
2-4 BCD
 To convert the number 87410 to BCD:

8 7 4
1000 0111 0100 = 100001110100BCD

 Each decimal digit is represented using 4 bits.


 Each 4-bit group can never be greater than 9.
 Reverse the process to convert BCD to decimal.
Ronald Tocci/Neal Widmer/Gregory
Moss Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Columbus, OH 43235
Applications, 10e All rights reserved.
2-4 BCD
 BCD is not a number system.
 BCD is a decimal number with
each digit encoded to its binary
equivalent.
 A BCD number is not the same as a
straight binary number.
 The primary advantage of BCD is
the relative ease of converting to
and from decimal.
Ronald Tocci/Neal Widmer/Gregory
Moss Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Columbus, OH 43235
Applications, 10e All rights reserved.
2-5 Gray Code
 The (binary-reflected) gray code is used in
applications where numbers change rapidly.
 In the gray code, only one bit changes from
each value to the next.
 Gray encoders:
 9 positions 128 positions:

Ronald Tocci/Neal Widmer/Gregory


Moss Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Columbus, OH 43235
Applications, 10e All rights reserved.
2-5 Gray Code
Binary Gray Code Binary
000 000 encoder
001 001
010 011
011 010
100 110
101 111
110 101 Gray code
111 100 encoder

Ronald Tocci/Neal Widmer/Gregory


Moss
Digital Systems: Principles and
Applications, 10e
Gray code
 The binary-reflected Gray code
for n bits can be generated
recursively by:
 reflecting the bits (i.e. listing
them in reverse order and
concatenating the reverse list onto
the original list)
 prefixing the original bits with a
binary 0 and then prefixing the
reflected bits with a binary 1
Binary to Gray Code
 100102→11011(gray)

 11011(gray)→ 100102
2-6 Putting It All Together
Decimal Binary Hexadecimal BCD Gray
0 0 0 0 0
1 1 1 0001 0001
2 10 2 0010 0011
3 11 3 0011 0010
4 100 4 0100 0110
5 101 5 0101 0111
6 110 6 0110 0101
7 111 7 0111 0100
8 1000 8 1000 1100
9 1001 9 1001 1101
10 1010 A 0001 0000 1111
11 1011 B 0001 0001 1110
12 1100 C 0001 0010 1010
13 1101 D 0001 0011 1011
14 1110 E 0001 0100 1001
15 1111 F 0001 0101 1000
Ronald Tocci/Neal Widmer/Gregory
Moss Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Columbus, OH 43235
Applications, 10e All rights reserved.
2-7 The Byte, Nibble, and Word
 1 byte = 8 bits
 1 nibble = 4 bits
 1 word = size depends on data pathway size.
 Word size in a simple system may be one byte (8
bits)
 Typical word size in a PC:
 Common systems: 4 bytes (32 bits)
 Modern computer systems: 8 bytes (64 bits)
Ronald Tocci/Neal Widmer/Gregory
Moss Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Columbus, OH 43235
Applications, 10e All rights reserved.
Byte multiples
 Kilobyte (KB)  Petabyte (PB)
 1 KB = 1000 bytes= 103  1 000 PB = 1015 Bytes
Bytes.  Exabyte (EB)
 Megabyte (MB)  1 000 PB = 1018 Bytes
 1000 KB  Zettabyte (ZB)
 1000 ×1000= 106 Bytes  1 000 EB = 1021 Bytes
 Gigabyte (GB)  Yottabyte (YB)
 1 000 MB = 109 KB  1 000 ZB = 1024 Bytes
 Terabyte (TB)
 1 000 GB = 1012 Bytes
Byte multiples (binary prefixes)
 Kibibyte (KiB)  Pebibyte (PiB)
 1 KB = 1024 bytes (210 bytes).  1 024 TiB
 Mebibyte (MiB)  250 Bytes
 1 024 KiB  Exbibyte (EiB)
 1024 ×1024= 1 048 576 (220) Bytes  1 024 PiB
 Gibibyte (GiB)  260 Bytes
 1 024 MiB = 1 048 576 KiB  Zebibyte (ZiB)
 1 073 741 824 (230) Bytes  1 024 EiB
 Tebibyte (TiB)  270 Bytes
 1 024 GiB  Yobibyte (YiB)
 240 Bytes  1 024 ZiB
(standard IEC 60027-1 International Electrotechnical Commission (IEC)  280 Bytes
recent nomenclature, sometimes is confused with the previous one)
2-8 Alphanumeric Codes
 Computers can only understand numbers, so a code is needed
for the numerical representation of a character such as 'a' or
'@' or '8‘, or an action of some sort
 Represents characters and functions found on a computer
keyboard.
 ASCII – American Standard Code for Information
Interchange.
 Basic table + extended table
 Seven bit code: 27 = 128 possible code groups
 Examples of use are: to transfer information between computers,
between computers and printers, and for internal storage.
Ronald Tocci/Neal Widmer/Gregory
Moss Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Columbus, OH 43235
Applications, 10e All rights reserved.
Basic ASCII code table
(One) Extended ASCII code table
2-9 Parity Method for Error Detection
 Binary data and codes are frequently transmitted between
locations. For example:
 Digitized voice over a microwave link.
 Storage and retrieval of data from magnetic and optical disks.
 Communication between computer systems over telephone lines
using a modem.
 Electrical noise can cause errors during transmission:

 Many digital systems employ methods for error detection


(and sometimes correction).
2-9 Parity Method for Error Detection
 The parity method of error detection requires
the addition of an extra bit to a code group.
 This extra bit is called the parity bit.
 The bit can be either a 0 or 1, depending on
the number of 1s in the code group.
 There are two methods:
 Even parity
 Odd parity.
Ronald Tocci/Neal Widmer/Gregory
Moss Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Columbus, OH 43235
Applications, 10e All rights reserved.
2-9 Parity Method for Error Detection
 Even parity method
 The total number of bits in a group including the
parity bit must add up to an even number.
 The binary group 1 0 1 1 would require the
addition of a parity bit 1 1 0 1 1
 Note that the parity bit may be added at either end of a
group.

Ronald Tocci/Neal Widmer/Gregory


Moss Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Columbus, OH 43235
Applications, 10e All rights reserved.
2-9 Parity Method for Error Detection
 Odd parity method
 The total number of bits in a group including the
parity bit must add up to an odd number.
 The binary group 1 1 1 1 would require the
addition of a parity bit 1 1 1 1 1

Ronald Tocci/Neal Widmer/Gregory


Moss Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Columbus, OH 43235
Applications, 10e All rights reserved.
2-9 Parity Method for Error Detection
 The transmitter and receiver must “agree” on the
type of parity checking used.
 Two bit errors would not indicate a parity error.
 Both odd and even parity methods are used, but even
seems to be used more often.

Copyright ©2007 by Pearson Education, Inc.


Columbus, OH 43235
All rights reserved.
2-10 Applications
 A CD-ROM stores 650 megabytes of digital data.
How many bits of data is this?
 Determine the odd parity bit required for each of the
following 7 bit ASCII codes:
_ 1001010
_ 0101101
_ 0110101
 Determine the even parity bit required for each 7 bit
ASCII code listed above.
Ronald Tocci/Neal Widmer/Gregory
Moss Copyright ©2007 by Pearson Education, Inc.
Digital Systems: Principles and Columbus, OH 43235
Applications, 10e All rights reserved.

You might also like