/* Author : Rick van der Zwet * S-number : 0433373 * Version : $Id: memory.h 363 2007-12-03 06:07:31Z rick $ * Copyright : FreeBSD Licence * Description : Small libary to include most common functions * cycles */ #include #include "common.h" /* Print of struct bus2_t mainly for debugging purposes */ void fprintfbus2(FILE * output, struct bus2_t * line) { fprintf(output, "type: %c, ", line->type); fprintf(output, "size: %i, ", line->size); fprintf(output, "address: %12i, ", line->address); fprintf(output, "rcount: %i, ", line->rcount); fprintf(output, "icount: %i, ", line->icount); fprintf(output, "\n"); } /* Push the bus2 lines into a bus2 struct */ int fscanfbus2(struct bus2_t * line) { return fscanf(stdin, "BUS2 %c %i %x %i %i\n", &line->type, &line->size, &line->address, &line->rcount, &line->icount); } void setstats(struct bus2_t * line, struct result_t * output) { /* Both calls are 'in cache calls' */ output->incache += line->rcount; output->incache += line->icount; /* Minus one, cause the current call is also included */ output->incache--; /* Raise the cache miss counter */ output->misses++; } void printfresult(FILE * output, struct result_t * result) { long bytes = result->incache * 4; float bandwidth = (float)bytes / result->cycles; fprintf(output, "Total cycles : %li\n", result->cycles); fprintf(output, "Cache misses : %li\n", result->misses); fprintf(output, "Cache bytes : %li\n", bytes); fprintf(output, "Bandwidth [1] : %.2f\n", bandwidth); fprintf(output, "Bankconflicts : %li\n", result->conflicts); fprintf(output, "---\n"); fprintf(output, "[1] Bytes/cycle CPU <> Cache\n"); }