Fix cache_access

This commit is contained in:
Adam Goldsmith 2016-04-28 01:54:20 -04:00
parent 9997f58137
commit e457f4dee0
1 changed files with 6 additions and 10 deletions

16
csim.c
View File

@ -234,17 +234,13 @@ char cache_access(linked_line** cache, long address, int set_bits, int block_bit
else if (line->tag == tag) out = 'H'; else if (line->tag == tag) out = 'H';
else out = 'E'; else out = 'E';
if (line != set_head) { if(!(line == set_head)) {
line->newer = NULL; line->newer->older = line->older;
set_head->newer = line; if(line->older)
line->older = set_head;
if (line->older) {
line->older->newer = line->newer; line->older->newer = line->newer;
if (line->older->older == line) line->newer = NULL;
line->older->older = NULL; line->older = set_head;
} set_head->newer = line;
if (line->newer)
line->newer->older = line->older;
cache[set] = line; cache[set] = line;
} }