event.py revision 11988
112885Sspwilson2@wisc.edu# Copyright (c) 2017 ARM Limited
212885Sspwilson2@wisc.edu# All rights reserved.
312885Sspwilson2@wisc.edu#
412885Sspwilson2@wisc.edu# The license below extends only to copyright in the software and shall
512885Sspwilson2@wisc.edu# not be construed as granting a license to any other intellectual
612885Sspwilson2@wisc.edu# property including but not limited to intellectual property relating
712885Sspwilson2@wisc.edu# to a hardware implementation of the functionality of the software
812885Sspwilson2@wisc.edu# licensed hereunder.  You may use the software subject to the license
912885Sspwilson2@wisc.edu# terms below provided that you ensure that this notice is replicated
1012885Sspwilson2@wisc.edu# unmodified and in its entirety in all distributions of the software,
1112885Sspwilson2@wisc.edu# modified or unmodified, in source code or in binary form.
1212885Sspwilson2@wisc.edu#
1312885Sspwilson2@wisc.edu# Copyright (c) 2006 The Regents of The University of Michigan
1412885Sspwilson2@wisc.edu# Copyright (c) 2013 Advanced Micro Devices, Inc.
1512885Sspwilson2@wisc.edu# Copyright (c) 2013 Mark D. Hill and David A. Wood
1612885Sspwilson2@wisc.edu# All rights reserved.
1712885Sspwilson2@wisc.edu#
1812885Sspwilson2@wisc.edu# Redistribution and use in source and binary forms, with or without
1912885Sspwilson2@wisc.edu# modification, are permitted provided that the following conditions are
2012885Sspwilson2@wisc.edu# met: redistributions of source code must retain the above copyright
2112885Sspwilson2@wisc.edu# notice, this list of conditions and the following disclaimer;
2212885Sspwilson2@wisc.edu# redistributions in binary form must reproduce the above copyright
2312885Sspwilson2@wisc.edu# notice, this list of conditions and the following disclaimer in the
2412885Sspwilson2@wisc.edu# documentation and/or other materials provided with the distribution;
2512885Sspwilson2@wisc.edu# neither the name of the copyright holders nor the names of its
2612885Sspwilson2@wisc.edu# contributors may be used to endorse or promote products derived from
2712885Sspwilson2@wisc.edu# this software without specific prior written permission.
2812885Sspwilson2@wisc.edu#
2912885Sspwilson2@wisc.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3012885Sspwilson2@wisc.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3112885Sspwilson2@wisc.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3212885Sspwilson2@wisc.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3312885Sspwilson2@wisc.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3412885Sspwilson2@wisc.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3512885Sspwilson2@wisc.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3612885Sspwilson2@wisc.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3712885Sspwilson2@wisc.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3812885Sspwilson2@wisc.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3914142Snikos.nikoleris@arm.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4012885Sspwilson2@wisc.edu#
4112885Sspwilson2@wisc.edu# Authors: Nathan Binkert
4212885Sspwilson2@wisc.edu
4314142Snikos.nikoleris@arm.comimport m5
4414142Snikos.nikoleris@arm.comimport _m5.event
4514142Snikos.nikoleris@arm.com
4614142Snikos.nikoleris@arm.comfrom _m5.event import GlobalSimLoopExitEvent as SimExit
4712885Sspwilson2@wisc.edufrom _m5.event import Event, getEventQueue, setEventQueue
4812885Sspwilson2@wisc.edu
4912885Sspwilson2@wisc.edumainq = None
5012885Sspwilson2@wisc.edu
5112885Sspwilson2@wisc.educlass ProgressEvent(Event):
5212885Sspwilson2@wisc.edu    def __init__(self, eventq, period):
5312885Sspwilson2@wisc.edu        super(ProgressEvent, self).__init__()
5412885Sspwilson2@wisc.edu        self.period = int(period)
5512885Sspwilson2@wisc.edu        self.eventq = eventq
5612885Sspwilson2@wisc.edu        self.eventq.schedule(self, m5.curTick() + self.period)
5712885Sspwilson2@wisc.edu
5812885Sspwilson2@wisc.edu    def __call__(self):
5914142Snikos.nikoleris@arm.com        print "Progress! Time now %fs" % (m5.curTick()/1e12)
6012885Sspwilson2@wisc.edu        self.eventq.schedule(self, m5.curTick() + self.period)
6112885Sspwilson2@wisc.edu
62__all__ = [ 'Event', 'ProgressEvent', 'SimExit', 'mainq' ]
63