This is a cycle-by-cycle simulator for the simple architectural implementation described at http://aggregate.org/CPE380/simple.html.
Enter/edit your control and initialization here: /* This is a demo of how the simulator works.... Comments are done as they are in C, i.e., like this. */ /* Now a simple delay specification... */ delay 5 IN OUT SEL delay 20 ALU delay 15 ALUand ALUor ALUxor /* a little faster */ delay 36 MEM /* just a tad over one clock */ /* In order for JUMPonop to work, you need to define how opcodes are decoded; that's what "when" does. For each different type of instruction, you define a mask and match value; if ((ir & mask) == match), then the next state after JUMPonop will be the labeled one. Note the functions available for formatting fields.... */ when (op(0x3f)+funct(0x3f)) funct(32) Add when 0xfc000000 0x20000000 Addi /* Just like the CPE380 reference description... */ Start: PCout, MARin, MEMread, Yin CONST(4), ALUadd, Zin, UNTILmfc MDRout, IRin Zout, PCin, JUMPonop HALT /* Should end here on undecoded op */ Add: SELrs, REGout, Yin SELrt, REGout, ALUadd, Zin Zout, SELrd, REGin, JUMP(Start) Addi: SELrs, REGout, Yin IRimmedout, ALUadd, Zin Zout, SELrt, REGin, JUMP(Start) /* Initial values... all others are 0 */ $9=0x10000000 /* MEM[0]= MIPS "addi $10,$9,0x50" instruction */ MEM[0]=0x20000000+rs(9)+rt(10)+immed(0x50) /* MEM[4]= MIPS "add $11,$10,$9" instruction */ MEM[4]=funct(32)+rs(9)+rt(10)+rd(11) /* MEM[8]= an instruction with no when, to cause HALT */ MEM[8]=0 /* A few final value tests... */ PC#12 10 /* only if sim enough cycles */ $10#0x10000050 5 MEM#2 /* 2 points off per memory error */ MEM[0]#0x20000000+rs(9)+rt(10)+immed(0x50) MEM[4]#0x012a5820 MEM[8]#23 /* like this one */
A maximum of 10 clock cycles will be simulated.
Memory latency will be 3 clock cycles.
Report conditions at each clock cycle Report only warnings and errors Report timing and final conditions
The final status was a 56% match for that specified.
The following values were wrong: PC MEM[0x8]
The C program that generated this page was written by Hank Dietz using the CGIC library to implement the CGI interface.
Computer Organization and Design.