Title: Digital Computers and Information
1Digital Computers and Information
- Digital preview (W 1-23)
- Number representations (W 25-38)
- Arithmetic operations (W 39-47)
- Data encoding (W 48-53, 69-70)
- Processor organization and operation
2Whats in a Computer?
- Microprocessor
- Central Processing Unit
- Floating Point Unit
- Memory Mgmt. Unit
- Internal Cache Memory
- Main Memory
- stores running programs and associated data
- typically 128MB-2GB
- Dynamic RAM
3Whats in a Computer?
Control movement of data between memory and I/O
devices
- External Cache
- small, fast memory
- stores recently used data
Memory Bus
4Whats in a Computer?
Transfer data between external network memory
Peripheral Bus
Read/write data on proper physical location on
disk
Convert text graphics to video
5Whats in a Chip?
- Photomicrographs made using colored filters.
6Representing Information in Computers
- Electronic computers represent information as
voltage levels. - To make the computer hardware simple and
reliable, computers represent information in
binary form. - example voltages greater than 3V are interpreted
as representing one value (called 1), voltages
less than 2V are interpreted as representing
another value (called 0). - In principle, could use more voltage levels.
- example 0 to .75V represents 0, 1 to 1.75V
represents 1, 2 to 2.75V represents 2, and so
forth. - In practice, this is rarely done.
- requires more complex circuits
- circuits are more susceptible to noise, hence
less reliable
7Noise in Computer Systems
- Computers, like all electronic systems, are
affected by noise. - noise has various sources (nearby signal changes,
thermal vibrations of molecules in semiconductor
materials, . . . ) - in computers, noise can cause binary signals to
be misinterpreted - The noise margin is the amountof noise that a
system cantolerate and still correctlyidentify
a logic high or low.
8Number Representation
- Standard decimal number representation
- 243.83 2102 4101 3100 810-1 310-2
- Generalization to base r
- An. . .A1A0.A-1 . . .A-m
- Anrn . . . A1r1 A0r0 A-1r-1 . . .
A-mr-m - Binary number representation
- 110.01 122 121 020 02-1 12-2
- Converting binary numbers to decimal (easy).
- write binary expansion, replace powers of 2 with
decimal values, and add up the values - 110.01 122 121 020 02-1 12-2 4
2 1/4 - 6.25
- Note it helps to know your powers of 2 (hint)
9Decimal-Binary Conversion
- Repeated division by 2
- 625/2 312 with remainder of 1 least
significant bit - 312/2 156 with remainder of 0
- 156/2 78 with remainder of 0
- 78/2 39 with remainder of 0
- 39/2 19 with remainder of 1
- 19/2 9 with remainder of 1
- 9/2 4 with remainder of 1
- 4/2 2 with remainder of 0
- 2/2 1 with remainder of 0
- 1/2 0 with remainder of 1
- So, (625)10 (10 0111 0001)2
- Why does this work?
- Works similarly for other number bases.
10Octal and Hexadecimal
- Octal (base 8) and hexadecimal (base 16) provide
more convenient way for people to write binary
numbers. - 110101100010 110 101 100 010 (6542)8
1101 0110 0010 (d62)16 - octal conversion hexadecimal conversion000
0 0000 0 1000 8001 1 0001 1
1001 9010 2 0010 2 1010 10
a011 3 0011 3 1011 11 b100
4 0100 4 1100 12 c101 5 0101
5 1101 13 d110 6 0110 6 1110
14 e111 7 0111 7 1111 15 f
11Finite Data Representations
- Computer hardware is generally designed to
operate on words with a fixed number of bits
(e.g. 16 bits). - Places a limit on the number of discrete values
that can be stored in a single word (e.g. 216). - If we use words to represent positive integers
then with n bits, we can represent integers 0 up
to 2n-1 - Larger integers can be represented by multiple
words. - computer hardware operates on single words
- software must combine results from single word
operations to produce desired result - Or, use floating point representation for large
(and small) values typically supported by
computer hardware.
12How Computers Add
- Binary long addition similar to decimal long
addition. - decimal binary carry 1100 111100
- augend 2565 10110
- addend 6754 11011
- sum 9319 110001
- Binary addition algorithm - add an-1...a0 to
bn-1...b0 and put result in sn...s0 - c00 // ci are carry bits
- for i 0 to n-1
- if one or three of ai, bi or ci 1 then si1
else si 0 - if at least two of ai, bi or ci 1 then ci11
else ci10 - sn cn
13Modular and Signed Arithmetic
- Computers use modular arithmetic in which values
wrap around circularly. - to add AB, start at position for A and then
count clockwise B positions - think of modular arithmetic like clock
arithmetic - Finite representation can cause overflow.
- Associating certain bit patterns with negative
values yields signed arithmetic. - Negate a given value by flipping all bits and
adding 1. - Note different conditions for overflow.
142s Complement and Subtraction
- In 2s complement arithmetic with n bits
- the first bit represents the sign (0 for
positive, 1 for negative) - for positive numbers, the remaining n-1 bits give
the magnitude in standard binary notation - to convert a positive number to corresponding
negative number, flip all bits and add 1
(0011?110011101) - to convert a negative number to corresponding
positive number, flip all bits and add 1
(1101?001010011) - To subtract, take complement and add.
- 410-710 0100-0111 0100(-0111)
01001001 1101 -310 - 2s complement is most popular method for
representing negative numbers. - no special subtraction circuit, just addition,
complement
15Other Data Representations
- Computers use bit patterns to represent
alphabetic characters, numerals and punctuation. - Most common encoding is ASCII (American Standard
Code for Communication Interchange) - characters represented by 7 bit values
- numerals start at (30)16
- upper case letters start at (41)16
- lower case letters start at (61)16
- see Table 1-4 in Wakerly for details
- Unicode uses 16 bits per character, allowing it
to represent far more distinct characters. - Binary Coded Decimal (BCD) uses groups of four
bits to represent decimal values. - example 379 is represented as 0011 0111 1001
- simpler to convert to/from text formats
- in excess-3 variant, values offset by 3 (28 ?
0101 1011)
16Simple Processor and Memory
- Memory stores programs and data.
- organized as set of numbered memory words
- memory word can hold a 16 bit value
- processor can read from or write to any word
- Fetch execute cycle
- read word whose address is in Program Counter
(PC) and store it in Instruction Register (IREG)
then increment PC - perform instruction using Accumulator (ACC),
Arithmetic Logic Unit (ALU) and possibly
Indirect Address Register (IAR) - IREG, PC, IAR and ACC are all 16 bit registers.
- Controller coordinates actions of other
components. - Data Address Buses carry data between
components.
17Instruction Set
0000 halt halt execution 0001 negate ACC
ACC 1xxx immediate load if sign bit of xxx is
0 then ACC 0xxx else ACC fxxx 2xxx direct
load ACC M0xxx 3xxx indirect load ACC
MM0xxx 4xxx direct store M0xxx
ACC 5xxx indirect store MM0xxx
ACC 6xxx branch PC 0xxx 7xxx branch if zero
if ACC 0 then PC 0xxx 8xxx branch if
positive if ACC gt 0 then PC 0xxx 9xxx branch
if negative if ACC lt 0 then PC 0xxx axxx add
ACC ACC M0xxx
18Simple Program
- Add the values in locations 20-2f and write sum
in 10.
Address Instruction Comment 0000 (start) 1000
(ACC 0000) initialize sum 0001 4010 (M0010
ACC) 0002 1020 (ACC 0020) initialize
pointer 0003 4011 (M0011 ACC) 0004
(loop) 1fd0 (ACC 0030) if pointer 030,
quit 0005 a011 (ACC ACCM0011) 0006 700e
(if 0 goto end) 0007 3011 (ACC MM0011)
sum sum pointer 0008 a010 (ACC
ACCM0010) 0009 4010 (M0010
ACC) 000b 1001 (ACC 0001) pointer
pointer 1 000b a011 (ACC ACCM0011) 000c
4011 (M011 ACC) 000d 6004 (goto 0004)
goto loop 000e (end) 0000 (halt) halt 0010
Store sum here 0011 Pointer to next value
19Convert Numeric String to Internal Value
- ASCII character codes for decimal integer stored
in locations 20-24 with M.S.D. at location 20.
Write internal value in location 1f.
Address Instruction Comment 0000 (start) 1000
(ACC 0000) result 0 0001 401f (M001f
ACC) 0002 1020 (ACC 0020) pointer
020 0003 401d (M001d ACC) 0004 (loop) 1025
(ACC 0025) if pointer025 then
quit 0005 0001 (ACC ACC) 0006 a01d (ACC
ACC M001d) 0007 7015 (if 0 goto
0015) 0008 100a (ACC 000a) result
10result 0009 b01f (ACC ACCM001f) New
multiply inst. 000a 401f (M001f ACC)
20Convert Numeric String (continued)
Address Instruction Comment 000b 1fd0
(ACC -30) result result (pointer-0)
000c 401e (M001e ACC) 000d
301d (ACC MM001d) 000e a01e
(ACC ACCM001e) 000f a01f (ACC
ACCM001f) 0010 401f (M001f ACC)
0011 1001 (ACC 0001)
pointerpointer1 0012 a01d (ACC
ACCM001d) 0013 401d (M001d ACC)
0014 6004 (goto 0004) goto loop 0015
(end) 0000 (halt) halt ... 001d Pointer
to next character 001e Temporary value
001f Store result here 0020 ASCII
digits
21Convert Internal Value to Numeric String
- Write ASCII character codes for value in location
1f into words 20..24 with L.S.D. in word 20. - pointer 20
- loop if pointer 25 then quit
- pointer (value modulo 10) 0
- value value / 10
- pointer pointer 1
- goto loop
- Exercise write corresponding machine program
assume two new instructions - cxxx divide value in accumulator by value in
location xxx and leave quotient in accumulator - dxxx divide by value in xxx put remainder
in ACC
22Execution of a Computer Program
reset(initialization)
systemclock
program counter,instruction register,
accumulator, . . .
timeaxis
monitoredsignals
waveforms buses
23Execution of a Computer Program