sim_events.hh revision 5606
12SN/A/* 21762SN/A * Copyright (c) 2002-2005 The Regents of The University of Michigan 32SN/A * All rights reserved. 42SN/A * 52SN/A * Redistribution and use in source and binary forms, with or without 62SN/A * modification, are permitted provided that the following conditions are 72SN/A * met: redistributions of source code must retain the above copyright 82SN/A * notice, this list of conditions and the following disclaimer; 92SN/A * redistributions in binary form must reproduce the above copyright 102SN/A * notice, this list of conditions and the following disclaimer in the 112SN/A * documentation and/or other materials provided with the distribution; 122SN/A * neither the name of the copyright holders nor the names of its 132SN/A * contributors may be used to endorse or promote products derived from 142SN/A * this software without specific prior written permission. 152SN/A * 162SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu * 282665Ssaidi@eecs.umich.edu * Authors: Nathan Binkert 292SN/A */ 302SN/A 311798SN/A#ifndef __SIM_SIM_EVENTS_HH__ 321798SN/A#define __SIM_SIM_EVENTS_HH__ 332SN/A 3456SN/A#include "sim/eventq.hh" 352SN/A 362SN/A// 372SN/A// Event to terminate simulation at a particular cycle/instruction 382SN/A// 392667Sstever@eecs.umich.educlass SimLoopExitEvent : public Event 402SN/A{ 415606Snate@binkert.org protected: 422SN/A // string explaining why we're terminating 432SN/A std::string cause; 442SN/A int code; 453144Shsul@eecs.umich.edu Tick repeat; 462SN/A 472SN/A public: 485606Snate@binkert.org SimLoopExitEvent(const std::string &_cause, int c, Tick repeat = 0); 492SN/A 502667Sstever@eecs.umich.edu std::string getCause() { return cause; } 512667Sstever@eecs.umich.edu int getCode() { return code; } 522SN/A 535543Ssaidi@eecs.umich.edu void process(); // process event 542SN/A 555336Shines@cs.fsu.edu virtual const char *description() const; 562SN/A}; 572SN/A 582839Sktlim@umich.educlass CountedDrainEvent : public SimLoopExitEvent 592797Sktlim@umich.edu{ 602797Sktlim@umich.edu private: 612839Sktlim@umich.edu // Count of how many objects have not yet drained 622797Sktlim@umich.edu int count; 635606Snate@binkert.org 642797Sktlim@umich.edu public: 655606Snate@binkert.org CountedDrainEvent(); 665606Snate@binkert.org 672797Sktlim@umich.edu void process(); 682797Sktlim@umich.edu 692797Sktlim@umich.edu void setCount(int _count) { count = _count; } 702797Sktlim@umich.edu 712797Sktlim@umich.edu int getCount() { return count; } 722797Sktlim@umich.edu}; 732797Sktlim@umich.edu 742SN/A// 752SN/A// Event class to terminate simulation after 'n' related events have 762SN/A// occurred using a shared counter: used to terminate when *all* 772SN/A// threads have reached a particular instruction count 782SN/A// 792SN/Aclass CountedExitEvent : public Event 802SN/A{ 812SN/A private: 825543Ssaidi@eecs.umich.edu std::string cause; // string explaining why we're terminating 835543Ssaidi@eecs.umich.edu int &downCounter; // decrement & terminate if zero 842SN/A 852SN/A public: 865606Snate@binkert.org CountedExitEvent(const std::string &_cause, int &_downCounter); 872SN/A 885543Ssaidi@eecs.umich.edu void process(); // process event 892SN/A 905336Shines@cs.fsu.edu virtual const char *description() const; 912SN/A}; 922SN/A 932SN/A// 941798SN/A// Event to check swap usage 952SN/A// 962SN/Aclass CheckSwapEvent : public Event 972SN/A{ 982SN/A private: 992SN/A int interval; 1002SN/A 1012SN/A public: 1025606Snate@binkert.org CheckSwapEvent(int ival); 1035543Ssaidi@eecs.umich.edu void process(); // process event 1042SN/A 1055336Shines@cs.fsu.edu virtual const char *description() const; 1062SN/A}; 1072SN/A 1081798SN/A#endif // __SIM_SIM_EVENTS_HH__ 109