hmc_hello.py revision 12340
1# Copyright (c) 2017, University of Kaiserslautern
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met:
7#
8# 1. Redistributions of source code must retain the above copyright notice,
9#    this list of conditions and the following disclaimer.
10#
11# 2. Redistributions in binary form must reproduce the above copyright
12#    notice, this list of conditions and the following disclaimer in the
13#    documentation and/or other materials provided with the distribution.
14#
15# 3. Neither the name of the copyright holder nor the names of its
16#    contributors may be used to endorse or promote products derived from
17#    this software without specific prior written permission.
18#
19# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
23# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30#
31# Author: Éder F. Zulian
32
33import sys
34import argparse
35
36import m5
37from m5.objects import *
38from m5.util import *
39addToPath('../')
40from common import MemConfig
41from common import HMC
42
43
44pd = "Simple 'hello world' example using HMC as main memory"
45parser = argparse.ArgumentParser(description=pd)
46HMC.add_options(parser)
47options = parser.parse_args()
48# create the system we are going to simulate
49system = System()
50# use timing mode for the interaction between master-slave ports
51system.mem_mode = 'timing'
52# set the clock fequency of the system
53clk = '1GHz'
54vd = VoltageDomain(voltage='1V')
55system.clk_domain = SrcClockDomain(clock=clk, voltage_domain=vd)
56# create a simple CPU
57system.cpu = TimingSimpleCPU()
58# config memory system
59MemConfig.config_mem(options, system)
60# hook the CPU ports up to the membus
61system.cpu.icache_port = system.membus.slave
62system.cpu.dcache_port = system.membus.slave
63# create the interrupt controller for the CPU and connect to the membus
64system.cpu.createInterruptController()
65# connect special port in the system to the membus. This port is a
66# functional-only port to allow the system to read and write memory.
67system.system_port = system.membus.slave
68# get ISA for the binary to run.
69isa = str(m5.defines.buildEnv['TARGET_ISA']).lower()
70# run 'hello' and use the compiled ISA to find the binary
71binary = 'tests/test-progs/hello/bin/' + isa + '/linux/hello'
72# create a process for a simple "Hello World" application
73process = Process()
74# cmd is a list which begins with the executable (like argv)
75process.cmd = [binary]
76# set the cpu workload
77system.cpu.workload = process
78# create thread contexts
79system.cpu.createThreads()
80# set up the root SimObject
81root = Root(full_system=False, system=system)
82m5.instantiate()
83m5.simulate()
84