mirror of
				https://github.com/openhwgroup/cvw
				synced 2025-02-11 06:05:49 +00:00 
			
		
		
		
	Progress on fixing the cache simulator to support cbo instructions.
This commit is contained in:
		
							parent
							
								
									3137fd7db2
								
							
						
					
					
						commit
						0cf7b2e45a
					
				| @ -85,6 +85,14 @@ class Cache: | |||||||
|             for line in way: |             for line in way: | ||||||
|                 line.dirty = False |                 line.dirty = False | ||||||
| 
 | 
 | ||||||
|  |     # invalidate this specific line | ||||||
|  |     def cboinvalidate(self, addr): | ||||||
|  |         tag, setnum, _ = self.splitaddr(addr) | ||||||
|  |         for waynum in range(self.numways): | ||||||
|  |             line = self.ways[waynum][setnum] | ||||||
|  |             if line.tag == tag and line.valid: | ||||||
|  |                 line.dirty = 0 | ||||||
|  |      | ||||||
|     # invalidates the cache by setting all valid bits to False |     # invalidates the cache by setting all valid bits to False | ||||||
|     def invalidate(self): |     def invalidate(self): | ||||||
|         for way in self.ways: |         for way in self.ways: | ||||||
| @ -108,14 +116,15 @@ class Cache: | |||||||
|     # performs a cache access with the given address. |     # performs a cache access with the given address. | ||||||
|     # returns a character representing the outcome: |     # returns a character representing the outcome: | ||||||
|     # H/M/E/D - hit, miss, eviction, or eviction with writeback |     # H/M/E/D - hit, miss, eviction, or eviction with writeback | ||||||
|     def cacheaccess(self, addr, write=False): |     def cacheaccess(self, addr, write=False, clean=False): | ||||||
|         tag, setnum, _ = self.splitaddr(addr) |         tag, setnum, _ = self.splitaddr(addr) | ||||||
| 
 | 
 | ||||||
|         # check our ways to see if we have a hit |         # check our ways to see if we have a hit | ||||||
|  |         #print(f"addr is {addr:x} Set is {setnum}") | ||||||
|         for waynum in range(self.numways): |         for waynum in range(self.numways): | ||||||
|             line = self.ways[waynum][setnum] |             line = self.ways[waynum][setnum] | ||||||
|             if line.tag == tag and line.valid: |             if line.tag == tag and line.valid: | ||||||
|                 line.dirty = line.dirty or write |                 line.dirty = 0 if clean else line.dirty or write | ||||||
|                 self.update_pLRU(waynum, setnum) |                 self.update_pLRU(waynum, setnum) | ||||||
|                 return 'H' |                 return 'H' | ||||||
| 
 | 
 | ||||||
| @ -132,6 +141,7 @@ class Cache: | |||||||
|          |          | ||||||
|         # we need to evict. Select a victim and overwrite. |         # we need to evict. Select a victim and overwrite. | ||||||
|         victim = self.getvictimway(setnum) |         victim = self.getvictimway(setnum) | ||||||
|  |         #print(f"addr is {addr:x} Victim is {victim} Set is {setnum}") | ||||||
|         line = self.ways[victim][setnum] |         line = self.ways[victim][setnum] | ||||||
|         prevdirty = line.dirty |         prevdirty = line.dirty | ||||||
|         line.tag = tag |         line.tag = tag | ||||||
| @ -243,10 +253,15 @@ def main(): | |||||||
|                     cache.invalidate() |                     cache.invalidate() | ||||||
|                     if args.verbose: |                     if args.verbose: | ||||||
|                         print("I") |                         print("I") | ||||||
|  |                 elif lninfo[1] == 'C' or lninfo[1] == 'L': | ||||||
|  |                     cache.cboinvalidate() | ||||||
|  |                     if args.verbose: | ||||||
|  |                         print("C"); | ||||||
|                 else: |                 else: | ||||||
|                     addr = int(lninfo[0], 16) |                     addr = int(lninfo[0], 16) | ||||||
|                     iswrite = lninfo[1] == 'W' or lninfo[1] == 'A' |                     iswrite = lninfo[1] == 'W' or lninfo[1] == 'A' or lninfo[1] == 'Z' | ||||||
|                     result = cache.cacheaccess(addr, iswrite) |                     iscboclean = lninfo[1] == 'C' | ||||||
|  |                     result = cache.cacheaccess(addr, iswrite, iscboclean) | ||||||
|                      |                      | ||||||
|                     if args.verbose: |                     if args.verbose: | ||||||
|                         tag, setnum, offset = cache.splitaddr(addr) |                         tag, setnum, offset = cache.splitaddr(addr) | ||||||
|  | |||||||
| @ -210,6 +210,10 @@ module loggers import cvw::*; #(parameter cvw_t P, | |||||||
|                          dut.core.lsu.LSUAtomicM[1] ? "A" : |                          dut.core.lsu.LSUAtomicM[1] ? "A" : | ||||||
|                          dut.core.lsu.bus.dcache.CacheRWM == 2'b10 ? "R" :  |                          dut.core.lsu.bus.dcache.CacheRWM == 2'b10 ? "R" :  | ||||||
|                          dut.core.lsu.bus.dcache.CacheRWM == 2'b01 ? "W" : |                          dut.core.lsu.bus.dcache.CacheRWM == 2'b01 ? "W" : | ||||||
|  |                          dut.core.lsu.bus.dcache.dcache.CMOpM == 4'b1000 ? "Z" :   // cmo.zero
 | ||||||
|  |                          dut.core.lsu.bus.dcache.dcache.CMOpM == 4'b0001 ? "V" :   // cmo.inval should just clear the valid and dirty bits
 | ||||||
|  |                          dut.core.lsu.bus.dcache.dcache.CMOpM == 4'b0010 ? "C" :   // cmo.clean should act like a read in terms of the lru, but clears the dirty bit
 | ||||||
|  |                          dut.core.lsu.bus.dcache.dcache.CMOpM == 4'b0100 ? "L" :   // cmo.flush should just clear and the valid and drity bits
 | ||||||
|                          "NULL"; |                          "NULL"; | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user