Title: Digital Computers and Information
1Digital Computers and Information
- Digital computers
- Number representations
- Arithmetic operations
- Alphanumeric codes
Read MK 3-26
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 64-512 Mbytes
- 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.
6Basic Processor Memory
- Memory stores programs and data.
- organized as set of numbered storage slots
- each storage slot (memory word) can hold a number
- processor can read from or write to any word
- Fetch execute cycle
- read word whose address is in Program Counter
(PC) and increment PC - interpret stored value as instruction (decoding)
- perform instruction using Accumulator (ACC) and
Arithmetic Logic Unit (ALU)
7Instruction 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
8Simple 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) 1030 (ACC 0030) if pointer 030,
quit 0005 0001 (ACC -ACC) 0006 a011 (ACC
ACCM0011) 0007 700f (if 0 goto
000f) 0008 3011 (MM0011 ACC) sum sum
pointer 0009 a010 (ACC ACCM0010) 000a 4010
(M0010 ACC) 000b 1001 (ACC
0001) pointer pointer 1 000c a011 (ACC
ACCM0011) 000d 4011 (M011
ACC) 000e 6004 (goto 0004) goto loop 000f
(end) 0000 (halt) halt 0010 Store sum
here 0011 Pointer to next value
9Representing 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
10Noise 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.
11Number 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)
12Decimal-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
- Works similarly for other number bases.
13Octal 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 conversion 000
0 0000 0 1000 8 001 1 0001 1
1001 9 010 2 0010 2 1010 10
a 011 3 0011 3 1011 11 b 100
4 0100 4 1100 12 c 101 5 0101
5 1101 13 d 110 6 0110 6
1110 14 e 111 7 0111 7 1111 15
f
14Finite 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.
15How 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 are 1 then si
1 else si 0 - if at least two of ai, bi or ci are 1, then
ci1 1 else ci1 0 - sn cn
16Modular 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 - modular arithmetic is just like clock arithmetic
- Associating certain bit patterns with negative
values yields signed arithmetic. - Negate a given value by flipping all bits and
adding 1. - Must pay attention to overflow.
17Representing Text
- Computers use numbers 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 Mano for details
- Unicode uses 16 bits per character, allowing it
to represent far more distinct characters.
18Convert 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 pointer 025, quit 0005 0001
(ACC -ACC) 0006 a01d (ACC ACC
M001d) 0007 7015 (if 0 goto 0015) 0008 100a
(ACC 000a) result 10 result 0009 b01f
(ACC ACCM001f) New multiply
inst. 000a 401f (M001f ACC)
19Convert Numeric String (continued)
Address Instruction Comment 000b 1fd0
(ACC -30) result result 000c 401e
(M001e ACC) (pointer-0) 000d
301d (ACC MM001d) 000e a01e (ACC
ACCM001e) 000f a01f (ACC
ACCM001f) 0010 401f (M001f ACC)
0011 1001 (ACC 0001) pointer pointer
1 0012 a01d (ACC ACCM001d) 0013
401d (M001d ACC) 0014 6004 (goto
0004) goto loop 0015 (end) 0000 (halt) halt
.... 001d Pointer to next char
001e Temporary value 001f Store result
here 0020 ASCII digits
20Convert 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
21Another Look at Basic Computer
- Program Counter (PC) stores address of next
instruction. - Instruction Register Decoder (IREG) stores
current instruction. - Indirect Address Register (IAR) stores indirect
addresses. - Accumulator (ACC) stores arithmetic operands and
results. - Arithmetic Logic Unit (ALU) implements
arithmetic functions. - Controller coordinates actions of other
components. - Data Address Buses carry data between
components.
22Execution of a Computer Program
reset(initialization)
systemclock
program counter,instruction register,
accumulator, . . .
timeaxis
monitoredsignals
waveforms buses
23Execution of a Computer Program