a guest Dec 7th, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import CacheTypes;
  3. // Address Helper Functions
  4. // NOTE: Each of these functions can be implemented with a single line.
  5. // Use the constants logCacheSets and logWordsPerLine, defined in
  6. ////////////////////////////////////////
  8. // Extract the Cache Line Index from a given memory address
  9. function CacheIndex getIndex(Word byteAddress);
  10.     return byteAddress[logWordsPerLine + logCacheSets+1:2+logWordsPerLine]; //TODO Your code here;
  11. endfunction
  13. // Extract the Cache Line Tag from a given memory address
  14. function CacheTag getTag(Word byteAddress);
  15.     return byteAddress[31: 2+logCacheSets + logWordsPerLine]; //TODO Your code here
  16. endfunction
  18. // Extract the Cache Line Word Offset from a given memory address
  19. function WordOffset getWordOffset(Word byteAddress);
  20.     return byteAddress[logWordsPerLine+1:2]; //TODO Your code here
  21. endfunction
  23. //Extract the line address (tag + index) from a given memory address
  24. function LineAddr getLineAddr(Word byteAddress);
  25.     return byteAddress[31:2+logWordsPerLine]; //TODO Your code here
  26. endfunction
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand