simulate.cc (10670:3bfbaefa3844) simulate.cc (10756:f9c0692f73ec)
1/*
2 * Copyright (c) 2006 The Regents of The University of Michigan
3 * Copyright (c) 2013 Advanced Micro Devices, Inc.
4 * Copyright (c) 2013 Mark D. Hill and David A. Wood
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are

--- 57 unchanged lines hidden (view full) ---

66thread_loop(EventQueue *queue)
67{
68 while (true) {
69 threadBarrier->wait();
70 doSimLoop(queue);
71 }
72}
73
1/*
2 * Copyright (c) 2006 The Regents of The University of Michigan
3 * Copyright (c) 2013 Advanced Micro Devices, Inc.
4 * Copyright (c) 2013 Mark D. Hill and David A. Wood
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are

--- 57 unchanged lines hidden (view full) ---

66thread_loop(EventQueue *queue)
67{
68 while (true) {
69 threadBarrier->wait();
70 doSimLoop(queue);
71 }
72}
73
74GlobalEvent*
75getLimitEvent(void) {
76 static GlobalSimLoopExitEvent
77 simulate_limit_event(mainEventQueue[0]->getCurTick(),
78 "simulate() limit reached", 0);
79 return &simulate_limit_event;
80}
81
74/** Simulate for num_cycles additional cycles. If num_cycles is -1
75 * (the default), do not limit simulation; some other event must
76 * terminate the loop. Exported to Python via SWIG.
77 * @return The SimLoopExitEvent that caused the loop to exit.
78 */
79GlobalSimLoopExitEvent *
80simulate(Tick num_cycles)
81{

--- 18 unchanged lines hidden (view full) ---

100
101 inform("Entering event queue @ %d. Starting simulation...\n", curTick());
102
103 if (num_cycles < MaxTick - curTick())
104 num_cycles = curTick() + num_cycles;
105 else // counter would roll over or be set to MaxTick anyhow
106 num_cycles = MaxTick;
107
82/** Simulate for num_cycles additional cycles. If num_cycles is -1
83 * (the default), do not limit simulation; some other event must
84 * terminate the loop. Exported to Python via SWIG.
85 * @return The SimLoopExitEvent that caused the loop to exit.
86 */
87GlobalSimLoopExitEvent *
88simulate(Tick num_cycles)
89{

--- 18 unchanged lines hidden (view full) ---

108
109 inform("Entering event queue @ %d. Starting simulation...\n", curTick());
110
111 if (num_cycles < MaxTick - curTick())
112 num_cycles = curTick() + num_cycles;
113 else // counter would roll over or be set to MaxTick anyhow
114 num_cycles = MaxTick;
115
108 GlobalEvent *limit_event = new GlobalSimLoopExitEvent(num_cycles,
109 "simulate() limit reached", 0, 0);
116 getLimitEvent()->reschedule(num_cycles);
110
111 GlobalSyncEvent *quantum_event = NULL;
112 if (numMainEventQueues > 1) {
113 if (simQuantum == 0) {
114 fatal("Quantum for multi-eventq simulation not specified");
115 }
116
117 quantum_event = new GlobalSyncEvent(curTick() + simQuantum, simQuantum,

--- 14 unchanged lines hidden (view full) ---

132 // locate the global exit event and return it to Python
133 BaseGlobalEvent *global_event = local_event->globalEvent();
134 assert(global_event != NULL);
135
136 GlobalSimLoopExitEvent *global_exit_event =
137 dynamic_cast<GlobalSimLoopExitEvent *>(global_event);
138 assert(global_exit_event != NULL);
139
117
118 GlobalSyncEvent *quantum_event = NULL;
119 if (numMainEventQueues > 1) {
120 if (simQuantum == 0) {
121 fatal("Quantum for multi-eventq simulation not specified");
122 }
123
124 quantum_event = new GlobalSyncEvent(curTick() + simQuantum, simQuantum,

--- 14 unchanged lines hidden (view full) ---

139 // locate the global exit event and return it to Python
140 BaseGlobalEvent *global_event = local_event->globalEvent();
141 assert(global_event != NULL);
142
143 GlobalSimLoopExitEvent *global_exit_event =
144 dynamic_cast<GlobalSimLoopExitEvent *>(global_event);
145 assert(global_exit_event != NULL);
146
140 // if we didn't hit limit_event, delete it.
141 if (global_exit_event != limit_event) {
142 assert(limit_event->scheduled());
143 limit_event->deschedule();
144 delete limit_event;
145 }
146
147 //! Delete the simulation quantum event.
148 if (quantum_event != NULL) {
149 quantum_event->deschedule();
150 delete quantum_event;
151 }
152
153 return global_exit_event;
154}

--- 74 unchanged lines hidden ---
147 //! Delete the simulation quantum event.
148 if (quantum_event != NULL) {
149 quantum_event->deschedule();
150 delete quantum_event;
151 }
152
153 return global_exit_event;
154}

--- 74 unchanged lines hidden ---