1/* 2 * Copyright 2018 Google, Inc. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: redistributions of source code must retain the above copyright 7 * notice, this list of conditions and the following disclaimer; 8 * redistributions in binary form must reproduce the above copyright --- 304 unchanged lines hidden (view full) --- 313 if (pendingCurr()) 314 return 0; 315 if (pendingFuture()) 316 return timeSlots.begin()->first - getCurTick(); 317 return MaxTick - getCurTick(); 318 } 319 320 // Run scheduled channel updates. |
321 void runUpdate(); |
322 |
323 // Run delta events. 324 void runDelta(); 325 |
326 void setScMainFiber(Fiber *sc_main) { scMain = sc_main; } 327 328 void start(Tick max_tick, bool run_to_time); 329 void oneCycle(); 330 331 void schedulePause(); 332 void scheduleStop(bool finish_delta); 333 |
334 enum Status 335 { 336 StatusOther = 0, 337 StatusDelta, 338 StatusUpdate, 339 StatusTiming, 340 StatusPaused, 341 StatusStopped 342 }; |
343 |
344 bool paused() { return status() == StatusPaused; } 345 bool stopped() { return status() == StatusStopped; } 346 bool inDelta() { return status() == StatusDelta; } 347 bool inUpdate() { return status() == StatusUpdate; } 348 bool inTiming() { return status() == StatusTiming; } 349 |
350 uint64_t changeStamp() { return _changeStamp; } 351 352 void throwToScMain(const ::sc_core::sc_report *r=nullptr); 353 |
354 Status status() { return _status; } 355 void status(Status s) { _status = s; } 356 |
357 private: 358 typedef const EventBase::Priority Priority; 359 static Priority DefaultPriority = EventBase::Default_Pri; 360 361 static Priority StopPriority = DefaultPriority - 1; 362 static Priority PausePriority = DefaultPriority + 1; 363 static Priority MaxTickPriority = DefaultPriority + 2; 364 static Priority ReadyPriority = DefaultPriority + 3; --- 44 unchanged lines hidden (view full) --- 409 updateList.empty() && deltas.empty() && 410 (timeSlots.empty() || timeSlots.begin()->first > maxTick) && 411 initList.empty()); 412 } 413 EventWrapper<Scheduler, &Scheduler::pause> starvationEvent; 414 void scheduleStarvationEvent(); 415 416 bool _started; |
417 bool _stopNow; 418 |
419 Status _status; 420 |
421 Tick maxTick; 422 Tick lastReadyTick; 423 void 424 maxTickFunc() 425 { 426 if (lastReadyTick != getCurTick()) 427 _changeStamp++; 428 pause(); --- 21 unchanged lines hidden (view full) --- 450 std::map<::Event *, Tick> eventsToSchedule; 451}; 452 453extern Scheduler scheduler; 454 455inline void 456Scheduler::TimeSlot::process() 457{ |
458 scheduler.status(StatusTiming); 459 |
460 while (!events.empty()) 461 events.front()->run(); |
462 463 scheduler.status(StatusOther); |
464 scheduler.completeTimeSlot(this); 465} 466 467const ::sc_core::sc_report *reportifyException(); 468 469} // namespace sc_gem5 470 471#endif // __SYSTEMC_CORE_SCHEDULER_H__ |