int main(int argc, char const *argv[]) { configureTheSize(argc, argv); FILE *iImage = fopen(IIMAGE_PATH, "rb"); FILE *dImage = fopen(DIMAGE_PATH, "rb"); snapshot = fopen(SNAPSHOT_PATH, "w"); //error = fopen(ERROR_PATH, "w"); rpt = fopen(REPORT_PATH, "w"); //debug = fopen(DEBUG_PATH, "w"); fread(&cPC, sizeof(int), 1, iImage); fread(&iNum, sizeof(int), 1, iImage); for (int i = 0; i < 32; i++) { regs[i] = 0; } //read iImage to iMemory for (int i = 0; i < 128; i++) { iDisk[i] = 0; } fread(&iDisk[0+cPC/4], sizeof(int), iNum, iImage); //read dImage to dMemory fread(®s[29], sizeof(int), 1, dImage); fread(&dNum, sizeof(int), 1, dImage); for (int i = 0; i < 128; i++) { dDisk[i] = 0; } iSP = regs[29]; fread(&dDisk, sizeof(int), dNum, dImage); //execution starts here /* printf("IMeomory\n"); for (int i = 0; i<iNum;i++) { printf("%d: %08x\n", i, iMemory[i]); } printf("DMeomory\n"); for (int i = 0; i<dNum;i++) { printf("%d: %08x\n", i, dMemory[i]); }*/ cycleCount = 0; halt = false; while(1){ prSnapshot(snapshot, cycleCount); cycleCount++; //printf("Cycle:%2d\n", cycleCount); if(addOverflow(cPC)) break; if(misAlign(cPC, 4)) break; ICacheCal(ITLBCal(cPC)); if(cycle(iDisk[cPC/4])) break; } prReport(rpt); fclose(iImage); fclose(dImage); fclose(snapshot); fclose(rpt); //fclose(error); return 0; }
void add(uint32_t ip) { if (counts_[ip] == 255) { addOverflow(ip); } else { counts_[ip]++; if (counts_[ip] > top.count) { top.ip = ip; top.count = counts_[ip]; } } }