From: <jo...@us...> - 2008-09-12 13:20:55
|
Revision: 323 http://mspsim.svn.sourceforge.net/mspsim/?rev=323&view=rev Author: joxe Date: 2008-09-12 13:20:53 +0000 (Fri, 12 Sep 2008) Log Message: ----------- added maxCycles limit to emulateOp Modified Paths: -------------- mspsim/se/sics/mspsim/core/MSP430.java mspsim/se/sics/mspsim/core/MSP430Core.java Modified: mspsim/se/sics/mspsim/core/MSP430.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430.java 2008-09-12 06:32:41 UTC (rev 322) +++ mspsim/se/sics/mspsim/core/MSP430.java 2008-09-12 13:20:53 UTC (rev 323) @@ -111,7 +111,7 @@ nextOut = cycles + 20000007; } - if (emulateOP()) { + if (emulateOP(-1)) { instCtr++; if (execCounter != null) { @@ -172,7 +172,7 @@ } } - boolean emuOP = emulateOP(); + boolean emuOP = emulateOP(-1); if (emuOP) { if (execCounter != null) { execCounter[reg[PC]]++; @@ -196,7 +196,10 @@ return cycles; } - public long step(long max_cycles) { + /* + * Perform a single step (even if in LPM) but no longer than to maxCycles + 1 instr + */ + public long step(long maxCycles) { if (isRunning()) { throw new IllegalStateException("step not possible when CPU is running"); } @@ -214,13 +217,12 @@ boolean emuOP = false; - if (max_cycles > 0) { - while (cycles < max_cycles && !(emuOP = emulateOP())) { - /* Stuck in LPM - hopefully not more than 10000 times*/ + if (maxCycles > 0) { + while (cycles < maxCycles && !(emuOP = emulateOP(maxCycles))) { } } else { int ctr = 0; - while (!(emuOP = emulateOP()) && ctr++ < 10000) { + while (!(emuOP = emulateOP(-1)) && ctr++ < 10000) { /* Stuck in LPM - hopefully not more than 10000 times*/ } } Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-09-12 06:32:41 UTC (rev 322) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-09-12 13:20:53 UTC (rev 323) @@ -646,7 +646,7 @@ } /* returns true if any instruction was emulated - false if CpuOff */ - public boolean emulateOP() { + public boolean emulateOP(long maxCycles) { //System.out.println("CYCLES BEFORE: " + cycles); int pc = readRegister(PC); long startCycles = cycles; @@ -669,7 +669,12 @@ if (cpuOff) { // System.out.println("Jumping: " + (nextIOTickCycles - cycles)); // nextEventCycles must exist, otherwise CPU can not wake up!? - cycles = nextEventCycles; + if (maxCycles >= 0 && maxCycles < nextEventCycles) { + // Should it just freeze or take on extra cycle step if cycles > max? + cycles = cycles < maxCycles ? maxCycles : cycles; + } else { + cycles = nextEventCycles; + } return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |