Browse Source

Add function to print cache

masstesting
Adam Goldsmith 6 years ago
parent
commit
92ae2a0a2b
  1. 20
      csim.c

20
csim.c

@ -44,6 +44,8 @@ linked_line** make_cache(long set_indices, long num_lines); @@ -44,6 +44,8 @@ linked_line** make_cache(long set_indices, long num_lines);
linked_line* make_set(linked_line* newer, long num_lines);
void free_cache(linked_line** cache, long num_sets);
void free_set(linked_line* line);
void print_cache(linked_line** cache, long num_sets);
void print_set(linked_line* line);
/* Global variables */
uint8_t VERBOSE = 0; /**< If nonzero, mprintf will not print. Set in main() if -v flag is given. */
@ -93,6 +95,8 @@ int main(int argc, char* argv[]) @@ -93,6 +95,8 @@ int main(int argc, char* argv[])
linked_line** cache = make_cache(set_indices, num_lines);
print_cache(cache, set_indices);
/* FILE READING */
FILE* f = fopen(filename, "r");
if(!f)
@ -177,6 +181,22 @@ void free_set(linked_line* line) { @@ -177,6 +181,22 @@ void free_set(linked_line* line) {
}
}
void print_cache(linked_line** cache, long num_sets)
{
int ii;
for (ii = 0; ii < num_sets; ii++) {
print_set(cache[ii]);
}
}
void print_set(linked_line* line)
{
if (line != NULL) {
print_set(line->older);
printf("%p %x.%lx %p:%p\n", (void *) line, line->validity, line->tag, (void *) line->newer, (void *) line->older);
}
}
void print_usage(void)
{
printf("Usage: ./csim [-hv] -s <number> -E <number> -b <number> -t <file>\n"