#include #include #include "bool.h" #include "computer.h" int main (int argc, char *argv[]) { int argIndex; int printingRegisters = FALSE; int printingMemory = FALSE; int printingCache = FALSE; int debugging = FALSE; int interactive = FALSE; FILE *filein; Computer computer; int associativity = 1, nsets = 4, blocksize = 2; if (argc < 2) { fprintf (stderr, "Not enough arguments.\n"); return 1; } for (argIndex=1; argIndex> i) & 0x1; if (count != 1) { fprintf (stderr, "Associativity must be a power of 2.\n"); return 1; } count = 0; for (i = 0; i < 32; i++) count += (nsets >> i) & 0x1; if (count != 1) { fprintf (stderr, "Sets must be a power of 2.\n"); return 1; } count = 0; for (i = 0; i < 32; i++) count += (blocksize >> i) & 0x1; if (count != 1) { fprintf (stderr, "Blocksize must be a power of 2.\n"); return 1; } if (argIndex == argc) { fprintf (stderr, "No file name given.\n"); return 1; } else if (argIndex < argc-1) { fprintf (stderr, "Too many arguments.\n"); return 1; } filein = fopen (argv[argIndex], "rb"); if (filein == NULL) { fprintf (stderr, "Can't open file: %s\n", argv[argIndex]); return 1; } computer = newComputer(1024, 3072, associativity, nsets, blocksize, filein, printingRegisters, printingMemory, printingCache, debugging, interactive); simulate (computer); return 0; }