Add cache implementation to compute cores#44
Open
Yellown42 wants to merge 1 commit intoadam-maj:masterfrom
Open
Add cache implementation to compute cores#44Yellown42 wants to merge 1 commit intoadam-maj:masterfrom
Yellown42 wants to merge 1 commit intoadam-maj:masterfrom
Conversation
- Implement direct-mapped cache (64 lines, write-through policy) - Add cache.sv module for data caching between LSU and memory controller - Add lsu_cached.sv as cache-enabled LSU variant - Update core.sv to use lsu_cached - Update Makefile to compile cache modules - Add test_cache.py to demonstrate cache effectiveness with data reuse patterns The cache stores recently accessed data to reduce global memory traffic. Each thread has its own cache instance, providing significant performance improvements for workloads with temporal locality (repeated data access).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: