1 # -*- coding: utf-8 -*-
2 # Copyright (c) 2017 Jason Power
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.
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.
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
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>
38 from __future__
import print_function
39 from __future__
import absolute_import
41 from m5
.defines
import buildEnv
42 from m5
.util
import fatal
44 from m5
.objects
import *
46 from msi_caches
import L1Cache
, DirController
, MyNetwork
48 class TestCacheSystem(RubySystem
):
51 if buildEnv
['PROTOCOL'] != 'MSI':
52 fatal("This system assumes MSI from learning gem5!")
54 super(TestCacheSystem
, self
).__init
__()
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.
64 num_testers
= tester
.num_cpus
66 # Ruby's global network.
67 self
.network
= MyNetwork(self
)
69 # MSI uses 3 virtual networks
70 self
.number_of_virtual_networks
= 3
71 self
.network
.number_of_virtual_networks
= 3
74 [L1Cache(system
, self
, self
) for i
in range(num_testers
)] + \
75 [DirController(self
, system
.mem_ranges
, mem_ctrls
)]
77 self
.sequencers
= [RubySequencer(version
= i
,
78 # I/D cache is combined and grab from ctrl
79 icache
= self
.controllers
[i
].cacheMemory
,
80 dcache
= self
.controllers
[i
].cacheMemory
,
81 clk_domain
= self
.clk_domain
,
82 ) for i
in range(num_testers
)]
84 for i
,c
in enumerate(self
.controllers
[0:len(self
.sequencers
)]):
85 c
.sequencer
= self
.sequencers
[i
]
87 self
.num_of_sequencers
= len(self
.sequencers
)
89 # Create the network and connect the controllers.
90 # NOTE: This is quite different if using Garnet!
91 self
.network
.connectControllers(self
.controllers
)
92 self
.network
.setup_buffers()
94 # Set up a proxy port for the system_port. Used for load binaries and
95 # other functional-only things.
96 self
.sys_port_proxy
= RubyPortProxy()
97 system
.system_port
= self
.sys_port_proxy
.slave
99 # Connect up the sequencers to the random tester
100 for seq
in self
.sequencers
:
101 if seq
.support_data_reqs
and seq
.support_inst_reqs
:
102 tester
.cpuInstDataPort
= seq
.slave
103 elif seq
.support_data_reqs
:
104 tester
.cpuDataPort
= seq
.slave
105 elif seq
.support_inst_reqs
:
106 tester
.cpuInstDataPort
= seq
.slave
108 # Do not automatically retry stalled Ruby requests
109 seq
.no_retry_on_stall
= True
111 # Tell each sequencer this is the ruby tester so that it
112 # copies the subblock back to the checker
113 seq
.using_ruby_tester
= True