simulate.cc (7822:fc475ac7d2a4) | simulate.cc (7823:dac01f14f20f) |
---|---|
1/* 2 * Copyright (c) 2006 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 33 unchanged lines hidden (view full) --- 42/** Simulate for num_cycles additional cycles. If num_cycles is -1 43 * (the default), do not limit simulation; some other event must 44 * terminate the loop. Exported to Python via SWIG. 45 * @return The SimLoopExitEvent that caused the loop to exit. 46 */ 47SimLoopExitEvent * 48simulate(Tick num_cycles) 49{ | 1/* 2 * Copyright (c) 2006 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 33 unchanged lines hidden (view full) --- 42/** Simulate for num_cycles additional cycles. If num_cycles is -1 43 * (the default), do not limit simulation; some other event must 44 * terminate the loop. Exported to Python via SWIG. 45 * @return The SimLoopExitEvent that caused the loop to exit. 46 */ 47SimLoopExitEvent * 48simulate(Tick num_cycles) 49{ |
50 inform("Entering event queue @ %d. Starting simulation...\n", curTick); | 50 inform("Entering event queue @ %d. Starting simulation...\n", curTick()); |
51 52 if (num_cycles < 0) 53 fatal("simulate: num_cycles must be >= 0 (was %d)\n", num_cycles); | 51 52 if (num_cycles < 0) 53 fatal("simulate: num_cycles must be >= 0 (was %d)\n", num_cycles); |
54 else if (curTick + num_cycles < 0) //Overflow | 54 else if (curTick() + num_cycles < 0) //Overflow |
55 num_cycles = MaxTick; 56 else | 55 num_cycles = MaxTick; 56 else |
57 num_cycles = curTick + num_cycles; | 57 num_cycles = curTick() + num_cycles; |
58 59 Event *limit_event = 60 new SimLoopExitEvent("simulate() limit reached", 0); 61 mainEventQueue.schedule(limit_event, num_cycles); 62 63 while (1) { 64 // there should always be at least one event (the SimLoopExitEvent 65 // we just scheduled) in the queue 66 assert(!mainEventQueue.empty()); | 58 59 Event *limit_event = 60 new SimLoopExitEvent("simulate() limit reached", 0); 61 mainEventQueue.schedule(limit_event, num_cycles); 62 63 while (1) { 64 // there should always be at least one event (the SimLoopExitEvent 65 // we just scheduled) in the queue 66 assert(!mainEventQueue.empty()); |
67 assert(curTick <= mainEventQueue.nextTick() && | 67 assert(curTick() <= mainEventQueue.nextTick() && |
68 "event scheduled in the past"); 69 70 // forward current cycle to the time of the first event on the 71 // queue | 68 "event scheduled in the past"); 69 70 // forward current cycle to the time of the first event on the 71 // queue |
72 curTick = mainEventQueue.nextTick(); | 72 curTick(mainEventQueue.nextTick()); |
73 Event *exit_event = mainEventQueue.serviceOne(); 74 if (exit_event != NULL) { 75 // hit some kind of exit event; return to Python 76 // event must be subclass of SimLoopExitEvent... 77 SimLoopExitEvent *se_event; 78 se_event = dynamic_cast<SimLoopExitEvent *>(exit_event); 79 80 if (se_event == NULL) --- 41 unchanged lines hidden --- | 73 Event *exit_event = mainEventQueue.serviceOne(); 74 if (exit_event != NULL) { 75 // hit some kind of exit event; return to Python 76 // event must be subclass of SimLoopExitEvent... 77 SimLoopExitEvent *se_event; 78 se_event = dynamic_cast<SimLoopExitEvent *>(exit_event); 79 80 if (se_event == NULL) --- 41 unchanged lines hidden --- |