event.py (12041:52b3b120dbc0) event.py (12563:8d59ed22ae79)
1# Copyright (c) 2017 ARM Limited
2# All rights reserved.
3#
4# The license below extends only to copyright in the software and shall
5# not be construed as granting a license to any other intellectual
6# property including but not limited to intellectual property relating
7# to a hardware implementation of the functionality of the software
8# licensed hereunder. You may use the software subject to the license

--- 26 unchanged lines hidden (view full) ---

35# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40#
41# Authors: Nathan Binkert
42
1# Copyright (c) 2017 ARM Limited
2# All rights reserved.
3#
4# The license below extends only to copyright in the software and shall
5# not be construed as granting a license to any other intellectual
6# property including but not limited to intellectual property relating
7# to a hardware implementation of the functionality of the software
8# licensed hereunder. You may use the software subject to the license

--- 26 unchanged lines hidden (view full) ---

35# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40#
41# Authors: Nathan Binkert
42
43from __future__ import print_function
44
43import m5
44import _m5.event
45
46from _m5.event import GlobalSimLoopExitEvent as SimExit
47from _m5.event import PyEvent as Event
48from _m5.event import getEventQueue, setEventQueue
49
50mainq = None

--- 20 unchanged lines hidden (view full) ---

71class ProgressEvent(Event):
72 def __init__(self, eventq, period):
73 super(ProgressEvent, self).__init__()
74 self.period = int(period)
75 self.eventq = eventq
76 self.eventq.schedule(self, m5.curTick() + self.period)
77
78 def __call__(self):
45import m5
46import _m5.event
47
48from _m5.event import GlobalSimLoopExitEvent as SimExit
49from _m5.event import PyEvent as Event
50from _m5.event import getEventQueue, setEventQueue
51
52mainq = None

--- 20 unchanged lines hidden (view full) ---

73class ProgressEvent(Event):
74 def __init__(self, eventq, period):
75 super(ProgressEvent, self).__init__()
76 self.period = int(period)
77 self.eventq = eventq
78 self.eventq.schedule(self, m5.curTick() + self.period)
79
80 def __call__(self):
79 print "Progress! Time now %fs" % (m5.curTick()/1e12)
81 print("Progress! Time now %fs" % (m5.curTick()/1e12))
80 self.eventq.schedule(self, m5.curTick() + self.period)
81
82
83def create(func, priority=Event.Default_Pri):
84 """Create an Event from a function"""
85
86 return EventWrapper(func, priority=priority)
87
88__all__ = [ 'Event', 'EventWrapper', 'ProgressEvent', 'SimExit',
89 'mainq', 'create' ]
82 self.eventq.schedule(self, m5.curTick() + self.period)
83
84
85def create(func, priority=Event.Default_Pri):
86 """Create an Event from a function"""
87
88 return EventWrapper(func, priority=priority)
89
90__all__ = [ 'Event', 'EventWrapper', 'ProgressEvent', 'SimExit',
91 'mainq', 'create' ]