config.py revision 13082
112870Sgabeblack@google.com# Copyright 2018 Google, Inc.
212870Sgabeblack@google.com#
312870Sgabeblack@google.com# Redistribution and use in source and binary forms, with or without
412870Sgabeblack@google.com# modification, are permitted provided that the following conditions are
512870Sgabeblack@google.com# met: redistributions of source code must retain the above copyright
612870Sgabeblack@google.com# notice, this list of conditions and the following disclaimer;
712870Sgabeblack@google.com# redistributions in binary form must reproduce the above copyright
812870Sgabeblack@google.com# notice, this list of conditions and the following disclaimer in the
912870Sgabeblack@google.com# documentation and/or other materials provided with the distribution;
1012870Sgabeblack@google.com# neither the name of the copyright holders nor the names of its
1112870Sgabeblack@google.com# contributors may be used to endorse or promote products derived from
1212870Sgabeblack@google.com# this software without specific prior written permission.
1312870Sgabeblack@google.com#
1412870Sgabeblack@google.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1512870Sgabeblack@google.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1612870Sgabeblack@google.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1712870Sgabeblack@google.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1812870Sgabeblack@google.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1912870Sgabeblack@google.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2012870Sgabeblack@google.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2112870Sgabeblack@google.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2212870Sgabeblack@google.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2312870Sgabeblack@google.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2412870Sgabeblack@google.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2512870Sgabeblack@google.com#
2612870Sgabeblack@google.com# Authors: Gabe Black
2712870Sgabeblack@google.com
2812870Sgabeblack@google.comfrom __future__ import print_function
2912870Sgabeblack@google.com
3012870Sgabeblack@google.comimport m5
3113082Sgabeblack@google.comimport re
3212870Sgabeblack@google.com
3312870Sgabeblack@google.comfrom m5.objects import SystemC_Kernel, Root
3412870Sgabeblack@google.com
3512870Sgabeblack@google.com# pylint:disable=unused-variable
3612870Sgabeblack@google.com
3712870Sgabeblack@google.comkernel = SystemC_Kernel()
3812870Sgabeblack@google.comroot = Root(full_system=True, systemc_kernel=kernel)
3912870Sgabeblack@google.com
4012870Sgabeblack@google.comkernel.sc_main("Hello", "World");
4112870Sgabeblack@google.com
4212870Sgabeblack@google.comm5.instantiate(None)
4312870Sgabeblack@google.com
4412870Sgabeblack@google.comcause = m5.simulate(m5.MaxTick).getCause()
4513082Sgabeblack@google.com
4613082Sgabeblack@google.comresult = kernel.sc_main_result()
4713082Sgabeblack@google.comif result.code != 0:
4813082Sgabeblack@google.com    # Arguably this should make gem5 fail, but some tests purposefully
4913082Sgabeblack@google.com    # generate errors, and as long as their output matches that's still
5013082Sgabeblack@google.com    # considered correct. A "real" systemc config should expect sc_main
5113082Sgabeblack@google.com    # (if present) not to fail.
5213082Sgabeblack@google.com    scrubbed = re.sub(r'In file: .*$',
5313082Sgabeblack@google.com            'In file: <removed by verify.pl>',
5413082Sgabeblack@google.com            result.message)
5513082Sgabeblack@google.com    print('\n' + scrubbed)
56