hello_goodbye.py revision 12337
11689SN/A# -*- coding: utf-8 -*-
22326SN/A# Copyright (c) 2017 Jason Lowe-Power
31689SN/A# All rights reserved.
41689SN/A#
51689SN/A# Redistribution and use in source and binary forms, with or without
61689SN/A# modification, are permitted provided that the following conditions are
71689SN/A# met: redistributions of source code must retain the above copyright
81689SN/A# notice, this list of conditions and the following disclaimer;
91689SN/A# redistributions in binary form must reproduce the above copyright
101689SN/A# notice, this list of conditions and the following disclaimer in the
111689SN/A# documentation and/or other materials provided with the distribution;
121689SN/A# neither the name of the copyright holders nor the names of its
131689SN/A# contributors may be used to endorse or promote products derived from
141689SN/A# this software without specific prior written permission.
151689SN/A#
161689SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
171689SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
181689SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
191689SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
201689SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
211689SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
221689SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
231689SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
241689SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
251689SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
261689SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
271689SN/A#
281689SN/A# Authors: Jason Lowe-Power
291060SN/A
301060SN/A"""
311689SN/AA simple run file that creates two SimObjects: HelloObject and GoodbyeObject
321060SN/Aand then runs the simulation. Using the debug "Hello" is informative.
331060SN/A
341060SN/AIMPORTANT: If you modify this file, it's likely that the Learning gem5 book
351060SN/A           also needs to be updated. For now, email Jason <power.jg@gmail.com>
362292SN/A
371717SN/A"""
381060SN/A
392292SN/A# import the m5 (gem5) library created when gem5 is built
402292SN/Aimport m5
411681SN/A# import all of the SimObjects
422292SN/Afrom m5.objects import *
432326SN/A
441061SN/A# set up the root SimObject and start the simulation
451060SN/Aroot = Root(full_system = False)
461061SN/A
472292SN/A# Create an instantiation of the simobject you created
482292SN/Aroot.hello = HelloObject(time_to_wait = '2us', number_of_fires = 5)
492292SN/Aroot.hello.goodbye_object = GoodbyeObject(buffer_size='100B')
502292SN/A
512292SN/A# instantiate all of the objects we've created above
522292SN/Am5.instantiate()
532292SN/A
542307SN/Aprint "Beginning simulation!"
552307SN/Aexit_event = m5.simulate()
561060SN/Aprint 'Exiting @ tick %i because %s' % (m5.curTick(), exit_event.getCause())
572292SN/A