112337Sjason@lowepower.com# -*- coding: utf-8 -*- 212337Sjason@lowepower.com# Copyright (c) 2017 Jason Lowe-Power 312337Sjason@lowepower.com# All rights reserved. 412337Sjason@lowepower.com# 512337Sjason@lowepower.com# Redistribution and use in source and binary forms, with or without 612337Sjason@lowepower.com# modification, are permitted provided that the following conditions are 712337Sjason@lowepower.com# met: redistributions of source code must retain the above copyright 812337Sjason@lowepower.com# notice, this list of conditions and the following disclaimer; 912337Sjason@lowepower.com# redistributions in binary form must reproduce the above copyright 1012337Sjason@lowepower.com# notice, this list of conditions and the following disclaimer in the 1112337Sjason@lowepower.com# documentation and/or other materials provided with the distribution; 1212337Sjason@lowepower.com# neither the name of the copyright holders nor the names of its 1312337Sjason@lowepower.com# contributors may be used to endorse or promote products derived from 1412337Sjason@lowepower.com# this software without specific prior written permission. 1512337Sjason@lowepower.com# 1612337Sjason@lowepower.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1712337Sjason@lowepower.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1812337Sjason@lowepower.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1912337Sjason@lowepower.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2012337Sjason@lowepower.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2112337Sjason@lowepower.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2212337Sjason@lowepower.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2312337Sjason@lowepower.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2412337Sjason@lowepower.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2512337Sjason@lowepower.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2612337Sjason@lowepower.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2712337Sjason@lowepower.com# 2812337Sjason@lowepower.com# Authors: Jason Lowe-Power 2912337Sjason@lowepower.com 3012337Sjason@lowepower.com""" 3112337Sjason@lowepower.comA simple run file that creates two SimObjects: HelloObject and GoodbyeObject 3212337Sjason@lowepower.comand then runs the simulation. Using the debug "Hello" is informative. 3312337Sjason@lowepower.com 3412337Sjason@lowepower.comIMPORTANT: If you modify this file, it's likely that the Learning gem5 book 3512337Sjason@lowepower.com also needs to be updated. For now, email Jason <power.jg@gmail.com> 3612337Sjason@lowepower.com 3712337Sjason@lowepower.com""" 3812337Sjason@lowepower.com 3912564Sgabeblack@google.comfrom __future__ import print_function 4013774Sandreas.sandberg@arm.comfrom __future__ import absolute_import 4112564Sgabeblack@google.com 4212337Sjason@lowepower.com# import the m5 (gem5) library created when gem5 is built 4312337Sjason@lowepower.comimport m5 4412337Sjason@lowepower.com# import all of the SimObjects 4512337Sjason@lowepower.comfrom m5.objects import * 4612337Sjason@lowepower.com 4712337Sjason@lowepower.com# set up the root SimObject and start the simulation 4812337Sjason@lowepower.comroot = Root(full_system = False) 4912337Sjason@lowepower.com 5012337Sjason@lowepower.com# Create an instantiation of the simobject you created 5112337Sjason@lowepower.comroot.hello = HelloObject(time_to_wait = '2us', number_of_fires = 5) 5212337Sjason@lowepower.comroot.hello.goodbye_object = GoodbyeObject(buffer_size='100B') 5312337Sjason@lowepower.com 5412337Sjason@lowepower.com# instantiate all of the objects we've created above 5512337Sjason@lowepower.comm5.instantiate() 5612337Sjason@lowepower.com 5712564Sgabeblack@google.comprint("Beginning simulation!") 5812337Sjason@lowepower.comexit_event = m5.simulate() 5912564Sgabeblack@google.comprint('Exiting @ tick %i because %s' % (m5.curTick(), exit_event.getCause())) 60