From be35fbd2bbedc94478568f3694571900b1c40ec2 Mon Sep 17 00:00:00 2001 From: Rushil Umaretiya Date: Wed, 10 Apr 2024 20:39:56 -0400 Subject: [PATCH] i cant read --- cache.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cache.c b/cache.c index fa725be..e4a2264 100644 --- a/cache.c +++ b/cache.c @@ -74,12 +74,18 @@ int cread(unsigned int cmf, unsigned int* hex_addr, bool* hit, bool* replace) { if (cache[line]->tag == tag) { // hit - *replace = true; + *hit = true; cache[line]->hit_count++; ret_val = cache[line]->block[block_offset]; } else { // miss - *hit = true; + if (cache[line]->tag == EMPTY) { + open_line = line; + } else { + replace_line = line; + *replace = true; + } + cache[line]->tag = tag; cache[line]->hit_count = 1;