Cache memory

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Cache memory

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which statement about cache memory is correct?
A Cache is faster than RAM
B Cache is slower than RAM
2. Compared with RAM, how much storage does cache usually have?
A Much more (it is bigger than RAM)
B Much less (it is smaller than RAM)
3. What does the CPU do first when it needs an instruction or data?
A Goes straight to RAM
B Checks the cache
4. What does cache store?
A Frequently used instructions and data
B Every program on the computer
5. Which description of cache levels is correct?
A L1 is the smallest and fastest; L2 and L3 are larger but slower
B L3 is the smallest and fastest; L1 is the largest but slowest

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1cache AThe CPU checks cache first because it is faster, and only goes to RAM if the data is not in cache.
2L1 cache BA small amount of very fast memory in or near the CPU that stores frequently used instructions and data
3The CPU checks cache first, and only goes to RAM if the data is not found there Cif data in cache: use it, else: read RAM
4Cache is smaller but faster than RAM, so it only holds the most frequently used data DCache is much smaller than RAM, not larger. It stores only frequently used instructions and data, not every program.
5Cache is larger than RAM, so it can store all of the programs EThe smallest and fastest level of cache, found closest to the CPU core
6The CPU looks in RAM first, then checks cache if RAM is too slow Fcache size < RAM size, cache speed > RAM speed

Definitions

cache

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
IF item IS IN _____ THEN
2.
cacheSize _ ramSize
3.
cacheSpeed _ ramSpeed
4.
CHECK L1, then __, then L3, then RAM
5.
IF cacheHit = FALSE THEN READ ___

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A CPU needs an instruction
B IF it is found in cache THEN
C use it from RAM
D ELSE
E fetch it from RAM
Question 2
A CPU needs data
B CHECK cache first
C IF found THEN use cache data
D ELSE read data from ROM
Question 3
A Cache levels:
B L1 - smallest and fastest
C L2 - bigger, slower than L1
D L3 - smaller, faster than L2
Question 4
A cacheSize ← 8
B ramSize ← 16000
C IF cacheSize > ramSize THEN
D OUTPUT "Cache is smaller"
Question 5
A cacheTime ← 1
B ramTime ← 0.5
C IF cacheTime < ramTime THEN
D OUTPUT "Cache is faster"

Answer Key

Cache memory
Section A: Quick Questions
Q1
A — Cache is faster than RAM
Q2
B — Much less (it is smaller than RAM)
Q3
B — Checks the cache
Q4
A — Frequently used instructions and data
Q5
A — L1 is the smallest and fastest; L2 and L3 are larger but slower
Section B: Match the Pairs
Q1
cache → A small amount of very fast memory in or near the CPU that stores frequently used instructions and data
Q2
L1 cache → The smallest and fastest level of cache, found closest to the CPU core
Q3
The CPU checks cache first, and only goes to RAM if the data is not found there → if data in cache: use it, else: read RAM
Q4
Cache is smaller but faster than RAM, so it only holds the most frequently used data → cache size < RAM size, cache speed > RAM speed
Q5
Cache is larger than RAM, so it can store all of the programs → Cache is much smaller than RAM, not larger. It stores only frequently used instructions and data, not every program.
Q6
The CPU looks in RAM first, then checks cache if RAM is too slow → The CPU checks cache first because it is faster, and only goes to RAM if the data is not in cache.
Section C: Definitions
Q1
cache — A small amount of very fast memory in or near the CPU that stores frequently used instructions and data, so the CPU can get them faster than from RAM.
Section D: Fill in the Blanks
Q1
IF item IS IN cache THEN
Q2
cacheSize < ramSize
Q3
cacheSpeed > ramSpeed
Q4
CHECK L1, then L2, then L3, then RAM
Q5
IF cacheHit = FALSE THEN READ RAM
Section E: Spot the Error
Q1
C — If the instruction is found in the cache, the CPU uses it from the cache, which is faster. Only the ELSE branch fetches from RAM, so line 3 should say 'use it from the cache'.
Q2
D — When the data is not in the cache, the CPU goes to RAM (main memory), not ROM. Line 4 should be 'ELSE read data from RAM'.
Q3
D — Higher cache levels are bigger but slower. L3 is larger and slower than L2, not smaller and faster.
Q4
C — Cache is smaller than RAM, so the condition must test cacheSize < ramSize. With > the message would not be output.
Q5
B — Cache is faster than RAM, so RAM must have the longer access time. ramTime should be bigger than cacheTime, such as 100.