Beruflich Dokumente
Kultur Dokumente
Dr. I. Damaj 1
Overview
n Digital Systems and Computer Systems
n Information Representation
n Number Systems [binary, octal and hexadecimal]
n Arithmetic Operations
n Base Conversion
n Decimal Codes [BCD (binary coded decimal), parity]
n Gray Codes
n Alphanumeric Codes
Dr. I. Damaj 2
1
Digital?
Digital
Computers?
Computers and
Information?
Information
Digital Computers and Information
0 1 Data
PE, I/O, Mem,…
Dr. I. Damaj 3
Discrete Discrete
Inputs Information
Discrete
Processing
System Outputs
System State
Dr. I. Damaj 4
2
Types of Digital Systems
n No state present
n Combinational Logic System
n Output = Function(Input)
n State present
n State updated at discrete times
Dr. I. Damaj 5
Count Up
Reset 0 0 1 3 5 6 4
Synchronous or Asynchronous?
Dr. I. Damaj 6
3
Digital Computers
n Digital Computers are heavily employed in design
manufacturing, distribution and sales.
Dr. I. Damaj 7
Signal
n An information variable represented by physical quantity.
n Two level binary values are the most prevalent in digital systems.
4
Signal Examples Over Time
Time
Analog Continuous in
value & time
Digital Discrete in
Asynchronous value &
continuous in
Synchronous
time
Discrete in
value & time
Dr. I. Damaj 9
Signal Example –
Physical Quantity: Voltage
OUTPUT INPUT
5.0
HIGH HIGH
4.0
3.0
Threshold
2.0 Region
1.0
LOW LOW
0.0
Volts
Dr. I. Damaj 10
5
Binary Values: Other Physical
Quantities
n What are other physical quantities
represent 0 and 1?
n CPU: Voltage
n Disk: Magnetic Field Direction
n CD: Surface Pits/Light
n Dynamic RAM: Electrical Charge
Dr. I. Damaj 11
Memory
Control
CPU unit Datapath
6
2. Number Systems – Representation
n Positive radix, positional number systems
n A number with radix r is represented by a string of
digits:
An - 1An - 2 … A1A0 . A- 1 A- 2 … A- m + 1 A- m
in which 0 ≤ Ai < r and . is the radix point.
n The string of digits represents the power series:
(∑ ) (∑ )
i = n-1 j =-1
(Number)r = Ai r +
i
Aj r j
i =0 j =- m
(Integer Portion) + (Fraction Portion)
Dr. I. Damaj 13
Dr. I. Damaj 14
7
Special Powers of 2
Dr. I. Damaj 15
Positive Powers of 2
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
10 1024 21 2,097,152
Dr. I. Damaj 16
8
2.1 Converting Binary to Decimal
Dr. I. Damaj 17
n Method 1
n Subtract the largest power of 2 (see slide 16)
that gives a positive remainder and record the
power.
n Repeat, subtracting from the prior remainder and
recording the power, until the remainder is zero.
n Place 1’s in the positions in the binary result
corresponding to the powers recorded; in all
other positions place 0’s.
n Example: Convert 625 10 to N2
Dr. I. Damaj 18
9
Commonly Occurring Bases
Dr. I. Damaj 19
10
Conversion Between Bases
§ 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
Dr. I. Damaj 21
Conversion Details
n 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, …
11
Example: Convert 46.687510 To
Base 2
n Convert 46 to Base 2
n 1011102
Dr. I. Damaj 23
12
Checking the Conversion
n To convert back, sum the digits times their respective
powers of r.
Dr. I. Damaj 25
Dr. I. Damaj 26
13
Octal (Hexadecimal) to Binary and
Back
n Octal (Hexadecimal) to Binary:
n (127.4)8 = 1 x 82 + 2 x 81 + 7 x 80 + 4 x 8 -1 = (87.5)10
n Similarly for Hexadecimal
Dr. I. Damaj 27
14
Number Range and Width
n Range:
n 16-bit unsigned integer: 0 -> 216 – 1
n i.e. 0 -> 65535
n n-bit unsigned integer: 0 -> 2n – 1
n Width :
n A value (2n – 1) requires n bits to be
represented.
n 16 values = 24 values that need 4 bits.
Dr. I. Damaj 29
n Information Types
n Numeric
n Must represent range of data needed
n Non-numeric
n Greater flexibility since arithmetic operations not applied.
15
Non-numeric Binary Codes
n Given n binary digits (called bits), a binary code is a
mapping from a set of represented elements to a subset
of the 2 n binary numbers.
Color Binary Number
n Example: A Red 000
binary code Orange 001
for the seven Yellow 010
colors of the Green 011
rainbow Blue 101
Indigo 110
Violet 111
n Code 100 is
not used
Dr. I. Damaj 31
16
Number of Elements Represented
n Given n digits in radix r, there are rn distinct elements
that can be represented.
n Examples:
n You can represent 4 elements in radix r = 2 with n = 2
digits: (00, 01, 10, 11).
n You can represent 4 elements in radix r = 2 with n = 4
digits: (0001, 0010, 0100, 1000).
n This second code is called a "one hot" code.
Dr. I. Damaj 33
§ There are over 8,000 ways that you can chose 10 elements
from the 16 binary numbers of 4 bits. A few are useful:
Decimal 8,4,2,1 Excess3 8,4,-2,-1 Gray
0 0000 0011 0000 0000
1 0001 0100 0111 0100
2 0010 0101 0110 0101
3 0011 0110 0101 0111
4 0100 0111 0100 0110
5 0101 1000 1011 0010
6 0110 1001 1010 0011
7 0111 1010 1001 0001
8 1000 1011 1000 1001
9 1001 1100 1111 1000
Dr. I. Damaj 34
17
Binary Coded Decimal (BCD)
n The BCD code is the 8,4,2,1 code.
Dr. I. Damaj 35
Gray Code
Decimal 8,4,2,1 Gray
0 0000 0000
1 0001 0100
2 0010 0101
3 0011 0111
4 0100 0110
5 0101 0010
6 0110 0011
7 0111 0001
8 1000 1001
9 1001 1000
18
Warning: Conversion or
Coding?
n Do NOT mix up conversion of a decimal
number to a binary number with coding a
decimal number with a BINARY CODE.
Dr. I. Damaj 37
Dr. I. Damaj 38
19
Single Bit Binary Addition with
Carry
Given two binary digits (X,Y), a carry in (Z) we get the
following sum (S) and carry (C):
Carry in (Z) of 0: Z 0 0 0 0
X 0 0 1 1
+Y +0 +1 +0 +1
CS 00 01 01 10
Carry in (Z) of 1:
Z 1 1 1 1
X 0 0 1 1
+Y +0 +1 +0 +1
Dr. I. Damaj CS 01 10 10 11 39
Carries 0 0
Augend 01100 10110
Addend + 10001 +10111
Sum 11101 1 01101
20
Single Bit Binary Subtraction with
Borrow
n Given two binary digits (X,Y), a borrow in (Z) we get the following
difference (S) and borrow (B):
n Borrow in (Z) of 0:
Z 0 0 0 0
X 0 0 1 1
-Y -0 -1 -0 -1
BS 00 11 01 00
n Borrow in (Z) of 1:
Z 1 1 1 1
X 0 0 1 1
-Y -0 -1 -0 -1
Dr. I. Damaj
BS 11 10 00 11 41
21
Binary Multiplication
The binary multiplication table is simple:
0∗0=0 | 1∗0=0 | 0∗1=0 | 1∗1=1
Extending multiplication to multiple digits:
Multiplicand 1011
Multiplier x 101
Partial Products 1011
0000 -
1011 - -
Product 110111
Dr. I. Damaj 43
22
BCD Addition Example
Dr. I. Damaj
1001 1 0011 1 0111 45
9 3 7
Why adding 6?
n Take the largest two BCD numbers and add
them:
n 9+9+1=1 9
carry
n In binary:
n 1001 + 1001 + 1 = 1 0011 = 13 and not 19
n The difference is 6!
Dr. I. Damaj 46
23
2.5 Error-Detection Codes
n Redundancy (e.g. extra information), in the form of extra
bits, can be incorporated into binary code words to detect
and correct errors.
24
2.5 ASCII Character Codes
n American Standard Code for Information Interchange.
Dr. I. Damaj 49
Dr. I. Damaj 50
25
2.6 UNICODE
n UNICODE extends ASCII to 65,536 universal characters
codes
n For encoding characters in world languages
n Available in many modern applications
n 2 byte (16-bit) code words
n See Reading Supplement – Unicode on the Companion
Website http://www.prenhall.com/mano
Dr. I. Damaj 51
Problems
n 1, 2, 3, 4, 7, 8, 9, 10, 11, 13, 15, 16, 18, 20,
22, 24
Dr. I. Damaj 52
26