Docsity

Memory Organization: Understanding Cache Memory and Virtual Memory, Study Guides, Projects, Research of Computer Architecture and Organization

Toggle sidebar
bg1
The Memory System
We now consider the memory system of the computer. Up to this point, we have considered
the memory as a single monolithic element. A 128 MB memory would be viewed as follows.
We now consider the actual structure of memory, which has evolved in response to
commercial pressure to have large memories that are also fast, physically compact, and
relatively cheap. As an example, we quote a recent (7/7/2005) price for memory from
Gateway Computers: $130 for 512 MB of 533 MHz SDRAM.
The multi–level memory structure is one response to the requirement for a very large, very
fast memory. A complete memory hierarchy uses several levels of cache memory, which is
best considered as a small fast memory attached to a larger slower memory. Under proper
conditions, such a memory can be made to act as a larger memory with a speed almost that of
the faster memory. In this chapter we consider these designs.
Here is the central problem addressed by the memory hierarchy: memory is too slow. We
now have central processing units with clocks rated at 3.2 GHz, with rumors of 5.0 GHZ
units being in development. We now ask about the impact of a 100 GHz unit, were it now
available. Such a unit, having a clock approximately 30 times faster than current units,
would be only slightly faster than current models, due to the inability of memory to keep up.
This phenomenon is called memory starvation – memory is just too slow for the CPU.
The central idea of a multi–level memory is to have a faster primary memory front for a
slower secondary memory. All modern computers employ two variants of such a memory
strategy, called cache memory and virtual memory. Although these two strategies evolved
for different reasons, their structures share a lot in common. The following figure shows
how the two play together in a typical computer.
The study of a virtual memory system focuses on the management of main and secondary
memory by the operating system as a single large address space. This is covered in courses
on Operating Systems. The study of cache memory focuses on the management of a high
speed cache placed between the main memory and the CPU.
Page 1 of 26 Chapter 6 Revised July 19, 2005
Copyright © by Edward L. Bosworth, Ph.D. All rights reserved.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a

Partial preview of the text

Download Memory Organization: Understanding Cache Memory and Virtual Memory and more Study Guides, Projects, Research Computer Architecture and Organization in PDF only on Docsity!

The Memory System

We now consider the memory system of the computer. Up to this point, we have considered the memory as a single monolithic element. A 128 MB memory would be viewed as follows. We now consider the actual structure of memory, which has evolved in response to commercial pressure to have large memories that are also fast, physically compact, and relatively cheap. As an example, we quote a recent (7/7/2005) price for memory from Gateway Computers: $130 for 512 MB of 533 MHz SDRAM. The multi–level memory structure is one response to the requirement for a very large, very fast memory. A complete memory hierarchy uses several levels of cache memory , which is best considered as a small fast memory attached to a larger slower memory. Under proper conditions, such a memory can be made to act as a larger memory with a speed almost that of the faster memory. In this chapter we consider these designs. Here is the central problem addressed by the memory hierarchy: memory is too slow. We now have central processing units with clocks rated at 3.2 GHz, with rumors of 5.0 GHZ units being in development. We now ask about the impact of a 100 GHz unit, were it now available. Such a unit, having a clock approximately 30 times faster than current units, would be only slightly faster than current models, due to the inability of memory to keep up. This phenomenon is called memory starvation – memory is just too slow for the CPU. The central idea of a multi–level memory is to have a faster primary memory front for a slower secondary memory. All modern computers employ two variants of such a memory strategy, called cache memory and virtual memory. Although these two strategies evolved for different reasons, their structures share a lot in common. The following figure shows how the two play together in a typical computer. The study of a virtual memory system focuses on the management of main and secondary memory by the operating system as a single large address space. This is covered in courses on Operating Systems. The study of cache memory focuses on the management of a high speed cache placed between the main memory and the CPU. Page 1 of 26 Chapter 6 Revised July 19, 2005

Locality Both virtual memory and cache memory depend on two locality properties of computer programs. These properties are collectively called “ locality ”. There are two basic types of locality: temporal and spatial locality. These have simple definitions: temporal locality the principle that recently accessed memory locations are very likely to be accessed again. spatial locality the principle that the next memory location to be accessed will likely be very close to the location last accessed. For instruction access, this can be called “sequential locality”. The locality principle was discovered by Peter J. Denning as a part of his Ph.D. research at MIT, where he addressed the problem called “memory thrashing” in which virtual memory systems spent most of their time handling memory access and very little time doing actual computation. Dr. Denning describes his work in the July 2005 issue of Communications of the ACM. We should all hope for a Ph.D. project with such wide applicability. Effective Access Time for Multilevel Memory Each of the two memory systems (cache memory and virtual memory) can be viewed as a two–level memory. We have a faster primary memory with an access time denoted by TP, and a slower secondary memory with an access time denoted by TS. Work with problems of this time is made more complicated by the names by which we refer to computer memory; our main memory (of which we might have 128 – 512 MB) is also called “primary memory”, a term that can cause confusion. Here are the proper uses of the terms. System Primary Level Secondary Level Cache Memory The Cache Main Memory Virtual Memory Main Memory The Disk When considering a problem, there is one rule that can always be used: TP < TS. For the simpler problem of cache memory, we have TP  5 to 10 nanoseconds and TS  80 nsec. We now consider the multilevel memory problem in the abstract, deriving results that are valid for both cache memory and virtual memory systems. As noted above, the success of such a system is due to the principle of locality. The measure of the effectiveness of this system is the hit ratio , reflected in the effective access time of the memory system. In a standard memory system, an addressable item is referenced by its address. In a two level memory system, the primary memory is first checked for the address. If the addressed item is present in the primary memory, we have a hit , otherwise we have a miss. The hit ratio is defined as the number of hits divided by the total number of memory accesses; 0.0  h  1.0. Given a faster primary memory with an access time TP and a slower secondary memory with access time TS, we compute the effective access time as a function of the hit ratio. The applicable formula is TE = hTP + (1.0 – h )TS. As an aside, we note that the following results are easily proved if TP < TS:

  1. TP  TE  TS,
  2. TE = TP if and only if h = 1,
  3. TE = TS if and only if h = 0. Page 2 of 26 Chapter 6 Revised July 19, 2005

A Strategy for Primary-Memory Misses In a multilevel memory system, we stipulate that the CPU first searches the primary memory for the desired word (data or instruction) before searching the secondary memory. To be a bit more specific about the above, we state that.

  1. In a cache memory scenario, the cache memory is accessed before main memory, and
  2. In a virtual memory scenario, the main memory is accessed before the disk. When the system has a primary memory hit, everything is fast. We now consider the implications of the fact that, with the primary memory being smaller than the secondary memory, there will be many instances in which the specified word is not in primary memory; these events are called primary memory misses.
  3. In a cache memory scenario, these are called cache misses , and
  4. In a virtual memory scenario, these are called page faults. Blocks and Slots We use this offbeat terminology to illustrate a strategy common to both cache memory and virtual memory when handling primary-memory misses. This strategy is to bring into the primary memory not only the word being sought but also a surrounding block of memory. To appreciate this strategy, suppose that the MARIE has a cache memory and that it is executing a sequence of eight instructions in words 0x201 though 0x208, none of which is in the cache memory. For this example, we assume that TP = 10 and TS = 80 nanoseconds. The simplest strategy would be to fetch each word as it is needed. Address Access Primary Hit? Action Time Total 201 10 nsec. No Access Secondary 80 nsec. 80 nsec. 202 10 nsec. No Access Secondary 80 nsec. 90 nsec. 203 10 nsec. No Access Secondary 80 nsec. 90 nsec. 204 10 nsec. No Access Secondary 80 nsec. 90 nsec. 205 10 nsec. No Access Secondary 80 nsec. 90 nsec. 206 10 nsec. No Access Secondary 80 nsec. 90 nsec. 207 10 nsec. No Access Secondary 80 nsec. 90 nsec. 208 10 nsec. No Access Secondary 80 nsec. 90 nsec. Total 720 nsec. Suppose now a more sophisticated strategy in which a miss on a word causes that word and the next seven words to be fetched from secondary memory. For realism, let’s assume that the block transfer takes an additional 40 nanoseconds, for a total of 120 nanoseconds. Address Access Primary Hit? Action Time Total 201 10 nsec. No Block transfer 120 nsec. 130 nsec. 202 10 nsec. Yes Read cache 0 10 nsec. 203 10 nsec. Yes Read cache 0 10 nsec. 204 10 nsec. Yes Read cache 0 10 nsec. 205 10 nsec. Yes Read cache 0 10 nsec. 206 10 nsec. Yes Read cache 0 10 nsec. 207 10 nsec. Yes Read cache 0 10 nsec. 208 10 nsec. Yes Read cache 0 10 nsec. Total 200 nsec. Page 4 of 26 Chapter 6 Revised July 19, 2005

In the first scenario, the average access time for the memory is 90 nanoseconds, actually slower than the secondary memory. In the second scenario, the average access time is 25 nanoseconds, not impressive but better than the secondary memory. We shall now discuss the general problem of primary memory management. This author would prefer to continue the use of generic language in order to emphasize the point that the strategy applies equally well to both the cache memory problem and the virtual memory problem. He has decided that holding tenaciously to such an approach would lead to more confusion than it is worth, so now focuses on a specific cache management strategy. A Direct-Mapped Cache in the MARIE We need a more focused discussion of the “slots and blocks” issue of primary memory management, so we focus on the simplest example: the management of a cache memory that fronts for the main memory in a computer. Ignoring the fact that the MARIE memory is much smaller than most existing cache memories, we postulate the following scenario. Main memory: 4096 words of 16 bits each Cache memory: 64 words of 16 bits each, organized into four “slots” or blocks holding sixteen words each. Mapping strategy: Direct mapped. As just noted, each block in the cache memory holds 16 words. It is organized as follows. As is the case with any memory fronted by a cache, the memory address space is also divided into blocks of 16 words each. Since there are 4096 (2^12 ) words in the memory, this implies 256 (2^8 ) blocks of 16 (2^4 ) words each. It is a requirement that the memory blocks be the same size as the cache blocks. The address of a word in main memory is thus considered as MemBlock16 + Offset Page 5 of 26 Chapter 6 Revised July 19, 2005

Tags and Valid Bits Suppose a program in the computer issues the address 0x006 by placing that 12-bit number in the Memory Address Register. The hardware must see if that address is in cache memory. As a 12–bit pattern, formatted according to the tag-cache block-offset scheme, we have: The figures for this address are: Offset = 0x Cache Block = 0x Tag = 0x We see that this memory address, if present in the cache memory, would be present in cache block 0 at offset 6. The trouble is that, from what we have specified already, the entry in that offset could just as easily be for address 0x146, 0x5C6, or any of the other 61 memory addresses that would map to that offset in cache 0. We need to store some additional address information with the entry to be sure we can identify it. Fortunately all entries in a given cache block correspond to the same memory block in main memory. The solution is to store the memory block number in a special register associated with the cache block. In this arrangement, every memory block stored in cache block 0 has a memory block such that (MemBlock mod 4 == 0) so that we need store only Tag = MemBlock / 4. Suppose now that the word in the specified offset (0x06) in cache block 0 is really the word at address 0x486 in main memory. This corresponds to a memory block number of 0x48. Recalling that 0x48 = 416 + 8, we see that the memory block is (44 + 2)4, so that (MemBlock mod 4) == 0 and (MemBlock / 4) == 44 + 2 = 0x12. The cache tag is 0x12. The CPU is seeking an entry in memory block 0, but it is memory block 0x48 that is in the cache block. This is a cache miss, so that main memory has to be accessed and a new block brought into the cache. The data in cache block 0 will be overwritten. The main question is whether or not the data in the cache should be saved back to main memory before the new data are read in. Managing this function is the job of the dirty bit. The rules for handling the dirty bit are simple:

  1. When a new memory block is read from main memory into a cache block, the dirty bit associated with the cache block is set to 0.
  2. Whenever a word is written into the cache block, the dirty bit associated with the cache block is set to 1. The bit remains at 0 if the block is only read.
  3. Whenever a new block is to be brought into the cache block, the dirty bit is checked. If it is 0, nothing is done before the copy as the data in the cache block are identical to those in main memory. If the dirty bit is 1, the data in the now-modified cache block are copied back to main memory before the new data are copied in. Suppose now that the program issues the address 0x006 and that the tag associated with cache block is 0x00. This is the desired tag, but does this imply that the required memory block is already in the cache block. The answer is that it does not, since the tag might just reflect that the memory has been initialized. For this reason, we also need a valid bit to be associated with the cache block, indicating that the data have been read from main memory. Page 7 of 26 Chapter 6 Revised July 19, 2005

We now associate the following structure with each of the cache blocks in the above example. Recall that a memory block size is 16 words, and that there are 4 cache blocks. Rules for this cache memory Before continuing with a more general description of the primary vs. secondary memory scenario, we explicitly close this small illustration with a complete set of rules. This rule set is specific to the above example: 12-bit memory addresses, with 4 cache blocks of 16 words.

  1. The address issued should be thought of as an 8-bit memory block and 4-bit offset. In other words, the address is represented as 3 hexadecimal digits, with the first two hexadecimal digits being the memory block number and the last being the offset.
  2. If a word is to be read in, so is every other word in the same memory block. Thus if the word at address 0x4C6 is read in, then so are all 16 words with addresses ranging from 0x4C0 through 0x4CF.
  3. The hardware computes the numbers MemBlock = Address / 16 CacheBlock = MemBlock mod 4 Tag = MemBlock / 4. The cache block with the specified number is now examined. Page 8 of 26 Chapter 6 Revised July 19, 2005

With this relaxed association of the memory block number to the cache block, the situation with the address space as in the next figure. Since we no longer have an automatic association of memory block with the cache block, we must consider a tag array associated with the cache. Suppose the following. Cache Block Memory Tag 0 0xA 1 0x 2 0xBF 3 0x The association represented by this table can be expressed as follows: Cache block 0 holds addresses 0xA00 through 0xA0F, Cache block 1 holds addresses 0x220 through 0x22F, Cache block 2 holds addresses 0xBF0 through 0xBFF, and Cache block 3 holds addresses 0x330 through 0x33F. Since we have just dropped the forced association of memory blocks with cache blocks, each memory reference must cause a search of all four elements of this array to determine which of the four cache blocks, if any, was associated with the memory reference. Talk about a big waste of time. There must be a better way. Naturally, there is a better way. Content Addressable Memory (Associative Memory) The difficulty with the above cache scheme is that it uses a standard memory structure to store the memory tags. The only way to access such a memory structure is via the address of each memory cell; we send an address and ask the contents of the cell. Content addressable memory , also called associative memory , is memory that is accessed via its contents; in such a memory the address is almost an afterthought. The basic memory unit of such a memory is closely related to that of standard memory and is best considered to be a modified flip–flop. The next figure shows a typical cell in associative memory. The most important structure in this drawing is the provision for a single bit, called the “Bit to Match” to be compared to the contents of the cell. Page 10 of 26 Chapter 6 Revised July 19, 2005

Calling the bit to be matched “B”, consider the output of the above circuit. Q B QB Q^ B 0 0 0 1 0 1 1 0 1 0 1 0 1 1 0 1 The output of this circuit is 1 if and only if the contents of the memory are the same as the bit to be matched. As in all discussions of associative memory, we acknowledge that the memory cell must be loaded somehow, but generally ignore that mechanism. The following diagram shows the output mechanism of an associative memory unit comprising two words of three bits each. There are three bits to be matched. If either of the 3–bit words in this memory contains bits that match the pattern being sought, its corresponding match line will be asserted. For example, suppose that B 2 B 1 B 0 = 011, and that words 0 and 1 contain 111 and 011 respectively. Then M 0 = 0 (no match) and M 1 = 1 (match). A complete associative memory contains provisions for a few additional features that need not concern us, as our goal is only to gain a basic understanding of this memory type. The additional features that a complete system should provide include:

  1. The ability to mask bits, so that only certain bits must be matched. For example, in the above case we could say that only bits 2 and 0 must be matched, so that 011 would be matched by either 001 or 011.
  2. The ability to handle multiple matches by a multiple match resolver. Suppose that the system has K words, with outputs M 0 , M 1 , …, MK. Such a circuit would force a priority structure on the outputs, so that only one match at a time is handled.
  3. The ability to mask certain matches that have already been processed. This feature allows processing each match in a system that can handle only one match at a time. Page 11 of 26 Chapter 6 Revised July 19, 2005
  1. The primary memory comprises a number of primary memory slots, each exactly the size of a memory block. Assume that there are M slots, numbered 0 .. (M – 1). Each slot has 2K^ addressable units, a tag field to hold the memory block number (either explicitly or implicitly), and two Boolean flags: Valid and Dirty.
  2. When the system is initialized (computer is turned on or “booted”), the valid bit for each primary memory slot is set to 0 (not valid). One could argue that the contents of each cache slot should be cleared, but this is not likely to happen.
  3. Whenever the CPU issues a memory reference by placing an address into the MAR (Memory Address Register), this address is broken into a memory block number and offset within the memory block. Due to the structure of the addressing system, the memory block number is bits (N – 1) through K of the N–bit address.
  4. The primary memory is now searched for a cache block with its tag equivalent to the memory block in the address. For direct mapped primary memory, there is only one primary memory slot in which this block can be placed; this is the only slot that is searched. For other strategies in which more than one primary memory slot can be associated with the memory block, an associative memory is often used as a way to speed up the search.
  5. If the memory block number matches the tag field for a primary memory slot with the valid bit set, then the desired block has been found and the memory access (read or write) proceeds. This is a primary memory “hit”; the process terminates.
  6. If the memory block is not found in the primary memory, we have a “miss”. A replacement policy (discussed later) is used to select the primary memory slot into which the memory block being sought will be copied. In our example of direct mapped caches, the choice of memory slot is automatic.
  7. If both the valid and dirty bits of the selected primary memory slot are set, that slot contains memory elements that differ from their image in the secondary memory. In this case, copy the contents of the primary memory slot back to the secondary memory block at the memory block associated with the tag.
  8. The memory block being sought is now read into the primary memory slot that has been selected, the valid bit is set to 1 (valid), the dirty bit is set to 0 (contents the same as in secondary memory) and the tag bit for the primary memory slot is changed to match the memory block number.
  9. The memory access (read or write) proceeds. If the access is a memory write, then the dirty bit is set to 1 (primary memory has been changed). Just for review, this table gives the interpretation of the Valid and Dirty bits. Valid Dirty Interpretation 0 0 No valid data in the primary memory slot. 0 1 1 0 Valid data in the slot, same as that in secondary memory. 1 1 Valid data in the slot, not the same as that in secondary memory. Page 13 of 26 Chapter 6 Revised July 19, 2005

Miscellaneous Comments on Primary Memory / Secondary Memory We now make a few comments that apply to both virtual memory and cache memory. How to Break Caching The utility of a cache memory (really, of any primary/secondary memory combination) depends on the locality of references. This is especially true in array references, when the arrays are accessed in a infelicitous order. To see what is happening, let us consider the storage of two–dimensional arrays in a computer. For example consider A[2][3], an array with row indices 0 and 1 and column indices 0, 1, 2. There are two orders in which the array can be stored: row major order and column major order. Here they are: Row Major Column Major A[0][0] A[0][0] A[0][1] A[1][0] A[0][2] A[0][1] A[1][0] A[1][1] A[1][1] A[0][2] A[1][2] A[1][2] To see how array references can come to grief, recall the example of direct mapped caching as it might be applied to the MARIE. The address structure is as follows. In this scenario, word 0 of cache block 0 would contain addresses 0, 64, 128, 192, etc. Now suppose an array, declared as A[64][4] with the first element A[0][0] associated with an address that maps to cache block 0. Suppose the following code fragment For (J = 0; J < 64; J++) For (K = 0; K < 4; K++) A[J][K] = 0 If the array is stored in row major order , then we have the following associations for the first eight entries in the cache block 0 in the cache memory. Offset 0 A[0][0] A[16][0] A[20][0] 1 A[0][1] A[16][1] A[20][1] 2 A[0][2] A[16][2] A[20][2] 3 A[0][3] A[16][3] A[20][3] 4 A[1][0] A[17][0] A[21][0] 5 A[1][1] A[17][1] A[21][1] 6 A[1][2] A[17][2] A[21][2] 7 A[1][3] A[17][3] A[21][3] The array accesses for this row major order will make optimal use of the cache. The first sixteen references will be from different offsets in cache block 0, which will not again be accessed until 48 more array accesses have been made. Page 14 of 26 Chapter 6 Revised July 19, 2005

Cache Write Policies What to do when an item is written to primary memory? Unless the circuit takes extra time to compare the old contents to the new contents, it must assume that the contents of the block in the primary memory now differ from those in the secondary memory; the block is “dirty”. Eventually, the contents of the memory block in secondary memory must be changed to agree with the contents of the block in the primary memory; the question is when to do this. The choice of handling dirty blocks is called the “ cache write policy ” or just “ write policy ”. In the policy called “ write–through ”, the secondary memory block is updated at the same time as the primary memory block. As an immediate result, the primary memory block can never become “dirty”, because it always is consistent with its corresponding memory block in secondary memory. The main problem is that every write to primary memory is accompanied by a write to secondary memory, and thus proceeds at the slower pace. In a cache memory scenario, the choice on this policy depends on the frequency of memory accesses that are memory writes vs. memory reads. If the fraction is small enough (and it usually is), then the slow–down due to this policy is negligible. In a virtual memory scenario, such a policy would require a disk write for every memory write; resulting in a performance degradation that would not be tolerated. In the policy called “ write–back ”, the dirty bit is set on a primary memory block that has been changed, and the primary memory block is copied back to secondary memory only when the replacement policy (defined below) selects its slot to be filled by another memory block. This strategy is considerably faster than write–through, but suffers the problem that the primary memory and secondary memory may not be consistent. Obviously, virtual memory must use some variant of this policy. While we are at it, we should mention the “ cache coherence ” problem that can appear in multi–processor systems. For the moment, ignore virtual memory and focus on two processors, each with its own cache memory sharing a common main memory. The scenario is simple, and is a variant of a problem that appears in databases.

  1. Processor 1 fetches a block from main memory into its cache,
  2. Processor 2 fetches a block from main memory into its cache,
  3. One of the processors changes the contents of its copy of the data block. We now have two big issues, but the basic problem is that even if the processor changing the data uses a write–through policy, thus updating the main memory, there is no assurance that the other processor will not be operating with stale data in its cache. Should the student think that the cache coherence problem is a minor one, relevant only to computer hardware, we mention that it appears “big time” in databases under the name of the “lost update problem”. The lost update problem and its associated problem of stale data both appear in database theory and relate to one user changing a record that another user is also working on. The next time some institution, such as an airline or restaurant, loses your reservation, think about cache coherence. Page 16 of 26 Chapter 6 Revised July 19, 2005

Replacement Policies We now consider the replacement policy for a primary memory. Suppose that the primary memory is full; every block contains valid data. If the system needs to read a new memory block from secondary into the primary memory, one of the blocks in primary memory must be overwritten. The replacement policy determines which block is to be overwritten. Remember the function of the “dirty bit”. If the primary memory block to be overwritten is dirty, its contents are always written back to the appropriate block in secondary memory. Direct Mapped Primary Memory This option is more often used with cache memories, but can also be applied in virtual memory. In this strategy, the primary memory block is already determined for every memory block from secondary memory; thus the replacement policy is fixed. In our discussion of a direct mapped cache for the MARIE, we postulated memory in which MemBlock = Address / 16 CacheBlock = MemBlock Mod 4 For this strategy, the replacement policy is automatic.

  1. For the given memory address, compute the value of CacheBlock, and
  2. If that cache block does not already contain the referenced memory block, it is the one to be replaced. Other Replacement Policies Here we investigate a number of other policies that can be applied in situations for which direct mapping is not used in primary memory block selection. We should emphasize now that there is only one policy for which there is strong theoretical justification, and that this one policy cannot actually be implemented. Each of the policies that can be implemented presents technical challenges in its implementation. Most of these policies involve attaching some extra registers to each primary memory block and managing them properly. These are issues that we shall blissfully ignore as we are only interested in the “big picture”. The replacement policy functions based on the memory block number of the referenced address in memory. Recall that the memory address is of the form Address = (MemBlock  2 K) + Offset and that all words in the specified memory block are transferred to the primary memory at the same time. Thus, it is the memory block number that determines the placement. We shall use the MARIE cache example when explaining the replacement strategies. For our example, we now drop the direct mapped part of the above cache example, and assume that the cache has four blocks (0, 1, 2, and 3) that can hold any memory block. For example, suppose the following string of memory block references (recall that they are 8–bit numbers). 0x21, 0x32, 0x43, 0x21, 0x54, 0x We assume that memory blocks 0x21, 0x32, 0x43, and 0x54 are in the cache memory and need to place memory block 0x73. Where do we put it? Page 17 of 26 Chapter 6 Revised July 19, 2005

SDRAM – Synchronous Dynamic Random Access Memory As we mentioned above, the relative slowness of memory as compared to the CPU has long been a point of concern among computer designers. One recent development that is used to address this problem is SDRAM – synchronous dynamic access memory. The standard memory types we have discussed up to this point are SRAM Static Random Access Memory Typical access time: 5 – 10 nanoseconds Implemented with 6 transistors: costly and fairly large. DRAM Dynamic Random Access Memory Typical access time: 50 – 70 nanoseconds Implemented with one capacitor and one transistor: small and cheap. In a way, the desirable approach would be to make the entire memory to be SRAM. Such a memory would be about as fast as possible, but would suffer from a number of setbacks, including very large cost (given current economics a 256 MB memory might cost in excess of $20,000) and unwieldy size. The current practice, which leads to feasible designs, is to use large amounts of DRAM for memory. This leads to an obvious difficulty.

  1. The access time on DRAM is almost never less than 50 nanoseconds.
  2. The clock time on a moderately fast (2.5 GHz) CPU is 0.4 nanoseconds, 125 times faster than the DRAM. The problem that arises from this speed mismatch is often called the “Von Neumann Bottleneck” – memory cannot supply the CPU at a sufficient data rate. Fortunately there have been a number of developments that have alleviated this problem. We have already discussed the idea of cache memory , in which a large memory with a 50 nanosecond access time can be coupled with a small memory with a 10 nanosecond access time and function as if it were a large memory with a 10.4 nanosecond access time. We always want faster. The next development that we shall discuss is synchronous dynamic access memory , SDRAM for short. Although we have not mentioned it, earlier memory was asynchronous, in that the memory speed was not related to any external speed. In SDRAM, the memory is synchronized to the system bus and can deliver data at the bus speed. The earlier SDRAM chips could deliver one data item for every clock pulse; later designs called DDR SDRAM (for Double Data Rate SDRAM) can deliver two data items per clock pulse. Modern computer designs, in an effort to avoid the Von Neumann bottleneck, use several tricks, including multi-level caches and DDR SDRAM main memory. As an example, we quote from the Dell Dimension 4700 advertisement of July 21, 2004. The chip has two 16 KB L1 caches (an Instruction Cache and a Data Cache), 1MB L2 cache, and 512 MB of DDR SDRAM that operates with a 400 MHz bus (800 M transfers/sec) with 64 data lines – 8 bytes at a time, for a data rate of 6.4 GB/sec. Page 19 of 26 Chapter 6 Revised July 19, 2005

The main difference between level 1 (L1) cache and level 2 (L2) cache is that the L1 cache is on the CPU chip, while the L2 cache generally is on a different chip. For example, the IBM S390/G5 chip has 256 KB of L1 cache on the CPU chip and 4MB of L2 cache. It is likely that the existence of two (or more) levels of cache, rather than one large L1 cache, is due to two aspects of area constraints: area on the CPU chip that can be allocated to the L1 cache and the fact that larger SRAM memories tend to be slower than the smaller ones. L1 cache memory is uniformly implemented as SRAM (Static RAM), while L2 cache memory may be either SRAM or SDRAM. The SDRAM chip uses a number of tricks to deliver data at an acceptable rate. As an example, let’s consider a modern SDRAM chip capable of supporting a DDR data bus. In order to appreciate the SDRAM chip, we must begin with simpler chips and work up. We begin with noting an approach that actually imposes a performance hit – address multiplexing. Consider an NTE2164, a typical 64Kb chip. With 64K of addressable units, we would expect 16 address lines, as 64K = 2^16. In stead we find 8 address lines and two additional control lines RAS Row Address Strobe (Active Low) CAS Column Address Strobe (Active Low) Here is how it works. Recalling that 64K = 2^16 = 2^8  28 = 256  256, we organize the memory as a 256-by-256 square array. Every item in the memory is uniquely identified by two addresses – its row address and its column address. Here is the way that the 8-bit address is interpreted. RAS CAS Action 0 0 An error – this had better not happen. 0 1 It is a row address (say the high order 8-bits of the 16-bit address) 1 0 It is a column address (say the low order 8-bits of the 16-bit address) 1 1 It is ignored. Here is that way that the NTE2164 would be addressed.

  1. Assert RAS = 0 and place the A 15 to A 8 on the 8-bit address bus.
  2. Assert (^) CAS = 0 and place A 7 to A 0 on the 8-bit address bus. There are two equivalent design goals for such a design.
  3. To minimize the number of pins on the memory chip. We have two options: 8 address pins, RAS, and CAS (10 pins), or 16 address pins and an Address Valid pin (17 pins).
  4. To minimize the number of address-related lines on the data bus. The same numbers apply here: 10 vs. 17. Page 20 of 26 Chapter 6 Revised July 19, 2005