Professional Documents
Culture Documents
Introduction
Discrete Discrete
Inputs Information
Processing Discrete
System Outputs
System State
Types of Digital Systems
No state present
Combinational 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)
Digital System Example
Count Up
Reset 0 0 1 3 5 6 4
Memory
Control
CPU unit Datapath
Inputs:
Outputs: LCD
keyboard,
screen,
mouse, Input/Output wireless,
wireless,
speakers
microphone
And Beyond – Embedded Systems
Chapter 1 8
INFORMATION REPRESENTATION - Signals
Chapter 1 9
Signal Examples Over Time
Time
Continuous
Analog in value &
time
Digital
Discrete in
Asynchronous value &
continuous
in time
Synchronous Discrete in
value & time
Chapter 1 10
NUMBER SYSTEMS – Representation
i=n-1 j=-1
(Number)r =
Ai r + i
Aj r j
( )( )
i=0 j=-m
(Integer Portion) + (Fraction Portion)
Chapter 1 11
Number Systems – Examples
Chapter 1 12
Decimal Number System
Base (also called radix) = 10
10 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }
Digit Position
Integer & fraction 2 1 0 -1 -2
Digit Weight
Position 5 1 2 7 4
Weight = (Base)
Magnitude
100 10 1 0.1 0.01
Sum of “Digit x Weight”
Formal Notation
d2*B2+d1*B1+d0*B0+d-1*B-1+d-2*B-2
(512.74)10
13 /
45
Octal Number System
Base = 8
8 digits { 0, 1, 2, 3, 4, 5, 6, 7 }
Weights
Position
Weight = (Base) 64 8 1 1/8 1/64
Magnitude
5 1 2 7 4
Sum of “Digit x Weight”
2 1 0 -1 -2
Formal Notation
5 *82+1 *81+2 *80+7 *8-1+4 *8-2
=(330.9375)10
(512.74)8
14 /
45
Binary Number System
Base = 2
2 digits { 0, 1 }, called binary digits or “bits”
Weights
Position 4 2 1 1/2 1/4
Weight = (Base)
Magnitude 1 0 1 0 1
Sum of “Bit x Weight”
2 1 0 -1 -2
Formal Notation
1 *22+0 *21+1 *20+0 *2-1+1 *2-2
Groups of bits 4 bits = Nibble =(5.25)10
8 bits = Byte
(101.01)2
1011
11000101
15 /
45
Hexadecimal Number System
Base = 16
16 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F }
Weights
Position
Weight = (Base) 256 16 1 1/16 1/256
Magnitude
1 E 5 7 A
Sum of “Digit x Weight”
2 1 0 -1 -2
Formal Notation
1 *162+14 *161+5 *160+7 *16-1+10 *16-2
=(485.4765625)10
(1E5.7A)16
16 /
45
The Power of 2
n 2n n 2n
0 20=1 8 28=256
1 21=2 9 29=512
2 22=4 10 210=1024 Kilo
3 23=8 11 211=2048
4 24=16 12 212=4096
5 25=32 20 220=1M Mega
1 1 Carry
5 5
+ 5 5
1 1 0
= Ten ≥ Base
Subtract a Base
18 /
45
Binary Addition
Column Addition
1 1 1 1 1 1
1 1 1 1 0 1 = 61
+ 1 0 1 1 1 = 23
1 0 1 0 1 0 0 = 84
≥ (2)10
19 /
45
Binary Subtraction
Borrow a “Base” when needed
1 2 = (10)2
0 2 2 0 0 2
1 0 0 1 1 0 1 = 77
− 1 0 1 1 1 = 23
0 1 1 0 1 1 0 = 54
20 /
45
Binary Multiplication
Bit by bit
1 0 1 1 1
x 1 0 1 0
0 0 0 0 0
1 0 1 1 1
0 0 0 0 0
1 0 1 1 1
1 1 1 0 0 1 1 0
21 /
45
Number Base Conversions
Evaluate
Magnitude
Octal
(Base 8)
Evaluate
Magnitude
Decimal Binary
(Base 10) (Base 2)
Hexadecimal
(Base 16)
Evaluate
22 /
Magnitude 45
Decimal (Integer) to Binary Conversion
Example: (13)10
Quotient Remainder Coefficient
13 /2= 6 1 a0 = 1
6 /2= 3 0 a1 = 0
3 /2= 1 1 a2 = 1
1 /2= 0 1 a3 = 1
Answer: (13)10 = (a3 a2 a1 a0)2 = (1101)2
MSB LSB
23 /
45
Decimal (Fraction) to Binary Conversion
Example: (0.625)10
Integer Fraction Coefficient
0.625 × 2 = 1 . 25 a-1 = 1
0.25 × 2 = 0 . 5 a-2 = 0
0.5 ×2= 1 . 0 a-3 = 1
Answer: (0.625)10 = (0.a-1 a-2 a-3)2 = (0.101)2
MSB LSB
24 /
45
Decimal to Octal Conversion
Example: (175)10
Quotient Remainder Coefficient
175 / 8 = 21 7 a0 = 7
21 / 8 = 2 5 a1 = 5
2 /8= 0 2 a2 = 2
Answer: (175)10 = (a2 a1 a0)8 = (257)8
Example: (0.3125)10
Integer Fraction Coefficient
0.3125 * 8 = 2 . 5 a-1 = 2
0.5 *8= 4 . 0 a-2 = 4
Answer: (0.3125)10 = (0.a-1 a-2 a-3)8 = (0.24)8
25 /
45
Binary − Octal Conversion
8 = 23 Octal Binary
Each group of 3 bits represents an octal
0 000
digit
1 001
2 010
Assume Zeros
Example: 3 011
( 1 0 1 1 0 . 0 1 )2 4 100
5 101
6 110
( 2 6 . 2 )8 7 111
Example:
( 2 6 . 2 )8
( 0 1 0 1 1 0 . 0 1 0 )2
(1 6 . 4 )16
29 /
45
Complements
1’s Complement (Diminished Radix Complement)
All ‘0’s become ‘1’s
All ‘1’s become ‘0’s
Example (10110000)2
(01001111)2
If you add a number and its 1’s complement …
10110000
+ 01001111
11111111
30 /
45
Complements
2’s Complement (Radix Complement)
Take 1’s complement then add 1
Toggle all bits to the left of the first ‘1’ from the right
OR
Example:
Number:
1’s Comp.:
10110000 10110000
01001111
+ 1
01010000 01010000
31 /
45
Negative Numbers
Computers Represent Information in ‘0’s and ‘1’s
‘+’ and ‘−’ signs have to be represented in ‘0’s and ‘1’s
3 Systems
Signed Magnitude
1’s Complement
2’s Complement
All three use the left-most bit to represent the sign:
‘0’ positive
‘1’ negative
32 /
45
Signed Magnitude Representation
Magnitude is magnitude, does not change with sign
S (Magnitude
(+3) 0 0 1 1 )2 (Binary)
10
(−3)10 ( 1 0 1 1 )2
0 0 1 1 (+3)10
+ 1 0 1 1 (−3)10
1 1 1 0 (−6)10
33 /
45
1’s Complement Representation
Positive numbers are represented in “Binary”
0 Magnitude (Binary)
Negative numbers are represented in “1’s Comp.”
(+3)10 (0 011)2
1 Code (1’s Comp.)
(−3)10 (1 100)2
There are 2 representations for ‘0’
(+0)10 (0 000)2
(−0)10 (1 111)2
34 /
45
1’s Complement Range
4-Bit Representation Decimal 1’s Comp.
4 +7 0111
2 = 16 Combinations
+6 0110
− 7 ≤ Number ≤ + 7 +5 0101
3 3
−2 +1 ≤ Number ≤ +2 − 1 +4 0100
n-Bit Representation +3 0011
n−1 n−1 +2 0010
−2 +1 ≤ Number ≤ +2 − 1 +1 0001
+0 0000
−0 1111
−1 1110
−2 1101
−3 1100
−4 1011
−5 1010
−6 1001
−7 1000
35 /
45
2’s Complement Representation
Positive numbers are represented in “Binary”
0 Magnitude (Binary)
Negative numbers are represented in “2’s Comp.”
(+3)10 (0 011)2
1 Code (2’s Comp.)
(−3)10 (1 101)2
There is 1 representation for ‘0’
(+0)10 (0 000)2
(−0)10 (0 000)2
36 /
45
2’s Complement Range
4-Bit Representation Decimal 2’s Comp.
4 +7 0111
2 = 16 Combinations
+6 0110
− 8 ≤ Number ≤ + 7 +5 0101
3 3
−2 ≤ Number ≤ + 2 − 1 +4 0100
n-Bit Representation +3 0011
n−1 n−1 +2 0010
−2 ≤ Number ≤ + 2 − 1 +1 0001
+0 0000
−1 1111
−2 1110
−3 1101
−4 1100
−5 1011
−6 1010
−7 1001
−8 1000
37 /
45
Number Representations
4-Bit Example
Unsigned Signed
1’s Comp. 2’s Comp.
Binary Magnitude
Range 0 ≤ N ≤ 15 -7 ≤ N ≤ +7 -7 ≤ N ≤ +7 -8 ≤ N ≤ +7
0 0 0
Positive
Binary Binary Binary Binary
1 1 1
Negative X
Binary 1’s Comp. 2’s Comp.
38 /
45
Binary Subtraction Using 1’s Comp. Addition
Change “Subtraction” to “Addition”
If “Carry” = 1
then add it to the (5)10 – (1)10 (5)10 – (6)10
LSB, and the result
is positive (+5)10 + (-1)10 (+5)10 + (-6)10
(in Binary)
If “Carry” = 0 0101 0101
then the result + 1110 + 1001
is negative
(in 1’s Comp.) 1 0011 0 1110
+
0100 1110
+4 −1 39 /
45
Binary Subtraction Using 2’s Comp. Addition
Change “Subtraction” to “Addition”
If “Carry” = 1
ignore it, and the (5)10 – (1)10 (5)10 – (6)10
result is positive
(in Binary) (+5)10 + (-1)10 (+5)10 + (-6)10
If “Carry” = 0
then the result 0101 0101
is negative + 1111 + 1010
(in 2’s Comp.)
1 0100 0 1111
+4 −1
40 /
45
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
Chapter 1 41
Non-numeric Binary Codes
Chapter 1 42
Number of Elements Represented
Chapter 1 43
DECIMAL CODES - Binary Codes for Decimal Digits
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 1 100 1111 1000
Chapter 1 44
Binary Coded Decimal (BCD)
Chapter 1 45
Excess 3 Code and 8, 4, –2, –1 Code
Chapter 1 46
Warning: Conversion or Coding?
Do NOT mix up conversion of a decimal number to a binary
number with coding a decimal number with a BINARY CODE.
Chapter 1 47
ALPHANUMERIC CODES - ASCII Character Codes
49
ASCII Properties
ASCII has some interesting properties:
Digits 0 to 9 span Hexadecimal values 3016 to 3916.
Upper case A-Z span 4116 to 5A16 .
Lower case a -z span 6116to 7A16.
• Lower to upper case translation (and vice versa)
occurs byflipping bit 6.
Delete (DEL) is all bits set,a carryover from when
punched paper tape was used to store messages.
Punching all holes in a row erased a mistake!
Chapter 1 50
PARITY BIT Error-Detection Codes
Chapter 1 51
Error Detecting Codes
Parity
One bit added to a group of bits to make the total number of
‘1’s (including the parity bit) even or odd
Odd 1 0 1 1 1 0 1 0 0 0 0 0 1
Good for checking single-bit errors
0 0 1 1 1 1 1 0 0 0 0 0 1
52 /
45
Gray Code
One bit changes from Decimal Gray Binary
one code to the next 00 0000 0000
code 01 0001 0001
02 0011 0010
Different than Binary 03 0010 0011
04 0110 0100
05 0111 0101
06 0101 0110
07 0100 0111
08 1100 1000
09 1101 1001
10 1111 1010
11 1110 1011
12 1010 1100
13 1011 1101
14 1001 1110
15 1000 1111
53 / 45