Project 3
RSCPU-E-Cache
You are going to add a 1K direct-mapped, write allocate/
write through cache to your RSCPU-E
processor. The cache lines are 4 bytes.
You should represent the cache as an array of structures consisting
of 4 bytes of data and a tag field.
You must initialize the cache properly so that the code works properly.
You must set each tag value to an invalid value. I suggest setting each
tag value to 255 and each data value within the tag to zero.
On each memory read, you must first check the cache to determine if
the data is in the cache, cache hit. If you have a cache hit, take the
data from the cache. If you have a cache miss, you must read the memory
from main memory and update the cache.
On each memory write,
bring the line into the cache then
you must write the data to both the cache and
to main memory.
In addition to the printing requirements specified in Project 2, on
each memory access you must print the following:
-
The AR value that you are referencing
-
The main memory block number
-
The cache line number
-
The cache line and tag before testing it for a miss/hit
-
Whether you have a cache hit or a cach miss
-
The cach line and tag following the read/write (regardless of whether the
memory location was already in the cache)
Submit your program
-
(85 points) Use turnin to submit your program. On the command line type
turnin, cs398c, RSCPUECACHE.Your program must be called rscpuecache.cpp.
Please note that your code must written in C++. It is your responsibility to check the output file generated by turnin
to be sure that your program turned in properly. Programs that do not compile
are not worth any credit. Programs that do not run to a normal completion
are worth very little.
-
(15 points)Using a word processor, answer the following:
-
What is m?
-
How many bits make up r (#bits in the line field)?
-
How many bits make up s-r (# bits in the tag field)?
-
Run your program against the following 2 programs:
Program 1
mvi 0x01
mvac
mvi 0x06
loop:
stac 0x2050
ldac 0x2050
sub
jpnz loop
halt
Program 2
mvie 0x0001
stace 0x0400
inace
stace 0x0400
inace
stace 0x0404
inace
stace 0x0404
ldace 0x0400
halt
-
How many cache hits for each program?
-
How many cache misses for each program?
-
Discuss the effectiveness of the cache in each program? Relate this discussion
to locality of reference. Discuss any differences between the 2 programs.
-
Would your observations be any different if the cache were an associative
cache instead of a direct mapped cache?
- Submit your report to D2L.
A link to my turnin .out file.
© This project is copyright protected by Barbara Bracken
This page is maintained by Barbara Bracken
Last Modified: 8/11/2024