config.py revision 13182
16657Snate@binkert.org# Copyright 2018 Google, Inc.
26657Snate@binkert.org#
36657Snate@binkert.org# Redistribution and use in source and binary forms, with or without
46657Snate@binkert.org# modification, are permitted provided that the following conditions are
56657Snate@binkert.org# met: redistributions of source code must retain the above copyright
66657Snate@binkert.org# notice, this list of conditions and the following disclaimer;
76657Snate@binkert.org# redistributions in binary form must reproduce the above copyright
86657Snate@binkert.org# notice, this list of conditions and the following disclaimer in the
96657Snate@binkert.org# documentation and/or other materials provided with the distribution;
106657Snate@binkert.org# neither the name of the copyright holders nor the names of its
116657Snate@binkert.org# contributors may be used to endorse or promote products derived from
126657Snate@binkert.org# this software without specific prior written permission.
136657Snate@binkert.org#
146657Snate@binkert.org# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
156657Snate@binkert.org# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
166657Snate@binkert.org# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
176657Snate@binkert.org# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
186657Snate@binkert.org# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
196657Snate@binkert.org# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
206657Snate@binkert.org# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
216657Snate@binkert.org# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
226657Snate@binkert.org# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
236657Snate@binkert.org# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
246657Snate@binkert.org# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
256657Snate@binkert.org#
266657Snate@binkert.org# Authors: Gabe Black
276657Snate@binkert.org
286657Snate@binkert.orgfrom __future__ import print_function
296657Snate@binkert.org
306657Snate@binkert.orgimport argparse
316657Snate@binkert.orgimport m5
3210308Snilay@cs.wisc.eduimport os
336657Snate@binkert.orgimport re
346657Snate@binkert.orgimport sys
356657Snate@binkert.org
366657Snate@binkert.orgfrom m5.objects import SystemC_Kernel, Root
3710307Snilay@cs.wisc.edu
3810308Snilay@cs.wisc.edu# pylint:disable=unused-variable
396657Snate@binkert.org
406657Snate@binkert.orgkernel = SystemC_Kernel()
416657Snate@binkert.orgroot = Root(full_system=True, systemc_kernel=kernel)
426657Snate@binkert.org
4310307Snilay@cs.wisc.eduparser = argparse.ArgumentParser()
449595Snilay@cs.wisc.eduparser.add_argument('--working-dir')
459595Snilay@cs.wisc.edu
466657Snate@binkert.orgargs = parser.parse_args()
476657Snate@binkert.orgif args.working_dir:
486657Snate@binkert.org    os.chdir(args.working_dir)
4910307Snilay@cs.wisc.edu
506657Snate@binkert.orgkernel.sc_main("Hello", "World");
516657Snate@binkert.org
529271Snilay@cs.wisc.edum5.instantiate(None)
536657Snate@binkert.org
546657Snate@binkert.orgcause = m5.simulate(m5.MaxTick).getCause()
556657Snate@binkert.org
5610005Snilay@cs.wisc.eduresult = kernel.sc_main_result()
5710005Snilay@cs.wisc.eduif result.code != 0:
5811111Snilay@cs.wisc.edu    # Arguably this should make gem5 fail, but some tests purposefully
5911111Snilay@cs.wisc.edu    # generate errors, and as long as their output matches that's still
606657Snate@binkert.org    # considered correct. A "real" systemc config should expect sc_main
616657Snate@binkert.org    # (if present) not to fail.
626657Snate@binkert.org    print('\n' + result.message)
6310307Snilay@cs.wisc.edu    sys.exit(int(result.code))
6410307Snilay@cs.wisc.edu