Add function to print cache
This commit is contained in:
parent
c26d27db9d
commit
92ae2a0a2b
20
csim.c
20
csim.c
@ -44,6 +44,8 @@ linked_line** make_cache(long set_indices, long num_lines);
|
|||||||
linked_line* make_set(linked_line* newer, long num_lines);
|
linked_line* make_set(linked_line* newer, long num_lines);
|
||||||
void free_cache(linked_line** cache, long num_sets);
|
void free_cache(linked_line** cache, long num_sets);
|
||||||
void free_set(linked_line* line);
|
void free_set(linked_line* line);
|
||||||
|
void print_cache(linked_line** cache, long num_sets);
|
||||||
|
void print_set(linked_line* line);
|
||||||
|
|
||||||
/* Global variables */
|
/* Global variables */
|
||||||
uint8_t VERBOSE = 0; /**< If nonzero, mprintf will not print. Set in main() if -v flag is given. */
|
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[])
|
|||||||
|
|
||||||
linked_line** cache = make_cache(set_indices, num_lines);
|
linked_line** cache = make_cache(set_indices, num_lines);
|
||||||
|
|
||||||
|
print_cache(cache, set_indices);
|
||||||
|
|
||||||
/* FILE READING */
|
/* FILE READING */
|
||||||
FILE* f = fopen(filename, "r");
|
FILE* f = fopen(filename, "r");
|
||||||
if(!f)
|
if(!f)
|
||||||
@ -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)
|
void print_usage(void)
|
||||||
{
|
{
|
||||||
printf("Usage: ./csim [-hv] -s <number> -E <number> -b <number> -t <file>\n"
|
printf("Usage: ./csim [-hv] -s <number> -E <number> -b <number> -t <file>\n"
|
||||||
|
Reference in New Issue
Block a user