Documente Academic
Documente Profesional
Documente Cultură
IE-321
Fundamentals of
Dr. Atif Shahzad
LECTURE #02
14-Jan-16
Computer Systems 1
RECAP
Page 1
Course Objectives
Rules & regulations
Grading scheme
Teaching Methodology
An overview of topics
Logic examples
A simple Logic thinking process
Dr. Atif Shahzad
9/27/2018 2
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
Dr. Atif Shahzad
Q&A
9/27/2018 3
Fundamentals of
Computer Systems
LECTURE #02
Dr. Atif Shahzad
Numbering Systems
14/01/2016
14/01/2016 4
Robert Noyce, 1927 - 1990
• Nicknamed “Mayor of Silicon Valley”
• Cofounded Fairchild Semiconductor in 1957
• Cofounded Intel in 1968
• Co-invented the integrated circuit
Dr. Atif Shahzad
Discrete Discrete
Information Discrete
Inputs
Processing Outputs
System
Dr. Atif Shahzad
System State
14/01/2016
9/27/2018 8 8
Types of Digital Systems
No state
State present
present
Output =
Combination Output =
State = Function
al Function State updated at State updated Function (State)
discrete times at any time (State, or Function
Logic System (Input)
Input) (State,
Input)
=> =>
Synchronous Asynchronous
Sequential Sequential
System System
Dr. Atif Shahzad
14/01/2016
9/27/2018 9 9
Logic Automatisms by Dr. Atif Shahzad
10
9/27/2018
Digital Systems
Two States
• On/Off
• Black/White
• Hot/Cold
Dr. Atif Shahzad
• Stationary/Moving
9/27/2018 10
Digital System Example:
A Digital Counter (e. g., odometer):
Count Up
Reset 0 0 1 3 5 64
Inputs: Count Up, Reset
Outputs: Visual Display
State: "Value" of stored digits
Dr. Atif Shahzad
14/01/2016
9/27/2018 11 11
A Digital Computer Example
Memory
Control
CPU unit Datapath
Inputs:
Outputs: CRT,
Keyboard,
LCD, modem,
mouse, modem, Input/Output
speakers
microphone
Synchronous or
Dr. Atif Shahzad
Asynchronous?
14/01/2016
9/27/2018 12 12
Digital Systems and Computer
Logic Automatisms by Dr. Atif Shahzad
13
9/27/2018
Systems
Dr. Atif Shahzad
9/27/2018 13
Signal
An information variable
represented by physical quantity.
14/01/2016
9/27/2018 14 14
Signal
Two level, or binary values are the most prevalent values in digital systems.
digits 0 and 1
represented abstractly by:
Binary values are
On and Off.
9/27/2018 15
Signal Examples Over Time
Time
Continuous in
Analog value & time
Digital Discrete in
value &
Asynchronous
continuous in
time
Synchronous Discrete in
Dr. Atif Shahzad
Volts
14/01/2016
9/27/2018 17 17
Binary Values: Other Physical
Quantities
What do other
physical quantities
represent 0 and 1?
CPU: Voltage
Information Representation
Dr. Atif Shahzad
9/27/2018 19
Number Systems [binary, octal
Logic Automatisms by Dr. Atif Shahzad
20
9/27/2018
and hexadecimal]
Dr. Atif Shahzad
9/27/2018 20
Number Systems –
Representation
Radix
in positional number systems
� 𝑑𝑑𝑖𝑖 . 10𝑖𝑖
𝑖𝑖=𝑛𝑛−1
Dr. Atif Shahzad
14/01/2016
9/27/2018 22 22
Number Systems – Questions
78 =
947=
301=
1294
10101010=
123456=
98123=
0
Dr. Atif Shahzad
� 𝑑𝑑𝑖𝑖 . 10𝑖𝑖
14/01/2016
9/27/2018
𝑖𝑖=𝑛𝑛−1 23 23
Number Systems – Examples
General Decimal Binary
Radix (Base) r 10 2
Digits 0 => r - 1 0 => 9 0 => 1
0 r0 1 1
1 r1 10 2
2 r2 100 4
3 r3 1000 8
Powers of 4 r4 10,000 16
Radix 5 r5 100,000 32
-1 r -1 0.1 0.5
-2 r -2 0.01 0.25
-3 r -3 0.001 0.125
-4 r -4 0.0001 0.0625
Dr. Atif Shahzad
-5 r -5 0.00001 0.03125
14/01/2016
9/27/2018 24 24
Binary Number
representation
0
� 𝑑𝑑𝑖𝑖 . 2𝑖𝑖
𝑖𝑖=𝑛𝑛−1
0
14/01/2016
9/27/2018 25 25
Binary Number
representation- EXAMPLE
0
� 𝑑𝑑𝑖𝑖 . 2𝑖𝑖
𝑖𝑖=𝑛𝑛−1
0
11012 = 1 × 23 +1 × 22 + 0 × 21 +1 × 20
Dr. Atif Shahzad
14/01/2016
9/27/2018 26 26
Binary Number
representation- EXAMPLE
The digits of the binary number are called bits
MSB=Most Significant Bit
LSB=Least Significant Bit 0
11012 = 1 × 23 + 1 × 22 + 0 × 21 + 1 × 20
Dr. Atif Shahzad
28 27 26 25 24 23 22 21 20
256 128 64 32 16 8 4 2 1
Dr. Atif Shahzad
14/01/2016
9/27/2018 28 28
Binary Number Names &
Prefixes
Number of Binary
Common Name
Digits (bits)
1 Bit
4 Nibble
8 Byte
16 Word
32 Double Word
64 Quad Word
Dr. Atif Shahzad
14/01/2016
9/27/2018 29 29
Special Powers of 2
14/01/2016
9/27/2018 30 30
Positive Powers of 2
Useful for Base Conversion
Exponent Value Exponent Value
0 1 11 2,048
1 2 12 4,096
2 4 13 8,192
3 8 14 16,384
4 16 15 32,768
5 32 16 65,536
6 64 17 131,072
7 128 18 262,144
8 256 19 524,288
9 512 20 1,048,576
Dr. Atif Shahzad
10 1024 21 2,097,152
14/01/2016
9/27/2018 31 31
Positive Powers of 2
Useful for Base Conversion
Exponent Value Exponent Value
0 1 11 2,048
1 2 12 4,096
2 4 13 8,192
3 8 14 16,384
4 16 15 32,768
5 32 16 65,536
6 64 17 131,072
7 128 18 262,144
8 256 19 524,288
9 512 20 1,048,576
Dr. Atif Shahzad
10 1024 21 2,097,152
14/01/2016
9/27/2018 32 32
In general…
0
𝑖𝑖=𝑛𝑛−1
14/01/2016
9/27/2018 33 33
Binary Number Systems –
Questions
10001 =
101010=
1100=
10000000=
100000101=
101010101010110=
1111110=
0
Dr. Atif Shahzad
� 𝑑𝑑𝑖𝑖 . 2𝑖𝑖
14/01/2016
9/27/2018
𝑖𝑖=𝑛𝑛−1 34 34
Usage of Number systems
Radix Name Description
2 Binary Computers
10 Decimal Everywhere
12 Duodecimal
Quantities like dozens
(dozenal)
16 Hexadecimal Used in Computing
9/27/2018 35
Commonly Occurring Bases
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
Dr. Atif Shahzad
14/01/2016
9/27/2018 36 36
Numbers in Different Bases
Good idea to memorize!
Decimal Binary Octal Hexadecimal
(Base 10) (Base 2) (Base 8) (Base 16)
00 00000 00 00
01 00001 01 01
02 00010 02 02
03 00011 03 03
04 00100 04 04
05 00101 05 05
06 00110 06 06
07 00111 07 07
08 01000 10 08
09 01001 11 09
10 01010 12 0A
11 01011 13 0B
12 01100 14 0C
13 01101 15 0D
Dr. Atif Shahzad
14 01110 16 0E
15 01111 17 0F
16 10000 20 10
14/01/2016
9/27/2018 37 37
Base Conversion
How to convert from one base system to other ?
Any Idea?
Dr. Atif Shahzad
14/01/2016
9/27/2018 38 38
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
1/2 1
14/01/2016
9/27/2018
1111011
39 39
Decimal to Binary– Questions
78 =
947=
301=
1294
10101010=
123456=
98123=
100=
Dr. Atif Shahzad
14/01/2016
9/27/2018 40 40
Conversion Details
(in general)
To Convert the Integral 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 digits A, B, …
To Convert the Fractional 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 digits A, B, …
Dr. Atif Shahzad
14/01/2016
9/27/2018 41 41
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
Dr. Atif Shahzad
14/01/2016
9/27/2018 42 42
Binary to Decimal – Questions
10001 =
101010=
1100=
10000000=
100000101=
101010101010110=
1111110=
100=
Dr. Atif Shahzad
14/01/2016
9/27/2018 43 43
Conversion Between Bases
Method 2
To convert from one base to another:
14/01/2016
9/27/2018 44 44
Example: Convert 46.687510 To
Base 2
Convert 46 to Base 2
14/01/2016
9/27/2018 45 45
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
14/01/2016
9/27/2018 46 46
exercise: Convert
Convert 46 to Base 2
Convert 321 to Base 2
Convert 89 to Base 2
Convert 74 to Base 2
Convert 𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟐𝟐 to Base 10
Convert 𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟐𝟐 to Base 10
Convert 𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟐𝟐 to Base 10
Dr. Atif Shahzad
9/27/2018 48
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.
Dr. Atif Shahzad
14/01/2016
9/27/2018 49 49
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
Dr. Atif Shahzad
14/01/2016
9/27/2018 50 50
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
Dr. Atif Shahzad
14/01/2016
9/27/2018 52 52
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
Dr. Atif Shahzad
14/01/2016
9/27/2018 53 53
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.
14/01/2016
9/27/2018 54 54
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
Dr. Atif Shahzad
14/01/2016
9/27/2018 55 55
exercise: Convert
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
Dr. Atif Shahzad
14/01/2016
9/27/2018 58 58
Octal to Hexadecimal via
Binary--Question
(6 3 5 . 1 7 7) 8
Dr. Atif Shahzad
14/01/2016
9/27/2018 59 59
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
Dr. Atif Shahzad
14/01/2016
9/27/2018 60 60
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.
Information Types
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
Dr. Atif Shahzad
14/01/2016
9/27/2018 61 61
Brain Teaser…
5 4 3 2 1
2 + 2 + 2 + 2 + 2 +2
=?
6
2 +1
26 − 1
6
2
6
3
Dr. Atif Shahzad
9/27/2018 62
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 ?
Dr. Atif Shahzad
.
14/01/2016
9/27/2018 63 63
Dr. Atif Shahzad
14-Jan-16
65
NEVER hesitate to
contact should you
have any question
Dr. Atif Shahzad
Dr. Atif Shahzad
14-Jan-16 66