Title: Q: How can you identify an extroverted engineer
1- Q How can you identify an extroverted engineer?
- A When he talks to you, he looks at your shoes
instead of his own.
2CSE 502NFundamentals of Computer Science
- Fall 2004
- Lecture 19
- Introduction to Computer Architecture
- Number Representations
3Whats 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
4Whats in a Computer?
Control movement of data between memory and I/O
devices
- External Cache
- small, fast memory
- stores recently used data
Memory Bus
5Whats 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
6Whats in a Chip?
- Photomicrographs made using colored filters.
7Representing 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
8Noise 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.
9Number 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)
10Decimal-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.
11Octal 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
12Binary Number Representations
- In all three systems, most significant bit
denotes the sign - 0 positive
- 1 negative
- Sign-and-Magnitude
- MSB is sign
- Remaining bits are binary magnitude
- Convert sign by inverting MSB
- 1s Compliment
- Convert sign by inverting all bits
- 2s Compliment
- Convert sign by inverting all bits and adding 1
13Finite 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.
14Representing Numbers Text
- Computers use numbers to represent alphabetic
characters, numerals and punctuation. - Binary Coded Decimal (BCD) encoding uses 4 bits
per decimal digit - Example 39610 0011 1001 0110
- 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 http//www.asciitable.com/ for details
- Unicode uses 16 bits per character, allowing it
to represent far more distinct characters.
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
- When using 2s compliment representation, signed
arithmetic is identical - Implement subtraction by negating the subtrahend
and adding to the minuend
17Basic Processor Memory
- Memory stores programs and data.
- organized as set of numbered storage slots
- each 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)
18Instruction 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
19Sample 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 (ACC MM0011) sum sum
pointer 0009 a010 (ACC ACCM0010) 000a 401
0 (M0010 ACC) 000b 1001 (ACC
0001) pointer pointer 1 000c a011 (ACC
ACCM0011) 000d 4011 (M0011
ACC) 000e 6004 (goto 0004) goto loop 000f
(end) 0000 (halt) halt 0010 Store sum
here 0011 Pointer to next value
20Execution of a Computer Program
reset(initialization)
systemclock
program counter,instruction register,
accumulator, . . .
timeaxis
monitoredsignals
waveforms buses
21Execution of a Computer Program
22Detailed Processor Diagram
23Processing Cycle
- Instruction fetch
- PC used to read word from memory
- PC is incremented
- Instruction decode
- first 4 bits of retrieved instruction are decoded
to determine what to do - appropriate circuitry activated
- Instruction execution
- retrieve additional memory words
- write to memory
- modify PC or ACC contents
- may take different amounts of time to complete
24Instruction Execution
- Direct Load
- transfer data from memory to ACC, using low 12
bits of instruction word as memory address - requires asserting of memory signals and loading
ACC - Conditional branch
- determine if ACC0 (or gt0 or lt0)
- if so, transfer low 12 bits of instruction word
to PC - Indirect store
- transfer data from memory to Indirect Address
Register (IAR) using low 12 bits of instruction
word as memory address - transfer data from ACC to memory, using IAR
contents as address - requires placing IAR value on address bus and
asserting signals to perform memory write
25Instruction Fetch
2. Memory contents on Dbus
5. Increment PC
3. Load IREG
1. PC value on Abus
1. mem_en 1
4. mem_en 0
26Add Instruction Execution
2. Memory contents on Dbus
3. ALU adds values
1. IREG value on Abus
4. Load sum into ACC
1. mem_en 1
5. mem_en 0