import re import sys from m5.objects import SystemC_Kernel, Root # pylint:disable=unused-variable kernel = SystemC_Kernel() root = Root(full_system=True, systemc_kernel=kernel) parser = argparse.ArgumentParser() parser.add_argument('--working-dir') args = parser.parse_args() if args.working_dir: os.chdir(args.working_dir) kernel.sc_main() m5.instantiate(None) cause = m5.simulate(m5.MaxTick).getCause() result = kernel.sc_main_result() if result.code != 0: # Arguably this should make gem5 fail, but some tests purposefully # generate errors, and as long as their output matches that's still # considered correct. A "real" systemc config should expect sc_main # (if present) not to fail. sys.exit(int(result.code))
parser.add_argument( '--word', action="append", default=[], help='Add a word to the list of words to print. Can be repeated.') args = parser.parse_args() # Tell gem5 to run the c++ sc_main function. If one isn't defined, gem5 will # detect that and report an error. If gem5 isn't finding your sc_main, make # sure its signature matches exactly so your compiler doesn't think it's a # different function. # # The arguements passed to this function will be treated as the argv values # passed to the c++ sc_main, with the argc value set appropriately. kernel.sc_main(*args.word) # Construct the SimObject hierarchy. Anything sc_main built has already been # constructed. m5.instantiate(None) # Run the simulation until something kicks us back to the config file. sc_main # will be at the point it first called sc_start and may keep executing as the # simulation runs, or it may be completed if it never called sc_start. cause = m5.simulate(m5.MaxTick).getCause() # If sc_main finished, extract what it returned and do something with it. result = kernel.sc_main_result() if result.code != 0: sys.exit(int(result.code))
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # Authors: Gabe Black from __future__ import print_function import logging import m5 from m5.objects import SystemC_Kernel, Root # pylint:disable=unused-variable kernel = SystemC_Kernel() root = Root(full_system=True, systemc_kernel=kernel) kernel.sc_main("Hello", "World") m5.instantiate(None) cause = m5.simulate(m5.MaxTick).getCause() logging.info('Exiting @ tick %i because %s', m5.curTick(), cause)
import re import sys from m5.objects import SystemC_Kernel, Root # pylint:disable=unused-variable kernel = SystemC_Kernel() root = Root(full_system=True, systemc_kernel=kernel) parser = argparse.ArgumentParser() parser.add_argument('--working-dir') args = parser.parse_args() if args.working_dir: os.chdir(args.working_dir) kernel.sc_main('gem5_systemc_test') m5.instantiate(None) cause = m5.simulate(m5.MaxTick).getCause() result = kernel.sc_main_result() if result.code != 0: # Arguably this should make gem5 fail, but some tests purposefully # generate errors, and as long as their output matches that's still # considered correct. A "real" systemc config should expect sc_main # (if present) not to fail. sys.exit(int(result.code))
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # Authors: Gabe Black from __future__ import print_function import sys import m5 from m5.objects import SystemC_Kernel, Root # pylint:disable=unused-variable kernel = SystemC_Kernel() root = Root(full_system=True, systemc_kernel=kernel) kernel.sc_main(*sys.argv) m5.instantiate(None) cause = m5.simulate(m5.MaxTick).getCause() result = kernel.sc_main_result() if result.code != 0: m5.util.panic('sc_main return code was %d.' % result.code)