Due: 10:30 pm Wednesday May 2022
Summary: You will implement a direct-mapped cache for a read-only memory in Logisim.
Collaboration: You will work during lab in randomly assigned pairs. You must complete the work together in these groups, whether during or after the scheduled lab time.
Submitting: Submit your cache.circ
and references.txt
to the appropriate Assignment in Gradescope. Be sure to follow the submission guidelines and use precisely these file names. You do not need to submit your test sequence from part D, but make sure you have this signed off before the lab deadline.
In this lab, you will implement a direct-mapped cache for read-only memory in Logisim.
Your grade for the Logisim portions of this assignment will be determined by how many tests your cache implementation can pass.
Additional consideration will be given to the clarity of organization within your circuits. Wires, gates, and pins should be laid out in a fashion that facilitates comprehension.
The memory system you are implementing will use eight bit addresses and a four-entry cache with four-byte cache lines. Before starting your implementation, answer the following questions:
Have the instructor or a mentor approve your answers before moving on to the next part of the lab.
For this part of the lab you will implement a single entry for the direct-mapped cache. To start, download the cache.circ
and cache-test.circ
starter circuit files.
The file cache-test.circ
contains an instance of your cache connected to a read-only memory element, a clock, an address input, and data output. This component will be useful in a later part of the lab.
For now, open cache.circ
in Logisim and double-click the “cache-entry” subcircuit to open it. Remember that you can start Logisim with the following shell command:
$ java -jar /home/curtsinger/shared/logisim.jar &
The “cache-entry” subcircuit implements a single entry in a cache. The subcircuit in the provided Logisim file has the following inputs:
data_in
tag
clock
data_in
input and the tag
. Reading from the cache entry is always enabled.
The subcircuit also has the following outputs:
data_out
miss
To complete this part of the lab you will need to implement a cache entry in this subcircuit. You will need registers to hold
Make sure your cache entry correctly reports a miss, and will store both the data input and tag on the clock input’s falling edge. We want these registers to update on the falling edge rather than the rising edge to allow time for the ROM read to occur while the clock input is high. At the end of the high clock signal, the registers should store the value from ROM. Warning: The default for registers in Logisim is to store on the rising edge. Do not forget to change your registers to update on the falling edge.
Do not add any additional inputs or outputs to this subcircuit or edit the subcircuit’s appearance.
Ask the instructor or a mentor to sign off on this part of the lab before moving on.
Once you have completed your “cache-entry” subcircuit, you can use it to build your complete cache. To implement caching behavior, the “main” subcircuit is designed to sit in front of a ROM element. (You can see an example use of this cache in the cache-test.circ
circuit.) While the “main” subcircuit has been operationally “completed” for you, it does not yet implement a cache; instead, it passes along all requests to memory.
Open the cache-test.circ
file. You should see the following components:
Address
inputData
outputYou should use this circuit to test your cache implementation as you complete it. Note that you will likely need to close and re-open cache-test.circ
each time you edit your cache.circ
implementation.
If you look in the “main” subcircuit of cache.circ
, you should see some basic components already in place. First, let’s look at the main cache inputs and output:
address
inputread enable
inputdata_out
outputIn addition to these primary connections for the cache, the “main” subcircuit has three pins to interface with the ROM element:
ROM read address
outputROM read enable
outputROM data in
inputBefore completing your cache you will need to delete the wire connecting the read enable
input to the ROM read enable
output. The other components can stay in place, although you may need to move or modify them slightly.
Do not add any additional inputs or outputs to this subcircuit or edit the subcircuit’s appearance. Unfortunately, if you accidentally delete any inputs or outputs and even restore them with an “undo” (from the Edit menu), the damage has been done and the grading program will not recognize the circuit correctly. The only solution in that case is to open and rewire a new copy. So be careful!!
Use four copies of your “cache-entry” subcircuit to implement a four-entry direct-mapped cache:
You will need to use a splitter to break the requested address into its tag, index, and byte offset components.
Use the index to select between your four cache entries, and pass the tag in to each of the entries.
When there is a miss and the read enable
input is on, request data from ROM by turning on the ROM read enable
output. When the read enable
input falls, the registers in the selected cache entry will store the value read from ROM.
You should only pass this clock signal to the selected cache entry, since this will overwrite the cache entry’s contents.
Once you have output from the appropriate cache entry, use the byte offset bits from the address to select a byte from the 32-bit cache line; the multiplexor in the provided subcircuit already does this, so you may want to reuse the provided components.
You do not need to have anyone sign off on this part of the lab (it will be assessed by the autograder); instead, move on to the next part where you will design an access sequence to test your cache implementation.
Now that you have a (hopefully) working cache, you will need to design an exhaustive test for the cache. It is not enough just to verify that your cache returns the correct data; it must also access memory at the appropriate times. For example, if you access an address twice in a row, the cache should only access memory the first time.
Write down a series of memory accesses that you can perform using the cache-test.circ
test harness to verify that your cache has the following properties:
Write out your access pattern as well as the expected behavior for each access:
Verify that your cache has the expected behavior. When you have completed your tests, ask the instructor or a mentor to sign off on your tests. Be prepared to re-run your tests, and to explain how your access sequence demonstrates each of the four properties above.
Copyright © 2018, 2019, 2020, 2022 Charlie Curtsinger and Jerod Weinman
This work is licensed under a Creative Commons Attribution NonCommercial ShareAlike 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.