Chapter 5. The Memory System. Overview Basic memory circuits Organization of the main memory Cache memory concept Virtual memory mechanism Secondary storage.

Slides:



Advertisements
Similar presentations
MEMORY popo.
Advertisements

Chapter 9 Memory Basics Henry Hexmoor1. 2 Memory Definitions  Memory ─ A collection of storage cells together with the necessary circuits to transfer.
1  1998 Morgan Kaufmann Publishers Chapter Seven Large and Fast: Exploiting Memory Hierarchy.
1 COMP 206: Computer Architecture and Implementation Montek Singh Mon, Oct 31, 2005 Topic: Memory Hierarchy Design (HP3 Ch. 5) (Caches, Main Memory and.
1 Pertemuan 17 Internal Memory: I Matakuliah: T0324 / Arsitektur dan Organisasi Komputer Tahun: 2005 Versi: 1.
Memory Organization.
Registers  Flip-flops are available in a variety of configurations. A simple one with two independent D flip-flops with clear and preset signals is illustrated.
Memory It’s all about storing bits--binary digits
©UCB CS 162 Ch 7: Virtual Memory LECTURE 13 Instructor: L.N. Bhuyan
1 Lecture 14: Virtual Memory Today: DRAM and Virtual memory basics (Sections )
1 The Memory System (Chapter 5)
1  1998 Morgan Kaufmann Publishers Chapter Seven Large and Fast: Exploiting Memory Hierarchy (Part II)
Chapter 5. The Memory System
VIRTUAL MEMORY. Virtual memory technique is used to extents the size of physical memory When a program does not completely fit into the main memory, it.
Cache Memories Effectiveness of cache is based on a property of computer programs called locality of reference Most of programs time is spent in loops.
CH05 Internal Memory Computer Memory System Overview Semiconductor Main Memory Cache Memory Pentium II and PowerPC Cache Organizations Advanced DRAM Organization.
Chapter 5-1 Memory System
Topics covered: Memory subsystem CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
Computer Architecture Lecture 28 Fasih ur Rehman.
Basic concepts Maximum size of the memory depends on the addressing scheme: 16-bit computer generates 16-bit addresses and can address up to 216 memory.
1 CSCI 2510 Computer Organization Memory System I Organization.
Fundamental Concepts.  Maximum size of the Main Memory  byte-addressable  CPU-Main Memory Connection Up to 2 k addressable MDR MAR k-bit address bus.
In1210/01-PDS 1 TU-Delft The Memory System. in1210/01-PDS 2 TU-Delft Organization Word Address Byte Address
EEE-445 Review: Major Components of a Computer Processor Control Datapath Memory Devices Input Output Cache Main Memory Secondary Memory (Disk)
Memory System Unit-IV 4/24/2017 Unit-4 : Memory System.
Memory and cache CPU Memory I/O. CEG 320/52010: Memory and cache2 The Memory Hierarchy Registers Primary cache Secondary cache Main memory Magnetic disk.
Tag Cache Main memory Block 0 Block 1 Block 127 Block 128 Block 129 Block 255 Block 256 Block 257 Block 4095 Block 0 Block 1 Block Main memory address.
+ CS 325: CS Hardware and Software Organization and Architecture Memory Organization.
Memory Cell Operation.
Computer system & Architecture
Fundamental Concepts.  Maximum size of the Main Memory  byte-addressable  CPU-Main Memory Connection Up to 2 k addressable MDR MAR k-bit address bus.
Computer Architecture Lecture 32 Fasih ur Rehman.
Computer Architecture Lecture 24 Fasih ur Rehman.
Introduction: Memory Management 2 Ideally programmers want memory that is large fast non volatile Memory hierarchy small amount of fast, expensive memory.
Multilevel Caches Microprocessors are getting faster and including a small high speed cache on the same chip.
1 CSCI 2510 Computer Organization Memory System II Cache In Action.
1 Chapter Seven CACHE MEMORY AND VIRTUAL MEMORY. 2 SRAM: –value is stored on a pair of inverting gates –very fast but takes up more space than DRAM (4.
Topics covered: Memory subsystem CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 5:
1 Memory Hierarchy (I). 2 Outline Random-Access Memory (RAM) Nonvolatile Memory Disk Storage Suggested Reading: 6.1.
1 Chapter Seven. 2 SRAM: –value is stored on a pair of inverting gates –very fast but takes up more space than DRAM (4 to 6 transistors) DRAM: –value.
Chapter 11 System Performance Enhancement. Basic Operation of a Computer l Program is loaded into memory l Instruction is fetched from memory l Operands.
Computer Architecture Lecture 25 Fasih ur Rehman.
CS 704 Advanced Computer Architecture
Chapter 7 The Memory System
CS 1251 Computer Organization N.Sundararajan
Memory Hierarchy Ideal memory is fast, large, and inexpensive
Computer Organization
Computer Organization
UNIT-IV Fundamental Concepts The Memory System.
The Memory System (Chapter 5)
Fundamental Concepts The Memory System.
Fundamental Concepts The Memory System.
Memory COMPUTER ARCHITECTURE
Yu-Lun Kuo Computer Sciences and Information Engineering
Memory and cache CPU Memory I/O.
Fundamental Concepts The Memory System.
Fundamental Concepts The Memory System.
Cache Memory Presentation I
Morgan Kaufmann Publishers Memory & Cache
Fundamental Concepts The Memory System.
Lecture 14 Virtual Memory and the Alpha Memory Hierarchy
Memory and cache CPU Memory I/O.
Fundamental Concepts The Memory System.
Fundamental Concepts The Memory System.
MICROPROCESSOR MEMORY ORGANIZATION
Fundamental Concepts The Memory System.
Chap. 12 Memory Organization
M. Usha Professor/CSE Sona College of Technology
Presentation transcript:

Chapter 5. The Memory System

Overview Basic memory circuits Organization of the main memory Cache memory concept Virtual memory mechanism Secondary storage

Some Basic Concepts

Basic Concepts The maximum size of the memory that can be used in any computer is determined by the addressing scheme. 16-bit addresses = 2 16 = 64K memory locations Most modern computers are byte addressable. 2 k 4-2 k 3-2 k 2-2 k 1-2 k 4-2 k k 1-2 k 2-2 k 3-2 k Byte address (a) Big-endian assignment(b) Little-endian assignment 4 Word address

Traditional Architecture Up to 2 k addressable MDR MAR Figure 5.1. Connection of the memory to the processor. k-bit address bus n-bit data bus Control lines (, MFC, etc.) Processor Memory locations Word length =n bits WR/

Basic Concepts “Block transfer” – bulk data transfer Memory access time Memory cycle time RAM – any location can be accessed for a Read or Write operation in some fixed amount of time that is independent of the location’s address. Cache memory Virtual memory, memory management unit

Semiconductor RAM Memories

Internal Organization of Memory Chips FF Figure 5.2. Organization of bit cells in a memory chip. circuit Sense / Write Address decoder FF CS cells Memory circuit Sense / Write circuit Data input/output lines: A 0 A 1 A 2 A 3 W 0 W 1 W 15 b 7 b 1 b 0 WR/ b 7 b 1 b 0 b 7 b 1 b 0 16 words of 8 bits each: 16x8 memory org.. It has 16 external connections: addr. 4, data 8, control: 2, power/ground: 2 1K memory cells: 128x8 memory, external connections: ? 19( ) 1Kx1:? 15 ( )

A Memory Chip Figure 5.3. Organization of a 1K  1 memory chip. CS Sense/Write circuitry array memory cell address 5-bit row input/output Data 5-bit decoder address 5-bit column address 10-bit output multiplexer 32-to-1 input demultiplexer 32  WR/ W 0 W 1 W 31 and

Static Memories The circuits are capable of retaining their state as long as power is applied. YX Word line Bit lines Figure 5.4. A static RAM cell. b T 2 T 1 b

Static Memories CMOS cell: low power consumption

Asynchronous DRAMs Static RAMs are fast, but they cost more area and are more expensive. Dynamic RAMs (DRAMs) are cheap and area efficient, but they can not retain their state indefinitely – need to be periodically refreshed. Figure 5.6. A single-transistor dynamic memory cell T C Word line Bit line

A Dynamic Memory Chip Column CS Sense / Write circuits cell array latch address Row Column latch decoder Row decoder address  R/W A 209- A 80-  D 0 D 7 RAS CAS Figure 5.7. Internal organization of a 2M  8 dynamic memory chip. Row Addr. Strobe Column Addr. Strobe

Fast Page Mode When the DRAM in last slide is accessed, the contents of all 4096 cells in the selected row are sensed, but only 8 bits are placed on the data lines D 7-0, as selected by A 8-0. Fast page mode – make it possible to access the other bytes in the same row without having to reselect the row. A latch is added at the output of the sense amplifier in each column. Good for bulk transfer.

Synchronous DRAMs The operations of SDRAM are controlled by a clock signal. R/W RAS CAS CS Clock Cell array latch address Row decoder Row Figure 5.8. Synchronous DRAM. decoder Column Read/Write circuits & latches counter address Column Row/Column address Data input register Data output register Data Refresh counter Mode register and timing control

Synchronous DRAMs R/W RAS CAS Clock Figure 5.9. Burst read of length 4 in an SDRAM. RowCol D0D1D2D3 Address Data

Synchronous DRAMs No CAS pulses is needed in burst operation. Refresh circuits are included (every 64ms). Clock frequency > 100 MHz Intel PC100 and PC133

Latency and Bandwidth The speed and efficiency of data transfers among memory, processor, and disk have a large impact on the performance of a computer system. Memory latency – the amount of time it takes to transfer a word of data to or from the memory. Memory bandwidth – the number of bits or bytes that can be transferred in one second. It is used to measure how much time is needed to transfer an entire block of data. Bandwidth is not determined solely by memory. It is the product of the rate at which data are transferred (and accessed) and the width of the data bus.

DDR SDRAM Double-Data-Rate SDRAM Standard SDRAM performs all actions on the rising edge of the clock signal. DDR SDRAM accesses the cell array in the same way, but transfers the data on both edges of the clock. The cell array is organized in two banks. Each can be accessed separately. DDR SDRAMs and standard SDRAMs are most efficiently used in applications where block transfers are prevalent.

Structures of Larger Memories Figure Organization of a 2M  32 memory module using 512K  8 static memory chips. 19-bit internal chip address decoder 2-bit addresses 21-bit A 0 A 1 A 19 memory chip A 20 D D 7-0 D D K8  Chip select memory chip 19-bit address 512K8  8-bit data input/output

Memory System Considerations The choice of a RAM chip for a given application depends on several factors: Cost, speed, power, size… SRAMs are faster, more expensive, smaller. DRAMs are slower, cheaper, larger. Which one for cache and main memory, respectively? Refresh overhead – suppose a SDRAM whose cells are in 8K rows; 4 clock cycles are needed to access each row; then it takes 8192×4=32,768 cycles to refresh all rows; if the clock rate is 133 MHz, then it takes 32,768/(133×10 -6 )=246×10 -6 seconds; suppose the typical refreshing period is 64 ms, then the refresh overhead is 0.246/64=0.0038<0.4% of the total time available for accessing the memory.

Memory Controller Processor RAS CAS R/W Clock Address Row/Column address Memory controller R/W Clock Request CS Data Memory Figure Use of a memory controller.

Read-Only Memories

Read-Only-Memory Volatile / non-volatile memory ROM PROM: programmable ROM EPROM: erasable, reprogrammable ROM EEPROM: can be programmed and erased electrically Not connected to store a 1 Connected to store a 0 Figure A ROM cell. Word line P Bit line T

Flash Memory Similar to EEPROM Difference: only possible to write an entire block of cells instead of a single cell Low power Use in portable equipment Implementation of such modules Flash cards Flash drives

Speed, Size, and Cost Processor Primary cache Secondary cache Main Magnetic disk memory Increasing size Increasing speed Figure Memory hierarchy. secondary memory Increasing cost per bit Registers L1 L2

Cache Memories

Cache What is cache? Why we need it? Locality of reference (very important) - temporal - spatial Cache block – cache line A set of contiguous address locations of some size Page 315

Cache Replacement algorithm Hit / miss Write-through / Write-back Load through Figure Use of a cache memory. Cache Main memory Processor

30 / 19 Memory Hierarchy CPU Cache Main Memory I/O Processor Magnetic Disks Magnetic Tapes

31 / 19 Cache Memory High speed (towards CPU speed) Small size (power & cost) CPU Cache (Fast)  Cache Main Memory (Slow)  Mem Hit Miss 95% hit ratio  Access = 0.95  Cache  Mem

32 / 19 Cache Memory CPU Cache 1 Mword Main Memory 1 Gword 30-bit Address Only 20 bits !!!

33 / 19 Cache Memory Cache Main Memory FFFFFFF FFFFF Address Mapping !!!

Direct Mapping tag Cache Main memory Block 0 Block 1 Block 127 Block 128 Block 129 Block 255 Block 256 Block 257 Block 4095 Block 0 Block 1 Block Main memory address TagBlockWord Figure Direct-mapped cache. 5 4: one of 16 words. (each block has 16=2 4 words) 7: points to a particular block in the cache (128=2 7 ) 5: 5 tag bits are compared with the tag bits associated with its location in the cache. Identify which of the 32 blocks that are resident in the cache (4096/128). Block j of main memory maps onto block j modulo 128 of the cache

35 / 19 Direct Mapping Cache 0 1 A C C Address 000 Tag 0 1 A 6 Data Compare Match No match 10 Bits (Tag) 16 Bits (Data) FFFFF 20 Bits (Addr) What happens when Address =

36 / 19 Direct Mapping with Blocks Cache 0 1 A C C A 0 B C Address 000 Tag 0 1 A 6 Data Compare Match No match 10 Bits (Tag) 16 Bits (Data) FFFFF 20 Bits (Addr) Block Size = 16

Direct Mapping 74Main memory address TagBlockWord 5 Tag: Block: =127, in the 127 th block of the cache Word:1100=12, the 12 th word of the 127 th block in the cache 11101, ,1100

Associative Mapping 4 tag Cache Main memory Block 0 Block 1 Blocki Block 4095 Block 0 Block 1 Block Main memory address Figure Associative-mapped cache. TagWord 4: one of 16 words. (each block has 16=2 4 words) 12: 12 tag bits Identify which of the 4096 blocks that are resident in the cache 4096=2 12.

39 / 19 Associative Memory Cache FFFFF Main Memory FFFFFFF Address (Key) Data Cache Location

40 / 19 Associative Mapping Cache 0 1 A C C Bits (Key) 16 Bits (Data) 0 1 A 6 Data Address Can have any number of locations How many comparators?

Associative Mapping Tag: Word:1100=12, the 12 th word of a block in the cache , Main memory address TagWord

Set-Associative Mapping tag Cache Main memory Block 0 Block 1 Block 63 Block 64 Block 65 Block 127 Block 128 Block 129 Block 4095 Block 0 Block 1 Block 126 tag Block 2 Block 3 tag Block 127 Main memory address664 TagSetWord Set 0 Set 1 Set 63 Figure Set-associative-mapped cache with two blocks per set. 4: one of 16 words. (each block has 16=2 4 words) 6: points to a particular set in the cache (128/2=64=2 6 ) 6: 6 tag bits is used to check if the desired block is present (4096/64=2 6 ).

43 / 19 Set-Associative Mapping Cache 0 1 A C C Address 000 Tag1 0 1 A 6 Data1 Compare Match 10 Bits (Tag) 16 Bits (Data) FFFFF 20 Bits (Addr) Tag Data2 Compare 10 Bits (Tag) 16 Bits (Data) 2-Way Set Associative No match

Set-Associative Mapping Tag: Set: =63, in the 63 th set of the cache Word:1100=12, the 12 th word of the 63th set in the cache Main memory address664 TagSetWord ,111111,1100

Replacement Algorithms Difficult to determine which blocks to kick out Least Recently Used (LRU) block The cache controller tracks references to all blocks as computation proceeds. Increase / clear track counters when a hit/miss occurs

46 / 19 Replacement Algorithms For Associative & Set-Associative Cache Which location should be emptied when the cache is full and a miss occurs? First In First Out (FIFO) Least Recently Used (LRU) Distinguish an Empty location from a Full one Valid Bit

47 / 19 Replacement Algorithms CPU Reference ABCADEADCF Miss HitMiss Hit Miss Cache FIFO  AA B A B C A B C A B C D E B C D E A C D E A C D E A C D E A F D Hit Ratio = 3 / 10 = 0.3

48 / 19 Replacement Algorithms CPU Reference ABCADEADCF Miss HitMiss Hit Miss Cache LRU  AB A C B A A C B D A C B E D A C A E D C D A E C C D A E F C D A Hit Ratio = 4 / 10 = 0.4

Performance Considerations

Overview Two key factors: performance and cost Price/performance ratio Performance depends on how fast machine instructions can be brought into the processor for execution and how fast they can be executed. For memory hierarchy, it is beneficial if transfers to and from the faster units can be done at a rate equal to that of the faster unit. This is not possible if both the slow and the fast units are accessed in the same manner. However, it can be achieved when parallelism is used in the organizations of the slower unit.

Interleaving If the main memory is structured as a collection of physically separated modules, each with its own ABR (Address buffer register) and DBR( Data buffer register), memory access operations may proceed in more than one module at the same time. m bits Address in moduleMM address (a) Consecutive words in a module i k bits Module DBRABRDBRABR DBR 0 n1- Figure Addressing multiple-module memory systems. (b) Consecutive words in consecutive modules i k bits 0 Module MM address DBRABR DBRABRDBR Address in module 2 k 1- m bits

Hit Rate and Miss Penalty The success rate in accessing information at various levels of the memory hierarchy – hit rate / miss rate. Ideally, the entire memory hierarchy would appear to the processor as a single memory unit that has the access time of a cache on the processor chip and the size of a magnetic disk – depends on the hit rate (>>0.9). A miss causes extra time needed to bring the desired information into the cache. Example 5.2, page 332.

Hit Rate and Miss Penalty (cont.) T ave =hC+(1-h)M T ave: average access time experienced by the processor h: hit rate M: miss penalty, the time to access information in the main memory C: the time to access information in the cache Example: Assume that 30 percent of the instructions in a typical program perform a read/write operation, which means that there are 130 memory accesses for every 100 instructions executed. h=0.95 for instructions, h=0.9 for data C=10 clock cycles, M=17 clock cycles, interleaved memory Time without cache 130x10 Time with cache 100(0.95x1+0.05x17)+30(0.9x1+0.1x17) The computer with the cache performs five times better = 5.04

How to Improve Hit Rate? Use larger cache – increased cost Increase the block size while keeping the total cache size constant. However, if the block size is too large, some items may not be referenced before the block is replaced – miss penalty increases. Load-through approach

Caches on the Processor Chip On chip vs. off chip Two separate caches for instructions and data, respectively Single cache for both Which one has better hit rate? -- Single cache What’s the advantage of separating caches? – parallelism, better performance Level 1 and Level 2 caches L1 cache – faster and smaller. Access more than one word simultaneously and let the processor use them one at a time. L2 cache – slower and larger. How about the average access time? Average access time: t ave = h 1 C 1 + (1-h 1 )h 2 C 2 + (1-h 1 )(1-h 2 )M where h is the hit rate, C is the time to access information in cache, M is the time to access information in main memory.

Other Enhancements Write buffer – processor doesn’t need to wait for the memory write to be completed Prefetching – prefetch the data into the cache before they are needed Lockup-Free cache – processor is able to access the cache while a miss is being serviced.

Virtual Memories

Overview Physical main memory is not as large as the address space spanned by an address issued by the processor = 4 GB, 2 64 = … When a program does not completely fit into the main memory, the parts of it not currently being executed are stored on secondary storage devices. Techniques that automatically move program and data blocks into the physical main memory when they are required for execution are called virtual-memory techniques. Virtual addresses will be translated into physical addresses.

Overview Memory Management Unit

Address Translation All programs and data are composed of fixed- length units called pages, each of which consists of a block of words that occupy contiguous locations in the main memory. Page cannot be too small or too large. The virtual memory mechanism bridges the size and speed gaps between the main memory and secondary storage – similar to cache.

Example: Example of Address Translation Prog 1 Virtual Address Space 1 Prog 2 Virtual Address Space 2 Code Data Heap Stack Code Data Heap Stack Data 2 Stack 1 Heap 1 OS heap & Stacks Code 1 Stack 2 Data 1 Heap 2 Code 2 OS code OS data Translation Map 1Translation Map 2 Physical Address Space

Page Tables and Address Translation The role of page table in the virtual-to-physical address translation process.

Address Translation Page frame Virtual address from processor in memory Offset Virtual page numberPage table address Page table base register Figure Virtual-memory address translation. Control bits Physical address in main memory PAGE TABLE Page frame +

Address Translation The page table information is used by the MMU for every access, so it is supposed to be with the MMU. However, since MMU is on the processor chip and the page table is rather large, only small portion of it, which consists of the page table entries that correspond to the most recently accessed pages, can be accommodated within the MMU. Translation Lookaside Buffer (TLB)

TLB Figure Use of an associative-mapped TLB. No Yes Hit Miss Virtual address from processor TLB OffsetVirtual page number number Virtual pagePage frame in memory Control bits Offset Physical address in main memory Page frame =?

TLB The contents of TLB must be coherent with the contents of page tables in the memory. Translation procedure. Page fault Page replacement Write-through is not suitable for virtual memory. Locality of reference in virtual memory

Memory Management Requirements Multiple programs System space / user space Protection (supervisor / user state, privileged instructions) Shared pages

Secondary Storage

Magnetic Hard Disks Disk Disk drive Disk controller

Organization of Data on a Disk Sector 0, track 0 Sector 3, trackn Figure Organization of one surface of a disk. Sector 0, track 1

Access Data on a Disk Sector header Following the data, there is an error- correction code (ECC). Formatting process Difference between inner tracks and outer tracks Access time – seek time / rotational delay (latency time) Data buffer/cache

Disk Controller ProcessorMain memory System bus Figure Disks connected to the system bus. Disk controller Disk drive

Disk Controller Seek Read Write Error checking

RAID Disk Arrays Redundant Array of Inexpensive Disks Using multiple disks makes it cheaper for huge storage, and also possible to improve the reliability of the overall system. RAID0 – data striping RAID1 – identical copies of data on two disks RAID2, 3, 4 – increased reliability RAID5 – parity-based error-recovery

Optical Disks AluminumAcrylicLabel (a) Cross-section Polycarbonate plastic SourceDetectorSourceDetector SourceDetector No reflection Reflection PitLand (c) Stored binary pattern Figure Optical disk. PitLand 1 (b) Transition from pit to land

Optical Disks CD-ROM CD-Recordable (CD-R) CD-ReWritable (CD-RW) DVD DVD-RAM

Magnetic Tape Systems Figure Organization of data on magnetic tape. File mark File 7 or 9 gap File gapRecord bits

Homework Page 361: 5.6, 5.9, 5.10(a) Due time: 10:30am, Monday, March 26

Requirements for Homework 5.6. (a): 1 credits 5.6. (b): Draw a figure to show how program words are mapped on the cache blocks: 2 Sequence of reads from the main memory blocks into cache blocks:2 Total time for reading blocks from the main memory: 2 Executing the program out of the cache: Beginning section of program:1 Outer loop excluding Inner loop:1 Inner loop:1 End section of program:1 Total execution time:1

Hints for Homework Assume that consecutive addresses refer to consecutive words. The cycle time is for one word Total time for reading blocks from the main memory: the number of readsx128x10 Executing the program out of the cache MEM word size for instructionsxloopNumx1 Outer loop excluding Inner loop: (outer loop word size-inner loop word size)x10x1 Inner loop: inner loop word sizex20x10x1 MEM word size from MEM 23 to 1200 is MEM word size from MEM 1201 to 1500(end) is