event.py revision 11988
111988Sandreas.sandberg@arm.com# Copyright (c) 2017 ARM Limited 211988Sandreas.sandberg@arm.com# All rights reserved. 311988Sandreas.sandberg@arm.com# 411988Sandreas.sandberg@arm.com# The license below extends only to copyright in the software and shall 511988Sandreas.sandberg@arm.com# not be construed as granting a license to any other intellectual 611988Sandreas.sandberg@arm.com# property including but not limited to intellectual property relating 711988Sandreas.sandberg@arm.com# to a hardware implementation of the functionality of the software 811988Sandreas.sandberg@arm.com# licensed hereunder. You may use the software subject to the license 911988Sandreas.sandberg@arm.com# terms below provided that you ensure that this notice is replicated 1011988Sandreas.sandberg@arm.com# unmodified and in its entirety in all distributions of the software, 1111988Sandreas.sandberg@arm.com# modified or unmodified, in source code or in binary form. 1211988Sandreas.sandberg@arm.com# 134167Sbinkertn@umich.edu# Copyright (c) 2006 The Regents of The University of Michigan 149983Sstever@gmail.com# Copyright (c) 2013 Advanced Micro Devices, Inc. 159983Sstever@gmail.com# Copyright (c) 2013 Mark D. Hill and David A. Wood 164167Sbinkertn@umich.edu# All rights reserved. 174167Sbinkertn@umich.edu# 184167Sbinkertn@umich.edu# Redistribution and use in source and binary forms, with or without 194167Sbinkertn@umich.edu# modification, are permitted provided that the following conditions are 204167Sbinkertn@umich.edu# met: redistributions of source code must retain the above copyright 214167Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer; 224167Sbinkertn@umich.edu# redistributions in binary form must reproduce the above copyright 234167Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer in the 244167Sbinkertn@umich.edu# documentation and/or other materials provided with the distribution; 254167Sbinkertn@umich.edu# neither the name of the copyright holders nor the names of its 264167Sbinkertn@umich.edu# contributors may be used to endorse or promote products derived from 274167Sbinkertn@umich.edu# this software without specific prior written permission. 284167Sbinkertn@umich.edu# 294167Sbinkertn@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 304167Sbinkertn@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 314167Sbinkertn@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 324167Sbinkertn@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 334167Sbinkertn@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 344167Sbinkertn@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 354167Sbinkertn@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 364167Sbinkertn@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 374167Sbinkertn@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 384167Sbinkertn@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 394167Sbinkertn@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 404167Sbinkertn@umich.edu# 414167Sbinkertn@umich.edu# Authors: Nathan Binkert 424167Sbinkertn@umich.edu 435696Snate@binkert.orgimport m5 4411802Sandreas.sandberg@arm.comimport _m5.event 454167Sbinkertn@umich.edu 4611988Sandreas.sandberg@arm.comfrom _m5.event import GlobalSimLoopExitEvent as SimExit 4711988Sandreas.sandberg@arm.comfrom _m5.event import Event, getEventQueue, setEventQueue 485605Snate@binkert.org 499983Sstever@gmail.commainq = None 505605Snate@binkert.org 515605Snate@binkert.orgclass ProgressEvent(Event): 525605Snate@binkert.org def __init__(self, eventq, period): 535605Snate@binkert.org super(ProgressEvent, self).__init__() 544167Sbinkertn@umich.edu self.period = int(period) 555605Snate@binkert.org self.eventq = eventq 565605Snate@binkert.org self.eventq.schedule(self, m5.curTick() + self.period) 574167Sbinkertn@umich.edu 584167Sbinkertn@umich.edu def __call__(self): 594167Sbinkertn@umich.edu print "Progress! Time now %fs" % (m5.curTick()/1e12) 605605Snate@binkert.org self.eventq.schedule(self, m5.curTick() + self.period) 615605Snate@binkert.org 6211988Sandreas.sandberg@arm.com__all__ = [ 'Event', 'ProgressEvent', 'SimExit', 'mainq' ] 63