slides

advertisement
Chapter 1
(1.1 through 1.6)
Digital Computers and
Information
Based on “Logic and Computer
Design Fundamentals”, by Mano
and Kime, Prentice Hall
CSE260-1-1
Announcements
 Homework problem set 1 will be posted
on the class website.
 Due: Wednesday 1/23/2013
CSE260-1-2
Overview: you will learn
 Information Representation
 Number Systems [binary, octal and
hexadecimal]
 Base Conversion
 Decimal Codes [BCD (binary coded
decimal)]
 Alphanumeric Codes
 Parity Bit
 Gray Codes
CSE260-1-3
1-1 INFORMATION REPRESENTATION in
Digital Systems- Signals
 Information variables represented by physical
quantities.
 For digital systems, the variables take on
discrete values.
 Two levels or binary values are the most
prevalent values in digital systems.
 Binary values are represented abstractly by:
•
•
•
•
digits 0 and 1
words (symbols) False (F) and True (T)
words (symbols) Low (L) and High (H)
and words Off and On.
CSE260-1-4
Signal Examples Over Time
Time
Analog
Digital
Asynchronous
Synchronous
with the clock
Continuous
in value &
time
Discrete in
value &
continuous
in time
Discrete in
value & time
CSE260-1-5
Advantage of Digital Circuit
 Immunity to noise
 Illustration:
Noise added
Receiver
Sender
Signal
Signal
CSE260-1-6
Immunity to noise: Noise Margin
VOH
NMH
Forbidden
VOL
NML
VIH
VIL
Threshold
Region
We cannot violate the Noise Margins, otherwise our digital assumption
is not valid: thus Vo must be > VOH or < VOL.
CSE260-1-7
Binary Values: Other Physical Quantities
 What are other physical quantities
represent 0 and 1?
• Logic Gates, CPU: Voltage
• Disk
Magnetic Field Direction
• CD
Surface Pits/Light
• Dynamic RAM
Electrical Charge
CSE260-1-8
1-2 Number Systems
 Positive radix, positional number systems
 Examples:
• Decimal (radix r =10)
Ex: 24.3 = 2x101 + 4x100+3x10-1
• Binary (radix r =2)
Digits (0-9)
Ex: 1101.01 = ( . )10
• Octal (radix r = )
• Hexadecimal (r =
Bits (0-1)
)
Digits: 1,2,…9, A, B, C, D, E, F
CSE260-1-9
Exercise
 (146.A)16 = ( ? )10
 (247.4)8 = ( ? )10
CSE260-1-10
Powers of 2: 2n
It will be convenient to remember these powers
2n
n
0
1
2
3
4
5
6
7
8
9
10
1
2
4
8
16
32
64
128
256
512
1024
2n
n
-1
-2
-3
0.5
0.25
0.125
CSE260-1-11
Special Powers of 2
 210 (=1024) is Kilo, denoted "K"
 220 (=1,048,576) is Mega, denoted "M"
 230 (1,073, 741,824) is
?
Giga,
denoted "G"
 240 (1,099,511,627,776 ) is Tera, denoted “T"
•Note: 8 bits (b) are also called a byte (B)
Exercise: what is (1111 1111)2 equal to in decimal?
Also what is the maximum number (in decimal) a
two bytes long word can represent?
CSE260-1-12
Range of numbers
 Binary number: ex. a 3-bit number: n=3
• 000, 001 … ,111
or in decimal system: 0, 1 … 7
 Total of 8 numbers (=23)
 Range: from 0 to 7 (0 to 23-1)
• In general a n-bit number represents:
 2n different numbers
 Min: 0
 Max number: 2n-1
 For fractions: m bits after the radix point:
• Min: 0
• Max number:
(2m -1)/2m
CSE260-1-13
Exercise
 16 Gbyte (= 16 GB) of memory
• How many (address) bits are required to
address each byte?
CSE260-1-14
Exercise
 Digital camera has 2048x2048 pixels,
and each pixel stores 8 bits of
information:
• a. How many Mega pixels?
• b. How many bits are stored per frame?
• c. How many different intensity levels can
be represented by each pixel?
CSE260-1-15
Use of HEX system
 Short hand notation of large binary numbers:
• Each HEX digits can be represented by exactly 4 bits
•
(16=24)
Thus (10011110.0101)2
9
E .
5
Conversion from binary to HEX and HEX to binary is
very easy:
(10011101)2 = (
)16
(1010110110.11)2 = (
B39.716 = (
)2
)16
CSE260-1-16
Octal system
 Radix r = 8
 8 digits:
• 0, 1, 2,…7
 Ex: 2758 = 2x82 + 7x8 + 5x1 = 128 + 56 + 5
= 18910
 Each octal digit can be represented by 3 bits
CSE260-1-17
1-3 Conversion Between Bases
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
CSE260-1-18
Conversion from Decimal to new Radix
 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.
 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, …
CSE260-1-19
Example: convert (325.65)10 to hex
 Integer part: 32510 = (
325/16 = 20 and rem = 5
20/16 = 1 and rem = 4
1/16 = 0 and rem = 1
 Fractional part: .65
. )16
Least significant digit
Most significant
Thus 32510 = 14516
0.65x16 = 10.4 thus int = 10= A Most significant
0.4x16 = 6.4 thus int = 6
0.4x16 = 6.4 thus int = 6
Least significant
Etc.
Thus .6510 = A6616
325.6510 = 145.A6616
CSE260-1-20
Example: Convert 54.687510 To Base 2
 Convert 54 to Base 2
 Convert 0.6875 to Base 2:
 Join the results together with the
radix point:
CSE260-1-21
Conversions from Binary to Octal and
Hexadecimal
Grouping in groups of 3 or 4 bits
Convert 10001011 into octal and hexadecimal:
Octal:
10001011
2 1
38
Hexadecimal
10001011
8
B16
CSE260-1-22
Octal to Hexadecimal via Binary
Conversion from Octal to Hexadecimal and vice versa
Convert 2138 into an hexadecimal number:
2138
10001011
8 B16
CSE260-1-23
Exercise: Octal
Hexadecimal
 Exercise: Hexadecimal to Octal:
3A.5 16 = (
)8
 Octal to Binary to Hexadecimal
6 3 5.1778 = (
)16
CSE260-1-24
Conversion - Summary
Divisions (or x) by 16
Ai.16i
Decimal
SAi.2i
Binary
 Ai.8i
Group in
bits of 3
Hexadecimal
Group in
bits of 4
Octal Hex:
through the binary
representation
Octal
CSE260-1-25
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:
Carry in (Z) of 1:
Z
X
+Y
0
0
+0
0
0
+1
0
1
+0
0
1
+1
CS
00
01
01
10
Z
X
+Y
1
0
+0
1
0
+1
1
1
+0
1
1
+1
CS
01
10
10
11
CSE260-1-26
Multiple Bit Binary Addition
 Extending this to two multiple bit
examples:
Carries
Augend
Addend
Sum
0
0
01100 10110
+10001 +10111
 Note: The 0 is the default Carry-In to
the least significant bit.
CSE260-1-27
Multiple Bit Binary Subtraction
 Extending this to two multiple bit examples:
0
0
Minuend
10110 10110
Subtrahend - 10010 - 10011
Borrows
Difference
 Notes: The 0 is a Borrow-In to the least
significant bit. If the Subtrahend > the
Minuend, interchange and append a – to the
result.
CSE260-1-28
1-4 Binary Codes
 A n-bit binary code is a n-bit word
which can represent up to 2n
different elements.
 Example: 3-bit code can represent
up to 8 different elements”
CSE260-1-29
Binary Codes
 Example: A
binary code
for the seven
colors of the
rainbow
 Code 100 is
not used
Color
Red
Orange
Yellow
Green
Blue
Indigo
Violet
Binary Number
000
001
010
011
101
110
111
 Given n binary digits (called bits), a binary
code is a mapping from a set of represented
elements to a subset of the 2n binary
numbers or elements.
CSE260-1-30
Binary Coded Decimal (BCD)
 The BCD code is the 8,4,2,1 code.
 This code only encodes the first ten
values from 0 to 9.
 Each decimal digit is coded
separately by 4 bits
 Example:
• (325)10 = (0011 0010 0101)BCD
3
2
 Exercise: (856)10 = (
5
)BCD
CSE260-1-31
1-5 ALPHANUMERIC CODES - ASCII Character
Codes
 American Standard Code for Information
Interchange
 This code is a popular code used to
represent information sent as characterbased data. It uses 7-bits to represent:
• 94 Graphic printing characters.
• 34 Non-printing characters
 Some non-printing characters are used for
text format (e.g. BS = Backspace, CR =
carriage return)
CSE260-1-32
ASCII Code: B7B6B5 B4B3B2B1
H=(1001000)
CSE260-1-33
PARITY BIT Error-Detection Codes
 Redundancy (e.g. extra information), in the form of
extra bits, can be incorporated into binary code words
to detect and correct errors.
 A simple form of redundancy is parity, an extra bit
appended onto the code word in the most significant
position to make the number of 1’s odd or even. Parity
can detect all single-bit errors and some multiple-bit
errors.
A code word has even parity if the
number of 1’s in the code word is
even.
A code word has odd parity if the
number of 1’s in the code word is
odd.
TX
7
Parity bit
RX
CSE260-1-34
ASCII Parity Code Example
TX
7
Parity bit
Transmit Ha in ascii:
1001000 1100001
Transmit with even parity:
01001000 11100001
added parity bit
RX
At the receiver side:
If an even parity is
detected, send an
ACK control =
00000110
If error was detected
send negative
acknowledge NAK =
10010101
CSE260-1-35
1-6 GRAY CODE – Decimal
Binary
000
001 2 bit changes
010
011 2 bit changes
100
101 2 bit changes
110
111
Gray
000
001
011
010
110
111
101
100
Only 1 bit changes
CSE260-1-36
Download