Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/cache_sim.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Before getting started, here are some general notes on cache simulation in Ripes
The cache is configurable through the following options:

- **Ways**: Associativity specification. Specified in a power of two (ie. a "two-way set associative cache" will have `ways=1 (2^1 = 2 ways)` whereas a "direct mapped cache" will have `ways=0 (2^0 = 1 way)`).
- **Lines**: Number of cache lines. The number of cache lines will define the size of the `index` used to index within the cache. Specified in a power of two.
- **Words/Line**: Number of words within each cache line. The number of words will define the size of the `word index` used to select a word within a cache line. Specified in a power of two.
- **Sets**: Number of cache sets. The number of cache sets will define the size of the `index` used to index within the cache. Specified in a power of two.
- **Words per Line**: Number of words within each cache line. The number of words will define the size of the `word index` used to select a word within a cache line. Specified in a power of two.
- **Wr. hit/Wr. miss**: Cache write policies. Please refer to [this Wikipedia article](https://en.wikipedia.org/wiki/Cache_(computing)#Writing_policies) for further info.
- **Repl. policy**: Cache replacement policies. Please refer to [this Wikipedia article](https://en.wikipedia.org/wiki/Cache_replacement_policies) for further info.

Expand All @@ -37,8 +37,8 @@ Based on the current cache configuration, a visualization of the current state o
</p>
The cache is drawn as a table wherein rows are defined as:

- **Cache lines** are delimited with **solid** lines. The indices (index column) represents the index of each cache line.
- **Cache ways** are contained within a cache line. Ways which map within the same cache line are delimited with **dashed** lines.
- **Cache sets** are delimited with **solid** lines. The indices (index column) represents the index of each cache set.
- **Cache ways** are contained within a cache set. Ways which map within the same cache set are delimited with **dashed** lines.

Commonly, a set-associative cache will be drawn as separate tables for each way. This representation is equivalent with the representation used in Ripes, as follows:
<p align="center">
Expand All @@ -58,7 +58,7 @@ The cache view may be interacted with as follows:
- Clicking a word will move the memory view to the corresponding physical address of the cached value.
- The cache view may be zoomed by performing a `ctrl+scroll` operation (`cmd+scroll on OSX`).

When the cache is indexed, the corresponding _line_ row and _word_ column will be highlighted in yellow. The intersection of these corresponds to all the cells which may contain the cached value. Hence, for a direct mapped cache, only 1 cell will be in the intersection whereas for an _N_-way cache, _N_ cells will be highlighted. In the 4-way set associative cache picture above, we see that 4 cells are highlighted. A cell being highlighted as green indicates a cache hit, whilst red indicates a cache miss. A cell being highlighted in blue indicates that the value is dirty (with write-hit policy "write-back").
When the cache is indexed, the corresponding _set_ row and _word_ column will be highlighted in yellow. The intersection of these corresponds to all the cells which may contain the cached value. Hence, for a direct mapped cache, only 1 cell will be in the intersection whereas for an _N_-way cache, _N_ cells will be highlighted. In the 4-way set associative cache picture above, we see that 4 cells are highlighted. A cell being highlighted as green indicates a cache hit, whilst red indicates a cache miss. A cell being highlighted in blue indicates that the value is dirty (with write-hit policy "write-back").

### Cache Access Statistics & Plotting

Expand Down Expand Up @@ -160,10 +160,10 @@ We see that the cache manages a hit rate of `0.01154`. In the example program, w
4: 4608 = 0b00010010 00000000
...
```
For the chosen cache configuration we see that the line index of the cache is the following bitmask:
For the chosen cache configuration we see that the set index of the cache is determined by the following bitmask:
> `0b0000001 11110000`

Applying the bitmask to the access pattern listed above, we see that all access addresses mask to `0x0` and thus will index to the same cache line. In other words, we have no diversity with respect to the indexing in the cache for the given access pattern.
Applying the bitmask to the access pattern listed above, we see that all access addresses mask to `0x0` and thus will index to the same cache set. In other words, we have no diversity with respect to the indexing in the cache for the given access pattern.
In this case, a set-associative cache could be more suitable than a direct-mapped cache.

Select the cache preset `32-entry 4-word 2-way set associative`. Note that this cache design provides the _same_ number of possibly cached words as the previous direct-mapped design. Next, rerun the program.
Expand Down
Binary file modified resources/images/cacheconfig.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/cachesim/cacheconfigwidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;2&lt;span style=&quot; vertical-align:super;&quot;&gt;N&lt;/span&gt; Lines:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;2&lt;span style=&quot; vertical-align:super;&quot;&gt;N&lt;/span&gt; Sets:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
Expand All @@ -109,7 +109,7 @@
<item row="6" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;2&lt;span style=&quot; vertical-align:super;&quot;&gt;N&lt;/span&gt; Words/Line:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;2&lt;span style=&quot; vertical-align:super;&quot;&gt;N&lt;/span&gt; Words per Line:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
Expand Down
Loading