Last Updated: Saturday, August 15, 2006 at 01:54pm
nogui.cand the oracles to fix a bug related to how the LRU information was being displayed in no gui mode. Please update your copies of those files.
gui.cto make it executable friendly with Ubuntu (possibly for other versions of linux).
In this project, you will be implementing the cache logic of a MIPS simulator, called TIPS. Most of the code for TIPS has been implemented for you, except the cache logic.
To copy tips to your home directory, enter the following commands:
% cd % mkdir proj4 % cd proj4 % cp ~cs61c/proj4/* .
To compile and execute TIPS, do the following:
% gmake % ./tips
The given code has a default cache size of 0, because it has no cache logic written into it yet. After you build and run TIPS, you can configure the cache by clicking on the "Config Cache" button at the lower left of the interface. After configuring the cache, the GUI should update showing you a cache similar to the parameters you have entered.
The GUI has been designed to be straight-forward. There are four main components to the GUI interface: register display, execution log, cache display, and control panel.
A description of each of the GUI widgets are described as follows:
To complete this project, you must complete the
accessMemory() function in
cachelogic.c. This function is the gateway to accessing actual memory, represented by the
accessDRAM() function. Thus, the behavior of
accessMemory() function should be a cache that will call the
accessDRAM() function as needed.
To ensure a variety of caches can be simulated, you will be required to dynamically support 5 properties:
More information about the variables you will be working with and the functions at your disposal with can be ascertained by looking over
You should keep the following things in mind when formulating the code to do the task at hand:
-pedanticflags are enabled on
bytepointer when it is called.
memcpy()function should be used. The function prototype of
memcpy()is defined as follows:
void* memcpy(void* dest, void* src, size_t amount);
dest is the desination of where things should be copied,
src is the source to be copied, and
amount is the number of bytes to copy. A more detailed description of this function can be found in K&R.
Look over what is mentioned in
tips.h gives you an overview of how the program was put together. A section of that file has been marked as something you should read to get an idea of what functions you should be calling as well as the variables you are working with.
cachelogic.c contains a slightly more detailed explanation of what you should be writing in
The cache data structure is divided into three levels:
cachestates that you are going to be accessing the 3rd set of the cache. This level is regulated by
blockfield. For example,
cache.blockaccesses the 6th block of the 3rd set. The block that is returned gives access to tag, valid bit, dirty bit, and lru information of the block. This level is regulated by the associativity of the cache.
datafield of a block. Using the offset, a particular byte can be referenced.
There are two methods to access the LRU information of a block. The first method is via
lru.value, a field that will hold LRU information in integer format. The other method is via
lru.data, a field that will hold LRU information represented in another format (as its type is of void*, which means it can be a pointer to anything). You are free to use either methods to represent the LRU, just as long as the LRU behaves in a deterministic fashion (i.e. no two blocks (when both are valid) will ever be candiates for replacement at the same time).
In a nutshell, the
accessMemory() function is a function that facilitates communication between the CPU and DRAM. The code within the
accessMemory() function manipulates the cache data structure defined in
Creating Dump Files for Testing
TIPS contains a subset of the MIPS R2000 processor instruction set. As a result, it accepts MIPS code dumped by
spim. The dump file can be loaded into the program by clicking on the "Load Program" button.
Dumpfiles should be created using
spim. The following command sequence will ensure you make a compatible dumpfile for TIPS. The delayed-branches flag is VERY important to get branches to work properly with TIPS.
cs61c@nova  ~/proj5 > spim -delayed_branches SPIM Version 7.2.1 of August 28, 2005 Copyright 1990-2004 by James R. Larus (email@example.com). All Rights Reserved. See the file README for a full copyright notice. Loaded: /usr/spim/exceptions.s Loaded: /usr/spim/cs61c-io.s (spim) load "test.s" (spim) dump "test.dump" Dumped 6 words starting at 0x0040006c to file test.dump (spim) exitIf spim 7.2.1 is giving odd dump files (i.e. dump files larger than your own code), then you can use
spimsalto create your dumpfiles. You can start
spimsalby just typing the name of the program (no need to add the delayed-branches flag). Remember if you are using
spimsal, you need to use
__start:as the start point of your assembly file when you load it. Otherwise, you will get an error.
Frequently Asked Questions
Q: What are the definitions of associativity and set?
A: Associativity is the number of cache blocks where a given memory block can be placed into using the memory block's index.
Set is the collection of blocks associatied with the SAME index. The number of unique indexes is equal to the number of sets you have.
Q: How do I know my cache is working correctly?
A: An oracle will be provided in the project folder. The name of the oracle is
Q: Is an oracle available for my home computer?
A: There are also an oracle available for Cygwin/Windows and Ubuntu (WIP).
Q: I am updating the cache in my function, but the GUI isn't doing anything. What is going on?
A: The GUI needs to be told of when changes are made to the cache. As a result, the GUI functions at your disposal are mentioned in
tips.h. The function that merely updates the display is the
Q: How much of the GUI behavior do I have to copy?
A: No, you do not have to copy any of the GUI behavior (i.e. the flashes, the messages, etc). But you do have to implement the cache logic in
Q: Should I follow the LRU algorithm seen in COD?
A: No, you should not follow the LRU algorithm in COD. The LRU algorithm in COD is an approximation LRU algorithm, which produces ties between valid blocks that are candidates for replacement. As a result, it is suggested you should use a true LRU algorithm, where there is a unique ranking between valid blocks. In other words, there should never be any randomness in your LRU replacement policy, nor should it always default to kicking just one block out in the event of a "tie" (two LRU values being the same for two valid blocks--blocks with valid bit set to 1).
Q: Do I have to use numbers for my LRU algorithm?
A: No, you do not have to use numbers for your LRU algorithm. If you want to use something else (such as time structs), use the
lru.data to be the pointer to this data. Make sure you update
init_lru() function and
Q: Are the addresses in this project byte addressed or word addressed?
A: They are byte addressed.
Q: What do you mean by unit of transfer between cache and physical memory is in blocks?
A: This means if you have blocks in your cache with a size of 4 words, you must always move data to and from physical memory in units of 4 words. There should never be a time in which the amount of data you move to physical memory from cache be less or greather than the block size of the cache.
Q: Can I add more files to the project?
A: You can, but we are only going to be using
cachelogic.c from your submission when we test your submission.
Q: Can I work from home without Exceed?
A: Yes, there is a "No GUI" mode for TIPS that can be activated by adding the
-nogui flag when starting up TIPS. To navigate the "No GUI" interface, type "help" on the prompt after starting up TIPS
Q: Can I work from home without using SSH?
A: Yes, the Makefile in the
proj4 folder comes with lines that allow compilation with Cygwin/Windows or Linux automatically.
Q: Can I start TIPS with a dump file already loaded?
A: Yes, TIPS will interpret the last argument on the command line as a name of a file. If you want to start up TIPS with a dump file named
test23.dump, you can type the following:
% ./tips test23.dump
Q: I typed in
make and it says there is an error in the Makefile. What's wrong?
Q: I ran gmake and I can't compile this project on Cygwin/Windows because of *some reason*. What do I have to do to get it to compile on Cygwin/Windows?
A: This project's GUI interface is built on GTK+. Compiling this project on Cygwin/Windows requires you at least install
pango libraries (all available via Cygwin's setup program). Information about specifics of the general GTK+ installation can be found here.
Q: What are the specific directions of getting this project compilable on Cygwin/Windows?
A: Try the following, assuming you already have a Cygwin/Window installation with x11 and gcc installed:
pkg-config. If you haven't installed Cygwin previously, you will also need
/usr/share/fonts, (formerly C:\cygwin\usr\share\fonts)
makeshould compile the project, where you can then just type
Q: Can I use other compilers on Windows?
A: All the project files are configured for use Sparc/Solaris or Cygwin/Windows. If you want to use other compilers (i.e. Microsoft Visual Studio), you will have to find the libraries usable with those compilers and make the appropriate modifications. Remember, you must make sure your program compiles on the lab computers in 271 Soda.
Q: Do I have to figure out answers to "Things to Ponder" section for getting full credit on this project?
A: No, but they can give you a break when you need one.
You will only be required to submit one file,
cachelogic.c. You can submit a
README if you wish to convey a message to your reader when grading this project. Thus, all your code MUST be in
cachelogic.c. When we test your project, we will be using our own files (including the Makefile) except for
Bug Submission/GUI Suggestions
TIPS originally was written several years ago to work with a GUI API known as Tcl/Tk. Because TIPS has been redesigned from the bottom up, bugs fixed in the previous version of the GUI interface may have been reintroduced or bugs may exist in the code itself. If you find a bug, the staff (i.e. the TA in charge) would appreciate it if the bug was brought to his attention via email or the newsgroup. Therefore, if you find a bug in the oracle or in the interface, or if you have suggestions to improve the interface, please contact the TA in charge.
Things to ponder