event.py revision 4167
14167Sbinkertn@umich.edu# Copyright (c) 2006 The Regents of The University of Michigan
24167Sbinkertn@umich.edu# All rights reserved.
34167Sbinkertn@umich.edu#
44167Sbinkertn@umich.edu# Redistribution and use in source and binary forms, with or without
54167Sbinkertn@umich.edu# modification, are permitted provided that the following conditions are
64167Sbinkertn@umich.edu# met: redistributions of source code must retain the above copyright
74167Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer;
84167Sbinkertn@umich.edu# redistributions in binary form must reproduce the above copyright
94167Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer in the
104167Sbinkertn@umich.edu# documentation and/or other materials provided with the distribution;
114167Sbinkertn@umich.edu# neither the name of the copyright holders nor the names of its
124167Sbinkertn@umich.edu# contributors may be used to endorse or promote products derived from
134167Sbinkertn@umich.edu# this software without specific prior written permission.
144167Sbinkertn@umich.edu#
154167Sbinkertn@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
164167Sbinkertn@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
174167Sbinkertn@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
184167Sbinkertn@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
194167Sbinkertn@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
204167Sbinkertn@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
214167Sbinkertn@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
224167Sbinkertn@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
234167Sbinkertn@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
244167Sbinkertn@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
254167Sbinkertn@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
264167Sbinkertn@umich.edu#
274167Sbinkertn@umich.edu# Authors: Nathan Binkert
284167Sbinkertn@umich.edu
294167Sbinkertn@umich.edufrom internal.event import create
304167Sbinkertn@umich.edufrom internal.event import SimLoopExitEvent as SimExit
314167Sbinkertn@umich.edu
324167Sbinkertn@umich.educlass ProgressEvent(object):
334167Sbinkertn@umich.edu    def __init__(self, period):
344167Sbinkertn@umich.edu        self.period = int(period)
354167Sbinkertn@umich.edu        self.schedule()
364167Sbinkertn@umich.edu
374167Sbinkertn@umich.edu    def schedule(self):
384167Sbinkertn@umich.edu        create(self, m5.curTick() + self.period)
394167Sbinkertn@umich.edu
404167Sbinkertn@umich.edu    def __call__(self):
414167Sbinkertn@umich.edu        print "Progress! Time now %fs" % (m5.curTick()/1e12)
424167Sbinkertn@umich.edu        self.schedule()
43