-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple.py
72 lines (53 loc) · 2.07 KB
/
simple.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# import all gem'5 objects
import m5
from m5.objects import * #imports all SimObjects
#Instantiate a system
# "System" is a Python class wrapper for the System C++ SimObject
system = System()
# Initialze a clock and voltage domain
# "clk_domain" is a *parameter* of the System SimObject
system.clk_domain = SrcClockDomain()
system.clk_domain.clock = '1GHz'
# gem5 is smart enough automatically convert units
system.clk_domain.voltage_domain = VoltageDomain()
# let's set up the memory system
system.mem_mode = 'timing'
# You want to use *timing* for simulations, the options are things 'atomic' 'functional'(debug)
# All systems need memory!
system.mem_ranges = [AddrRange('512MB')]
# Let's create a CPU
system.cpu = TimingSimpleCPU()
# Now, we need a memory bus
system.membus = SystemXBar()
# Hook up CPU
system.cpu.icache_port = system.membus.cpu_side_ports
system.cpu.dcache_port = system.membus.cpu_side_ports
# Next, some BS to get things right
system.cpu.createInterruptController()
system.cpu.interrupts[0].pio = system.membus.mem_side_ports
system.cpu.interrupts[0].int_requestor = system.membus.cpu_side_ports
system.cpu.interrupts[0].int_responder = system.membus.mem_side_ports
system.system_port = system.membus.cpu_side_ports
# Now, you must create a memory controller and add a specific DRAM interface. Code from gem5-20.1.
system.mem_ctrl = MemCtrl()
# Finally, let's make the memory controller
system.mem_ctrl.dram = DDR3_1600_8x8()
# Set up physical memory ranges
system.mem_ctrl.dram.range = system.mem_ranges[0]
# Connect memory to bus
system.mem_ctrl.port = system.membus.mem_side_ports
# Now tell the system what we want it to do
process = Process()
process.cmd = ['tests/test-progs/hello/bin/x86/linux/hello']
system.cpu.workload = process
system.cpu.createThreads()
# Now, we're almost done
# Create a root object
root = Root(full_system = False, system = system)
# Instantiate all of the C++
m5.instantiate()
# We're ready to run!
print("Beginning simulation!")
exit_event = m5.simulate()
print('Exiting @ tick {} because {}'
.format(m5.curTick(), exit_event.getCause()))