3. 9/27/2018 3
Dr.AtifShahzad
TODAY’S LECTURE
Digital System
What is a Numbering System?
Commonly Occurring Bases
Numbering System Examples
Base Conversion Procedure
Base Conversion
Number of Bits Required
Number of Elements represented
BCD, GRAY, ASCII & UNICODE
Q&A
5. 14/01/2016
Dr.AtifShahzad
5
Robert Noyce, 1927 - 1990
• Nicknamed“Mayor of Silicon Valley”
• Cofounded Fairchild Semiconductor in 1957
• Cofounded Intel in 1968
• Co-invented the integrated circuit
Logic Automatisms by Dr. Atif Shahzad9/27/2018 5
6. 14/01/2016
Dr.AtifShahzad
6
Gordon Moore, 1929 -
• Cofounded Intel in 1968 with Robert Noyce.
• Moore’s Law:the number of transistors on
a computer chip doubles every year (observed
in 1965)
• Since 1975,transistor counts have doubled
every two years.
Logic Automatisms by Dr. Atif Shahzad9/27/2018 6
8. 9/27/2018 8
Dr.AtifShahzad
Digital System
Takes a set of discrete informationinputs and discrete
internal information (system state) and generates a
set of discrete information outputs.
14/01/2016 8
System State
Discrete
Information
Processing
System
Discrete
Inputs
Discrete
Outputs
9. 9/27/2018 9
Dr.AtifShahzad
Types of Digital Systems
14/01/2016 9
No state
present
Combination
al
Logic System
Output =
Function
(Input)
State present
State updated at
discrete times
=>
Synchronous
Sequential
System
State updated
at any time
=>
Asynchronous
Sequential
System
State =
Function
(State,
Input)
Output =
Function
(State)
or Function
(State,
Input)
11. 9/27/2018 11
Dr.AtifShahzad
Digital System Example:
14/01/2016
11
A Digital Counter (e.g.,odometer):
1 30 0 5 6 4
Count Up
Reset
Inputs: Count Up,Reset
Outputs: Visual Display
State: "Value" of stored digits
12. 9/27/2018 12
Dr.AtifShahzad
A Digital Computer Example
14/01/2016
12
Synchronous or
Asynchronous?
Inputs:
Keyboard,
mouse, modem,
microphone
Outputs: CRT,
LCD, modem,
speakers
Memory
Control
unit Datapath
Input/Output
CPU
15. 9/27/2018 15
Dr.AtifShahzad
Signal
Two level, or binary values are the most prevalent values in digital systems.
Binary values are
represented by values or
ranges of values of physical
quantities
Binaryvaluesare
representedabstractlyby:
digits 0 and 1
words (symbols)
False (F) andTrue (T)
words (symbols)
Low (L) and High (H)
words
On and Off.
16. 9/27/2018 16
Dr.AtifShahzad
Signal Examples OverTime
14/01/2016
16
Analog
Asynchronous
Synchronous
Time
Continuous in
value & time
Discrete in
value &
continuous in
time
Discrete in
value & time
Digital
18. 9/27/2018 18
Dr.AtifShahzad
BinaryValues: Other Physical
Quantities
CPU:Voltage
Disk: Magnetic Field Direction
CD: Surface Pits/Light
Dynamic RAM: Electrical Charge
14/01/2016 18
What do other
physical quantities
represent 0 and 1?
21. 9/27/2018 21
Dr.AtifShahzad
Number Systems –
Representation
in positional number systems
Radix
is represented by a string of digits:
dn – 1dn - 2 … d1d0 . d- 1 d- 2 … d- m + 1 d- m
in which 0 ∈ Ai < r and . is the radix point.
A number
with radix r
represents the power series:
The string
of digits
14/01/2016 21
𝑑𝑑𝑛𝑛−1 … 𝑑𝑑2 𝑑𝑑1 𝑑𝑑0 = �
𝑖𝑖=𝑛𝑛−1
0
𝑑𝑑𝑖𝑖. 10𝑖𝑖
27. 9/27/2018 27
Dr.AtifShahzad
Binary Number
representation- EXAMPLE
14/01/2016 27
The digits of the binary number are called bits
MSB=Most Significant Bit
LSB=Least Significant Bit
(𝑑𝑑𝑛𝑛−1… 𝑑𝑑2 𝑑𝑑1 𝑑𝑑0)2 = �
𝑖𝑖=𝑛𝑛−1
0
𝑑𝑑𝑖𝑖. 2𝑖𝑖
11012 = 1 × 23
+ 1 × 22
+ 0 × 21
+ 1 × 20
Group of 8 bits = 1 Byte
29. 9/27/2018 29
Dr.AtifShahzad
Binary Number Names &
Prefixes
Number of Binary
Digits (bits)
Common Name
1 Bit
4 Nibble
8 Byte
16 Word
32 DoubleWord
64 QuadWord
14/01/2016 29
30. 9/27/2018 30
Dr.AtifShahzad
Special Powers of 2
14/01/2016
30
210 (1024) is Kilo,denoted "K"
220 (1,048,576) is Mega,denoted "M"
230 (1,073,741,824) is Giga,denoted "G"
35. 9/27/2018 35
Dr.AtifShahzad
Usage of Number systems
Name Description
Binary Computers
Octal Occasionally in Computing
Decimal Everywhere
Duodecimal
(dozenal)
Quantities like dozens
Hexadecimal Used in Computing
Vigesimal Traditional in some cultures
Sexagesimal Cirular coordinate system
(Angle and time)
Radix
2
8
10
12
16
20
60
36. 9/27/2018 36
Dr.AtifShahzad
Commonly Occurring Bases
14/01/2016
36
Name Base Digits
Binary 2 0,1
Octal 8 0,1,2,3,4,5,6,7
Decimal 10 0,1,2,3,4,5,6,7,8,9
Hexadecimal 16 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
The six letters (in addition to the 10 integers) in hexadecimal
represent: 10,11,12,13,14,15
39. 9/27/2018 39
Dr.AtifShahzad
Converting Decimal to Binary
Successively divide the decimal number by 2
Record the remainders after each division
The remainders written in reverse order form the binary number
14/01/2016 39
Example:Convert 12310 to N2
123/2 1
61/2 1
30/2 0
15/2 1
7/2 1
3/2 1
1/2 1
1111011
41. 9/27/2018 41
Dr.AtifShahzad
Conversion Details
(in general)
To Convert theIntegral Part:
Repeatedly divide the number by the new radix and save the
remainders.The digits for the new radix are the remainders
in reverse order of their computation. If the new radix is >
10, then convert all remainders > 10 to digitsA, B, …
To Convert theFractional Part:
Repeatedly multiply the fraction by the new radix and save
the integer digits that result. The digits for the new radix are
the integer digits in order of their computation. If the new
radix is > 10, then convert all integers > 10 to digitsA, B, …
14/01/2016 41
42. 9/27/2018 42
Dr.AtifShahzad
Converting Binary to Decimal
To convert to decimal, use decimal arithmetic
to form Σ (digit × respective power of 2).
Example:Convert 11012 to N10:
= 1 × 23
+ 1 × 22
+0 × 21
+1 × 20
= 13
14/01/2016 42
44. 9/27/2018 44
Dr.AtifShahzad
Conversion Between Bases
14/01/2016
44
Method 2
To convert from one base to another:
1) Convert the Integer Part
2) Convert the Fraction Part
3) Join the two results with a radix point
46. 9/27/2018 46
Dr.AtifShahzad
Example: Convert 46.687510 To
Base 2
Convert 46 to Base 2
46/2 = 23 rem = 0
23/2 = 11 rem = 1
11/2 = 5 remainder = 1
5/2 = 2 remainder = 1
2/2 = 1 remainder = 0
1/2 = 0 remainder = 1
Reading off in the reverse direction: 1011102
Convert 0.6875 to Base 2:
0.6875 * 2 = 1.3750 int = 1
0.3750 * 2 = 0.7500 int = 0
0.7500 * 2 = 1.5000 int = 1
0.5000 * 2 = 1.0000 int = 1
0.0000
Reading off in the forward direction: 0.10112
Join the results together with the radix point:
Combining Integral and Fractional Parts:
101110. 10112
14/01/2016 46
47. 9/27/2018 47
Dr.AtifShahzad
exercise: Convert
Convert 46 to Base 2
Convert 321 to Base 2
Convert 89 to Base 2
Convert 74 to Base 2
14/01/2016 47
Convert 𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟐𝟐 to Base 10
Convert 𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟐𝟐 to Base 10
Convert 𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟐𝟐 to Base 10
Convert 𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟐𝟐 to Base 10
48. 9/27/2018 48
Dr.AtifShahzad
A BrainTeaser…
It is known that octopuses with 7 legs always
lie, while those with 6 legs and those with 8
legs always tell the truth. One night, four
octopuses met:
Black — 'We have 28 legs.'
Green — 'We have 27 legs.'
Yellow— 'We have 26 legs.'
Red — 'We have 25 legs.'
Who spoke the truth?
49. 9/27/2018 49
Dr.AtifShahzad
Additional Issue - Fractional
Part
Note that in this conversion, the fractional part
became 0 as a result of the repeated multiplications.
In general, it may take many bits to get this to happen
or it may never happen.
Example: Convert 0.6510 to N2
0.65 = 0.1010011001001 …
The fractional part begins repeating every 4 steps yielding
repeating 1001 forever!
Solution: Specify number of bits to right of radix
point and round or truncate to this number.
14/01/2016 49
50. 9/27/2018 50
Dr.AtifShahzad
Checking the Conversion
To convert back, sum the digits times their
respective powers of r.
From the prior conversion of 46.687510
1011102 = 1·32 + 0·16 +1·8 +1·4 + 1·2 +0·1
= 32 + 8 + 4 + 2
= 46
0.10112 = 1/2 + 1/8 + 1/16
= 0.5000 + 0.1250 + 0.0625
= 0.6875
14/01/2016 50
51. 9/27/2018 52
Dr.AtifShahzad
Octal to Binary
Octal to Binary:
Restate the octal as three binary digits starting at
the radix point and going both ways.
Example: 1438
110 =001
410=100
310=011
so 1438 = 001 100 0112
14/01/2016 52
52. 9/27/2018 53
Dr.AtifShahzad
Hexadecimal to Binary
Hexadecimal to Binary:
Restate the octal as four binary digits starting at
the radix point and going both ways.
Example: 14316
110 =0001
410=0100
310=0011
so 14316 = 0001 0100 0011 2
14/01/2016 53
53. 9/27/2018 54
Dr.AtifShahzad
Binary to Octal
Binary to Octal :
Group the binary digits into three bit groups
starting at the radix point and going both ways,
padding with zeros as needed in the fractional
part.
Convert each group of three bits to an octal digit.
001100011 2= 001 100 011 2
Implies 1438
14/01/2016 54
54. 9/27/2018 55
Dr.AtifShahzad
Binary to hexadecimal
Binary to hexadecimal:
Group the binary digits into four bit groups starting
at the radix point and going both ways, padding with
zeros as needed in the fractional part.
Convert each group of four bits to an hexadecimal
digit.
0001010000112= 0001 0100 00112
Implies 14316
14/01/2016 55
55. 9/27/2018 56
Dr.AtifShahzad
exercise: Convert
14/01/2016 56
Convert 𝟏𝟏𝟏𝟏𝟏𝟏𝟖𝟖 to Base 2
Convert 𝟑𝟑𝟑𝟑𝟑𝟑𝟖𝟖 to Base 2
Convert 𝟏𝟏𝟕𝟕𝟎𝟎𝟎𝟎𝟓𝟓𝟎𝟎𝟖𝟖 to Base 2
Convert 𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟖𝟖 to Base 2
Convert 𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏 to Base 2
Convert 𝟕𝟕𝟕𝟕𝟏𝟏𝟏𝟏 to Base 2
Convert 𝑨𝑨𝑨𝑨𝑨𝑨𝟏𝟏𝟏𝟏 to Base 2
Convert 𝟗𝟗𝟗𝟗𝟗𝟗𝟏𝟏𝟏𝟏 to Base 2
56. 9/27/2018 57
Dr.AtifShahzad
exercise: Convert
14/01/2016 57
Convert 𝟏𝟏𝟏𝟏𝟏𝟏𝟐𝟐 to Base 8
Convert 𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟐𝟐 to Base 8
Convert 𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟖𝟖 to Base 8
Convert 𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟐𝟐 to Base 6
Convert 𝟏𝟏𝟏𝟏𝟏𝟏𝟐𝟐 to Base 16
Convert 𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟐𝟐 to Base 16
Convert 𝟎𝟎𝟎𝟎𝟎𝟎𝟎𝟎𝟎𝟎𝟎𝟎𝟎𝟎𝟎𝟎𝟐𝟐 to Base 16
Convert 𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟐𝟐 to Base 16
57. 9/27/2018 58
Dr.AtifShahzad
Octal to Hexadecimal via
Binary
Convert octal to binary.
Use groups of four bits and convert as above
to hexadecimal digits.
Example: Octal to Binary to Hexadecimal
6 3 5 8
14/01/2016 58
59. 9/27/2018 60
Dr.AtifShahzad
A Final Conversion Note
You can use arithmetic in other bases if
you are careful:
Example: Convert 1011102 to Base 10
using binary arithmetic:
Step 1 101110 / 1010 = 100 r 0110
Step 2 100 / 1010 = 0 r 0100
Converted Digits are 01002 | 01102
or 4 6 10
14/01/2016 60
60. 9/27/2018 61
Dr.AtifShahzad
Binary Numbers and Binary
Coding
Flexibility of representation
Within constraints below, can assign any binary
combination (called a code word) to any data as long as
data is uniquely encoded.
InformationTypes
Numeric
Must represent range of data needed
Very desirable to represent data such that simple, straightforward
computation for common arithmetic operations permitted
Tight relation to binary numbers
Non-numeric
Greater flexibility since arithmetic operations not applied.
Not tied to binary numbers
14/01/2016 61
62. 9/27/2018 63
Dr.AtifShahzad
There are 3 boxes, exactly one of which has a
chocolate.You can keep the chocolate if you pick
the correct box!
On each box there is a statement, exactly one of
which is true.
• Box 1:The chocolate is in this box.
• Box 2:The chocolate is not in this box.
• Box 3:The chocolate is not in box 1.
Which box has the chocolate ?
.
14/01/2016 63