






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







All of the addresses generated by the processor must be found in physical main memory at the bottom of the cache memory hierarchy. Main memory size on current systems is usu- ally limited (about 1 GB currently) by the expense of enlarging the memory. Two prob- lems with a finite amount of main memory can be handled with a virtual memory system design.
To solve these problems in a manner transparent to users, the address generated by the processor (the logical address or virtual address) is translated by the virtual memory into a physical address that can be anywhere in main memory (fig. 7.19, p. 512). When there is not enough main memory, disk storage is used to store main memory contents until needed. In this way, each process can generate addresses for a “virtual machine” consist- ing of the entire address space.
With the following correspondence in terminology,
cache virtual memory miss page fault, address fault block page, segment
virtual memory acts very much like
another level in the cache hierarchy with disk as the next lowest level memory (see fig. 7.22, p. 518).
physical memory length
segment #1 unused segment #2 segment #
external fragmentation page
unused internal fragmentation
Information is transferred between disk and main memory either in variable sized “seg- ments” or fixed size “pages”. With segments, external fragmentation limits memory usage efficiency. With pages, internal fragmentation is a problem.
Program Segments. It has become common practice to divide program code into seg- ments by function. These segments are designed with “memory protection” in mind, rather then overlaying. Four common types of segments are:
The point of these segments is to restrict the ways different segments can be used. It is taken to be an unintended error, for example, to write data into the program segment or fetch instructions from one of the data segments. Many systems support the user defining as many segments as he/she likes and also the user is allowed to control the access of each segment by setting protection bits for each segment.
Segmented Virtual Memory. Typical hardware support required for virtual memory with variable length segments is shown below.
virtual address^ segment offset
address fault
physical address
segment registers
base length prot
code segment base length prot base length prot base length prot
absolute segment stack segment data segment
protection fault
adder comparator^
protection logic
read/write control
Intel processors allow a much larger number of segments than the 4 shown above. The segment portion of the virtual address selects a segment descriptor from an area of mem- ory called the segment descriptor table. Segment descriptors take the place of the segment
For large memories, the page tables can get quite large. For example, if the page size is
8K bytes (DEC Alpha AXP 21064), then no must be 13 (8K = 2^13 ). If the address is 43
bits, then nv must be 30 (43 - 13), and there will be 2^30 = 1G PTE’s. The size of the PTE
depends on the maximum number of physical pages implemented in memory. Around 8 bytes is usually sufficient for the physical memory address and the protection bits. This gives
page table size = (no. of pages) x (PTE size) = 1G x 8 bytes =8 GB Thus, just the page table would be about as large or larger than a typical physical memory!
Multi-level Paging. Multi-level paging can reduce the total size of the page table. Con- sider the following three level paging scheme with the same numbers as the previous example. The original logical page number is divided into three fields, each with its own page tables. The page table register points to the level 1 page table. The level 1 and 2 page table entries contain the physical page number of the next level page table. The level 3 page table contains the physical page number of the desired memory location. The lowest
three bits of the PTE address are zero since each PTE is 2^3 = 8 bits in length.
level1 level2 offset
level
page table register
level 1 Page Table
level 2 Page Table
level 3 Page Table
physical address
logical address
The logical page address has been divided into three 10-bit fields so that the page tables for each of the three levels will be the same size.
PTE size = 8 bytes therefore
page table size = 1K x 8 bytes = 8KB
A page table fits exactly into one page. This simplifies the task of managing the page tables. A single page table is much smaller than the 8GB page table with single level pag- ing. Unfortunately, there is now more than one page table. There is one page table at the first level, but each level-1 PTE points to a different level-2 page table. There may be as
many as 2^10 level-2 page tables! For each level-2 PTE, there can be as many as 2^10 level- 3 page tables! The total memory taken up by page tables can be as much as
mem for page tables = (# tables) x (table size) = (1 + 2^10 + 2^10 x 2^10 ) x 8KB = 1M x 8KB = 8GB which does not save space! However, it is not necessary for all of the level-2 and level- page tables to be present if the program segments do not use all of the address space. For
example, a program can fit into a single level-3 page table if it is shorter than 2^10 x 2^13 = 8M bytes. Having a single level-1 page table, a single level-2 page table and a single level-3 page table would require 24KB which is acceptable. Although the maximum amount of memory is not reduced, clearly the average amount of memory used by page tables is reduced by using multi-level paging.
This design has several advantages.
PA tag advantages: there is a one to one correspondence between cache and main memory (a block in main memory is represented by only one block in cache). If data in cache is changed (CPU write), it is not necessary to worry about updating other blocks in cache that correspond to the same main memory location.
PA tag disadvantages: The cache must wait for the TLB to provide the physical address. This puts the TLB on the critical timing path that determines the processor clock period! This disadvantage can be overcome by putting the TLB in a separate pipeline stage of a superpipelined processor.
VA tag advantages: If the VA is used to address the cache, the cache does not wait for the TLB. The Reverse Translation Buffer (RTB) does not have a significant impact on mem- ory delay since the RTB is used only on cache miss.
VA tag disadvantages: Unfortunately, there is not necessarily a one to one correspondence between VA’s and PA’s. For example, the operating system and the current process may use different VA’s to refer to the same physical address space. The duplicate VA’s are called “aliases.” When a CPU write modifies data in the cache, data consistency requires that cache locations corresponding to all aliases must also be updated. One way to do this is to allow only one valid alias in cache at a time, and thus avoid having to update aliases. A reverse translation buffer (RTB) is used to stores the VA corresponding to each PA. When a PA is generated by the TLB on cache miss, the RTB is checked to see if another VA already corresponds to this PA. If so, then the old VA entry is invalidated before the new one is read into data cache. Unfortunately, the RTB would need an entry for each main memory location (each PA) which would be too large.
VA cache is not commonly used because of the difficulty of removing aliases.
Fully associative cache (12 locations)
virtual instr address [42:0] (^) instruc- virtual data address [42:0] tion bus [63:0]
data out bus [63:0]
data in bus [63:0]
virtual page no. [42:13]
offset [12:0]
virtual page no. [42:13]
offset [12:0]
virtual tag [42:13]
phys page no. [33:13]
Direct mapped cache (256 locations)
phys tag [33:13]
data [255:0]
index [12:5]
word offset [4:3]
byte offset [2:0]
Fully associative cache (32 locations)
virtual tag [42:13]
phys page no. [33:13]
index [12:5]
word offset [4:3]
byte offset [2:0]
Direct mapped cache (256 locations)
phys tag [33:13]
data [255:0]
mux mux
shift
Prefetch Buffer
tag [33:5]
data [255:0]
Fully associative cache (1 location) Delayed Write Buffer
tag [33:3]
data[63:0]
Fully associative cache
(1 location)
Write Buffer
tag [33:5]
data [255:0]
Fully associative cache (4 locations)
address [33:5]
data [255:0] off chip interface
Cache Controller. In the event of a cache miss or TLB miss, the processor must be stalled while the cache fill sequence takes place or the page tables are read. Even under normal conditions (TLB hit and cache hit), extra hardware must check for access privileges and that there is a valid page in memory (it might have been swapped out to disk). This work is done by the cache controller hardware.
The cache controller along with the on-chip cache is often called the Memory Manage- ment Unit (MMU). The MMU includes all of the hardware necessary to fool the proces- sor into thinking that it has a large, very fast memory. The MMU does this by stalling the processor when necessary while the cache controller in the MMU loads the TLB and caches.
The cache controller is usually implemented as a small state machine (Moore machine). A typical flow chart for design of the controller state machine is shown in fig. 7.25, p. 526. Part of the work can be done by the processor executing protected code in a special read only memory (ROM). To do this requires interrupting the processor as discussed in a pre- vious section.
Memory System Examples. A photograph of the AMD Opteron (same instruction set as Intel Pentium IV) is shown in fig. 7.33, p. 546. Note the huge L2 on chip cache, smaller L1 instruction and data caches and the relatively small area for the Execution Unit. Both of these processors are superscalar processors which will be discussed next semester.
The on chip TLB organization of the Intel Pentium IV and the AMD Opteron is compared in fig. 7.34, p. 547 and the on chip cache organization is compared in fig. 7.35, p. 548.
Finally, the on chip memory systems of several processors are compared in fig. 7.36, p.