Title: CoE EE 00142 Computer Organization Set 9 Memory
1CoE - EE 00142Computer OrganizationSet 9 Memory
2Five Computer Components
3Memory and Storage
- We have already seen memory
- Registers, program memory, etc.
- Lots of kinds
- Primary memory
- Cache
- Hard disks
- Removable disks, floppy
- Optical - CDROM
- Tapes
- etc.
4Memory Hierarchy
5Memory Hierarchy
6Basic Computer Organization
7Memory Hierarchy
Data typically transferred a block at a time
Fig 7.2
8Speed Size - Cost
Fig 7.1
9Memory Tradeoff
10Size Distance From CPU
Fig 7.3
11Example Memory Structure
12Internal Computer Memory
- Two basic styles - RAM and ROM
- RAM - Random Access Memory
- Read and Write
- ROM - Read Only Memory
- PLD, PLA, CPLD, FPGA
13Original Core Memory
14Properties of RAM Memory
- Static RAM - SRAM
- Essentially a latch or FF
- Dynamic RAM - DRAM
- Uses charge on capacitor
- Needs refreshing
- Both are volatile
- i.e. lose stored information when power is removed
15Main Memory Block Diagram
Graphics from Logic and Computer Design
Fundamentals, Mano Kime, Prentice Hall
16Example 1024X16 Memory
1024 x 16 words x bits
17Example Number Storage
- Suppose that we want to store the 32-bit
hexadecimal value 12345678, and that it is to
stored in a 32-bit word in byte-addressed memory
starting in location 184. The word will require
4 bytes with the least significant byte
containing 78 and the most significant byte
containing 12.
18Memory Data Byte OrderingThree Ways
- Little-endian
- Big-endian
- Bi-endian
19Byte Ordering Example
value 12345678
Little-endian
Big-endian
Intel x86, Vax
Motorola, Sun, RISC
20Bi-endian
- In a bi-endian machine, the data can be stored in
either direction. The actual direction is
determined by the operating system, but once
established, all data is stored in the same
direction. - Power PC is example
21Memory Size
- Words or Bytes, typically bytes
- Measured in K, M, or G
- K - kilo - 210 1,024
- M - meg - 220 1,048,576
- G - gig - 230 1,073,741,824
- For example 64K 26 210 216
22Basic Static RAM Cell Model
Graphics from Logic and Computer Design
Fundamentals, Mano Kime, Prentice Hall
23RAM Bit Slice Model
Graphics from Logic and Computer Design
Fundamentals, Mano Kime, Prentice Hall
24Address Decoder
25Example Address Decoder
26RAM Bit Slice Model Symbol
Graphics from Logic and Computer Design
Fundamentals, Mano Kime, Prentice Hall
2716 - Word by 1 - Bit Chip
Graphics from Logic and Computer Design
Fundamentals, Mano Kime, Prentice Hall
28Three State Buffer
When EN 1, output input When EN 0, output
Hi Impedance
Allows you to connect 64K single bit
lines together without worrying about
loading Also allows connection to BUS
Graphics from Logic and Computer Design
Fundamentals, Mano Kime, Prentice Hall
29Consider a two dimensional memory selection
3016 X 1 RAM Using 4 X 4 Cell Array
Coincident Selection - use two k/2 input decoders
instead of one k input decoder
16 words by 1 bits but uses a row-column Coinciden
t Selection approach for addressing
Graphics from Logic and Computer Design
Fundamentals, Mano Kime, Prentice Hall
31Bit Plane Depiction of Memory
328X2 RAM using 4X4 Cell Array
Can also be arranged in other ways Same 16 bits
but arranged 8 words by 2 bits using a
row-column approach for addressing
Graphics from Logic and Computer Design
Fundamentals, Mano Kime, Prentice Hall
33Coincident Selection
- Improves speed
- Reduces complexity
- Example - a realistic 32K X 8
- Single decoder 15 inputs 32K outputs would need
32,800 gates - With two decoders (6 and 9) would need 608 gates
- Reduces gates (therefore improves speed) by
factor of 50
3464K X 8 RAM Chip
64K 216
Graphics from Logic and Computer Design
Fundamentals, Mano Kime, Prentice Hall
35256K X 8 RAM
256K 218
8 bit data
Graphics from Logic and Computer Design
Fundamentals, Mano Kime, Prentice Hall
36Alternatively - 64K X 16 RAM
16 bit data
Graphics from Logic and Computer Design
Fundamentals, Mano Kime, Prentice Hall
37RAM Conclusions
- Typically constructed in arrays
- Fabricated as chips
- Can be arranged in several forms
- Depending on machine configuration
- Main working memory of computer
- Used to hold programs and data
38Error Detection and Correction
- Used to check if data was written/read correctly
- or if data is transmitted correctly - Parity check - simplest
- even or odd
- Hamming code - more complex
- Detect and correct errors
39Even or Odd Parity
- 50/50 chance of detection
- Presumes one bit error most likely
- Detection only - no correction
40Even Parity Example
Data is on bits 1, 2, 3, 4, 5, 6, 7, 8
P XOR of bits (1, 2, 3, 4, 5, 6, 7, 8) 0 ? 1
? 1 ? 1 ? 1 ? 0 ? 0 ? 1 1
This is what is transmitted or stored
41Even Parity Example
If read correctly
P XOR of bits (1, 2, 3, 4, 5, 6, 7, 8, 9) 0 ?
1 ? 1 ? 1 ? 1 ? 0 ? 0 ? 1 ? 1 0
42Even Parity Example
If read incorrectly (error in bit 2 from a 1 to 0)
P XOR of bits (1, 2, 3, 4, 5, 6, 7, 8, 9) 0 ?
0 ? 1 ? 1 ? 1 ? 0 ? 0 ? 1 ? 1 1
But it is not clear where the error occurred
43Hamming Codes
- Error detection and correction
- Presumes one bit error most likely
- Detects error and position
- therefore allows for correction
44Hamming Code Example
Data is on bits 3, 5, 6, 7, 9, 10, 11, 12
P1 XOR of bits (3, 5, 7, 9, 11) 1 ? 1 ? 0 ? 0
? 0 0 P2 XOR of bits (3, 6, 7, 10, 11) 1 ?
0 ? 0 ? 1 ? 0 0 P4 XOR of bits (5, 6, 7, 12)
1 ? 0 ? 0 ? 0 1 P8 XOR of bits (9, 10, 11,
12) 0 ? 1 ? 0 ? 0 1
This is what is transmitted or stored
Note that parity bits are in power of 2 positions
45Hamming Code Example
If data received or read from memory is correct
4 check bits are evaluated as follows
C1 XOR of bits (1, 3, 5, 7, 9, 11) 0 ? 1 ? 1
? 0 ? 0 ? 0 0 C2 XOR of bits (2, 3, 6, 7, 10,
11) 0 ? 1 ? 0 ? 0 ? 1 ? 0 0 C4 XOR of bits
(4, 5, 6, 7, 12) 1 ? 1 ? 0 ? 0 ? 0 0 C8 XOR
of bits (8, 9, 10, 11, 12) 1 ? 0 ? 1 ? 0 ? 0 0
46Hamming Code Example
If data received or read from memory is not
correct
If read incorrectly (change bit 3 from a 1 to 0)
4 check bits are evaluated as follows
C1 XOR of bits (1, 3, 5, 7, 9, 11) 0 ? 0 ? 1
? 0 ? 0 ? 0 1 C2 XOR of bits (2, 3, 6, 7, 10,
11) 0 ? 0 ? 0 ? 0 ? 1 ? 0 1 C4 XOR of bits
(4, 5, 6, 7, 12) 1 ? 1 ? 0 ? 0 ? 0 0 C8 XOR
of bits (8, 9, 10, 11, 12) 1 ? 0 ? 1 ? 0 ? 0 0
0 0 1 1 Error in bit 3
47Programmable Logic Devices
- ROM - Read only memory
- PLA - Programmable logic array
- PAL - Programmable array logic
- CPLD - Complex programmable logic device
- FPGA - Field-programmable gate array
48Programmable Logic Devices
- All permanent
- Typically WORM
- write once - read many
- Typically use fuse, antifuse, or mask
- Sometimes erasable
49ROM - Read Only Memory
- Non volatile
- maintains information without power
- Typically programmed by
- blowing fuses
- masking
- Sometimes erasable - EPROM
- E2PROM electrically erasable
50Example ROM
5132 X 8 ROM Un-programmed
52Programmed ROM
Consider the above truth table or program
Note that this is how your BIOS is programmed
53Programmed ROM
Consider the above truth table or program
Note that A7 is 1 for combinations 0, 2, 3, 29
54Programmed ROM
Note that A7 is 1 for combinations 0, 2, 3, 29
Graphics from Logic and Computer Design
Fundamentals, Mano Kime, Prentice Hall
55Views of ROM
- Can be used to store program
- BIOS of computer
- Can be used as a combinational logic device
Note in previous example that A7 ?m (0, 2, 3,
29)
56Example ROM Logic Implementation
- Consider a circuit which inputs a 3-bit binary
number and which generates a binary number equal
to the square of that input number.
57Example Truth Table
Note output is square of input
58ROM Implementation
Graphics from Logic and Computer Design
Fundamentals, Mano Kime, Prentice Hall
59Views of ROM
- PROM - fixed ANDs and programmable ORs
- Used for sum of minterm implementations
- Example A7 ? m (0, 2, 3, 29)
- PAL - fixed ORs and programmable ANDs
- Used for product of maxterm implementations
- Example A7 ? M (1, 4, 5, 28, 30, 31)
- PLA - both ORs and ANDs programmable
60Configuration of PLD Devices
Graphics from Logic and Computer Design
Fundamentals, Mano Kime, Prentice Hall
61More Complex Devices
- VLSI Programmable Devices
- CPLDs - Complex programmable logic arrays
- FPGAs - Field programmable gate arrays
- Structure varies by manufacturer
62Memory Hierarchy - Disks, etc.
63Mass Storage Devices
- Typically involve physical motion
- Spin (disks) or slide (tape)
- Usually magnetic - hard disk, tape
- Sometimes optic - CDROM
- Involve three time-variables
- Seek time - to find track
- Latency time - to rotate to start of track
- Transfer time - to read/write data
64Disk Structure
65Typical Disk Layout
etc.
etc.
Typically tracks of data are buffered through a
disk cache
66Disk Storage Devices
- Transfer blocks of data or pages
- uses buffer or cache
- overlays blocks of main memory - pages
- appears as virtual memory
- Disk cache issues
- thrashing - program flips back and forth between
data on two different pages
67Disk Cache Concepts
- Disk cache issues
- Thrashing
- Virtual Memory
- Pages - Memory Blocks
- Page faults
68Virtual Memory
Fig 7.20
69Virtual Memory Mapping
Fig 7.21
70Cache Memory
- Fast memory
- Resides between devices
- Main memory and CPU
- Hard disk and main memory (buffering of pages)
- Sometimes between main memory and screen
71Typical Memory Hierarchy
72Multiple Cache Hierarchy
73Cache Memory
74Locality of Reference
- When executing an instruction
- Most other program instructions are local
- Most instructions are sequential
- Most data is local
- Most data is stored together (array)
- Key aspect of cache
75Principle of Locality
- Spatial locality - if we got word i from memory,
there is a good chance that we will want word i1
soon - Temporal locality - if we got word i once, then
we will probably want it again, soon
76Principle of Locality
- Therefore, if we copy a block of words into cache
when we need one (i i15), we will likely use
several before we need to do another copy - Eventually, we will have several non-contiguous
blocks of memory in cache
77Example Cache Scheme
78Direct Mapped Cache
Note address 00000 011
79Direct Mapped Cache
mod 8 cache
upper 2 add bits become tag
Fig 7.3
80Direct Mapped Cache
Fig 7.7
81Fully Associative Cache
82Cache Concepts
- Cache hit - processor reads or writes data and
finds it in cache - Cache miss - not in cache
- must go back to main memory
- get whole block in process
- Data write
- write-through (both cache memory)
- write-back (only cache)
83Cache Memory
84Memory Speed - Cost
85End of Set