// // mips.C // // Description: // The AD Modified MIPS32(TM) processor. // // Version: // $Id$ // // Revision: // $Log$ // // Author: // Brian J. Alliet // #include "includes.h" static void run() { while(imem.MAR().uvalue() != 0xdeadbeef) { // check if we have to stall :-( if(branch()) { if(CPUObject::debug&CPUObject::trace) cout << endl << "---> STALLING FOR THE NEXT CLOCK CYCLE <---" << endl; } else { fetch(); } decode(); execute(); memory(); writeback(); Clock::tick(); } } int main(int argc, char **argv) { if(argc < 2) { fprintf(stderr,"Usage: %s image\n",argv[0]); exit(EXIT_FAILURE); } bool debug = argc >= 3 && strcmp(argv[2],"debug")==0; std::cout << std::hex; if(debug) CPUObject::debug |= CPUObject::trace; // create all of the MIPS CPU hardware connections make_connections(); // load I/D memory const char *image = argc < 2 ? "mem" : argv[1]; imem.load(image); dmem.load(image); if(debug) imem.dump(0x10000,0x10073); if(argc >= 5) { long start = strtol(argv[3],NULL,0); long length = strtol(argv[4],NULL,0); dmem.dump(start,start+length-1); } // HACK: Initialize PC StorageObject& pc = imem.MAR(); pc.latchFrom(imem.READ()); Clock::tick(); run(); cout << *regs[V0] << endl; if(argc >= 5) { long start = strtol(argv[3],NULL,0); long length = strtol(argv[4],NULL,0); dmem.dump(start,start+length-1); } return EXIT_SUCCESS; }