Add cache implementation to compute cores #44
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TL;DR
Adds a simple, educational direct-mapped L1 cache between the LSU and memory controller.
Reduces memory traffic for repeated accesses while keeping the design minimal and easy to understand.
Includes a test demonstrating cache hits vs misses.
Implementation Details
New Files
src/cache.sv: Direct-mapped cache module (64 cache lines, write-through policy)src/lsu_cached.sv: Cache-enabled LSU that wraps the cache moduletest/test_cache.py: Test demonstrating cache effectivenessModified Files
src/core.sv: Updated to uselsu_cachedinstead oflsuMakefile: Updated to compile cache modulesArchitecture
Design Decisions
Testing
Run the cache test:
The test verifies:
test_matadd,test_matmul)Backward Compatibility
To use the original non-cached LSU, simply change
lsu_cachedback tolsuinsrc/core.sv.Future Enhancements
Possible extensions to this implementation: