mem-ruby: Sequencer can be used without cache
[gem5.git] / configs / learning_gem5 / part3 / test_caches.py
1 # -*- coding: utf-8 -*-
2 # Copyright (c) 2017 Jason Power
3 # All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
7 # met: redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer;
9 # redistributions in binary form must reproduce the above copyright
10 # notice, this list of conditions and the following disclaimer in the
11 # documentation and/or other materials provided with the distribution;
12 # neither the name of the copyright holders nor the names of its
13 # contributors may be used to endorse or promote products derived from
14 # this software without specific prior written permission.
15 #
16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 """ This file creates a set of Ruby caches, the Ruby network, and a simple
29 point-to-point topology for the RubyRandomTester to use.
30 See Part 3 in the Learning gem5 book:
31 http://gem5.org/documentation/learning_gem5/part3/MSIintro
32
33 IMPORTANT: If you modify this file, it's likely that the Learning gem5 book
34 also needs to be updated. For now, email Jason <jason@lowepower.com>
35
36 """
37
38 from __future__ import print_function
39 from __future__ import absolute_import
40
41 from m5.defines import buildEnv
42 from m5.util import fatal
43
44 from m5.objects import *
45
46 from msi_caches import L1Cache, DirController, MyNetwork
47
48 class TestCacheSystem(RubySystem):
49
50 def __init__(self):
51 if buildEnv['PROTOCOL'] != 'MSI':
52 fatal("This system assumes MSI from learning gem5!")
53
54 super(TestCacheSystem, self).__init__()
55
56 def setup(self, system, tester, mem_ctrls):
57 """Set up the Ruby cache subsystem. Note: This can't be done in the
58 constructor because many of these items require a pointer to the
59 ruby system (self). This causes infinite recursion in initialize()
60 if we do this in the __init__.
61 Setting up for running the RubyRandomTester is a little different
62 than when we're using CPUs.
63 """
64 num_testers = tester.num_cpus
65
66 # Ruby's global network.
67 self.network = MyNetwork(self)
68
69 # MSI uses 3 virtual networks
70 self.number_of_virtual_networks = 3
71 self.network.number_of_virtual_networks = 3
72
73 self.controllers = \
74 [L1Cache(system, self, self) for i in range(num_testers)] + \
75 [DirController(self, system.mem_ranges, mem_ctrls)]
76
77 self.sequencers = [RubySequencer(version = i,
78 # I/D cache is combined and grab from ctrl
79 dcache = self.controllers[i].cacheMemory,
80 clk_domain = self.clk_domain,
81 ) for i in range(num_testers)]
82
83 for i,c in enumerate(self.controllers[0:len(self.sequencers)]):
84 c.sequencer = self.sequencers[i]
85
86 self.num_of_sequencers = len(self.sequencers)
87
88 # Create the network and connect the controllers.
89 # NOTE: This is quite different if using Garnet!
90 self.network.connectControllers(self.controllers)
91 self.network.setup_buffers()
92
93 # Set up a proxy port for the system_port. Used for load binaries and
94 # other functional-only things.
95 self.sys_port_proxy = RubyPortProxy()
96 system.system_port = self.sys_port_proxy.slave
97
98 # Connect up the sequencers to the random tester
99 for seq in self.sequencers:
100 if seq.support_data_reqs and seq.support_inst_reqs:
101 tester.cpuInstDataPort = seq.slave
102 elif seq.support_data_reqs:
103 tester.cpuDataPort = seq.slave
104 elif seq.support_inst_reqs:
105 tester.cpuInstDataPort = seq.slave
106
107 # Do not automatically retry stalled Ruby requests
108 seq.no_retry_on_stall = True
109
110 # Tell each sequencer this is the ruby tester so that it
111 # copies the subblock back to the checker
112 seq.using_ruby_tester = True