CacheConfig.py revision 9793
17087Snate@binkert.org# Copyright (c) 2012-2013 ARM Limited
211329Salexandru.dutu@amd.com# All rights reserved
37087Snate@binkert.org#
47087Snate@binkert.org# The license below extends only to copyright in the software and shall
57087Snate@binkert.org# not be construed as granting a license to any other intellectual
67087Snate@binkert.org# property including but not limited to intellectual property relating
77087Snate@binkert.org# to a hardware implementation of the functionality of the software
87087Snate@binkert.org# licensed hereunder.  You may use the software subject to the license
97087Snate@binkert.org# terms below provided that you ensure that this notice is replicated
107087Snate@binkert.org# unmodified and in its entirety in all distributions of the software,
117087Snate@binkert.org# modified or unmodified, in source code or in binary form.
127087Snate@binkert.org#
137087Snate@binkert.org# Copyright (c) 2010 Advanced Micro Devices, Inc.
145359Sgblack@eecs.umich.edu# All rights reserved.
155359Sgblack@eecs.umich.edu#
165359Sgblack@eecs.umich.edu# Redistribution and use in source and binary forms, with or without
175359Sgblack@eecs.umich.edu# modification, are permitted provided that the following conditions are
185359Sgblack@eecs.umich.edu# met: redistributions of source code must retain the above copyright
195359Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer;
205359Sgblack@eecs.umich.edu# redistributions in binary form must reproduce the above copyright
215359Sgblack@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the
225359Sgblack@eecs.umich.edu# documentation and/or other materials provided with the distribution;
235359Sgblack@eecs.umich.edu# neither the name of the copyright holders nor the names of its
245359Sgblack@eecs.umich.edu# contributors may be used to endorse or promote products derived from
255359Sgblack@eecs.umich.edu# this software without specific prior written permission.
265359Sgblack@eecs.umich.edu#
275359Sgblack@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
285359Sgblack@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
295359Sgblack@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
305359Sgblack@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
315359Sgblack@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
325359Sgblack@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
335359Sgblack@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
345359Sgblack@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
355359Sgblack@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
365359Sgblack@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
375359Sgblack@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
385359Sgblack@eecs.umich.edu#
395359Sgblack@eecs.umich.edu# Authors: Lisa Hsu
405359Sgblack@eecs.umich.edu
415359Sgblack@eecs.umich.edu# Configure the M5 cache hierarchy config in one place
424561Sgblack@eecs.umich.edu#
434561Sgblack@eecs.umich.edu
444561Sgblack@eecs.umich.eduimport m5
454561Sgblack@eecs.umich.edufrom m5.objects import *
464561Sgblack@eecs.umich.edufrom Caches import *
474561Sgblack@eecs.umich.edu
484601Sgblack@eecs.umich.edudef config_cache(options, system):
494601Sgblack@eecs.umich.edu    if options.cpu_type == "arm_detailed":
504601Sgblack@eecs.umich.edu        try:
5110196SCurtis.Dunham@arm.com            from O3_ARM_v7a import *
524601Sgblack@eecs.umich.edu        except:
534601Sgblack@eecs.umich.edu            print "arm_detailed is unavailable. Did you compile the O3 model?"
544601Sgblack@eecs.umich.edu            sys.exit(1)
554601Sgblack@eecs.umich.edu
564601Sgblack@eecs.umich.edu        dcache_class, icache_class, l2_cache_class = \
574601Sgblack@eecs.umich.edu            O3_ARM_v7a_DCache, O3_ARM_v7a_ICache, O3_ARM_v7aL2
584601Sgblack@eecs.umich.edu    else:
594601Sgblack@eecs.umich.edu        dcache_class, icache_class, l2_cache_class = \
604601Sgblack@eecs.umich.edu            L1Cache, L1Cache, L2Cache
614601Sgblack@eecs.umich.edu
624601Sgblack@eecs.umich.edu    if options.l2cache:
634601Sgblack@eecs.umich.edu        # Provide a clock for the L2 and the L1-to-L2 bus here as they
644601Sgblack@eecs.umich.edu        # are not connected using addTwoLevelCacheHierarchy. Use the
654601Sgblack@eecs.umich.edu        # same clock as the CPUs, and set the L1-to-L2 bus width to 32
664601Sgblack@eecs.umich.edu        # bytes (256 bits).
674601Sgblack@eecs.umich.edu        system.l2 = l2_cache_class(clk_domain=system.cpu_clk_domain,
684601Sgblack@eecs.umich.edu                                   size=options.l2_size,
694601Sgblack@eecs.umich.edu                                   assoc=options.l2_assoc,
704601Sgblack@eecs.umich.edu                                   block_size=options.cacheline_size)
714601Sgblack@eecs.umich.edu
724601Sgblack@eecs.umich.edu        system.tol2bus = CoherentBus(clk_domain = system.cpu_clk_domain,
734601Sgblack@eecs.umich.edu                                     width = 32)
744601Sgblack@eecs.umich.edu        system.l2.cpu_side = system.tol2bus.master
754601Sgblack@eecs.umich.edu        system.l2.mem_side = system.membus.slave
764601Sgblack@eecs.umich.edu
777620Sgblack@eecs.umich.edu    for i in xrange(options.num_cpus):
786345Sgblack@eecs.umich.edu        if options.caches:
796345Sgblack@eecs.umich.edu            icache = icache_class(size=options.l1i_size,
806345Sgblack@eecs.umich.edu                                  assoc=options.l1i_assoc,
815912Sgblack@eecs.umich.edu                                  block_size=options.cacheline_size)
825912Sgblack@eecs.umich.edu            dcache = dcache_class(size=options.l1d_size,
834601Sgblack@eecs.umich.edu                                  assoc=options.l1d_assoc,
844601Sgblack@eecs.umich.edu                                  block_size=options.cacheline_size)
854601Sgblack@eecs.umich.edu
864601Sgblack@eecs.umich.edu            # When connecting the caches, the clock is also inherited
874601Sgblack@eecs.umich.edu            # from the CPU in question
884601Sgblack@eecs.umich.edu            if buildEnv['TARGET_ISA'] == 'x86':
894601Sgblack@eecs.umich.edu                system.cpu[i].addPrivateSplitL1Caches(icache, dcache,
904587Sgblack@eecs.umich.edu                                                      PageTableWalkerCache(),
9110196SCurtis.Dunham@arm.com                                                      PageTableWalkerCache())
924587Sgblack@eecs.umich.edu            else:
934587Sgblack@eecs.umich.edu                system.cpu[i].addPrivateSplitL1Caches(icache, dcache)
944587Sgblack@eecs.umich.edu        system.cpu[i].createInterruptController()
954587Sgblack@eecs.umich.edu        if options.l2cache:
964587Sgblack@eecs.umich.edu            system.cpu[i].connectAllPorts(system.tol2bus, system.membus)
974587Sgblack@eecs.umich.edu        else:
984587Sgblack@eecs.umich.edu            system.cpu[i].connectAllPorts(system.membus)
994587Sgblack@eecs.umich.edu
1004587Sgblack@eecs.umich.edu    return system
1014587Sgblack@eecs.umich.edu