MI_example.py revision 6906
14120Sgblack@eecs.umich.edu# Copyright (c) 2006-2007 The Regents of The University of Michigan
24120Sgblack@eecs.umich.edu# Copyright (c) 2009 Advanced Micro Devices, Inc.
34120Sgblack@eecs.umich.edu# All rights reserved.
44120Sgblack@eecs.umich.edu#
57087Snate@binkert.org# Redistribution and use in source and binary forms, with or without
67087Snate@binkert.org# modification, are permitted provided that the following conditions are
77087Snate@binkert.org# met: redistributions of source code must retain the above copyright
87087Snate@binkert.org# notice, this list of conditions and the following disclaimer;
97087Snate@binkert.org# redistributions in binary form must reproduce the above copyright
107087Snate@binkert.org# notice, this list of conditions and the following disclaimer in the
117087Snate@binkert.org# documentation and/or other materials provided with the distribution;
127087Snate@binkert.org# neither the name of the copyright holders nor the names of its
134120Sgblack@eecs.umich.edu# contributors may be used to endorse or promote products derived from
147087Snate@binkert.org# this software without specific prior written permission.
157087Snate@binkert.org#
167087Snate@binkert.org# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
177087Snate@binkert.org# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
187087Snate@binkert.org# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
197087Snate@binkert.org# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
207087Snate@binkert.org# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
217087Snate@binkert.org# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
224120Sgblack@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
237087Snate@binkert.org# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
244120Sgblack@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
254120Sgblack@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
264120Sgblack@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
274120Sgblack@eecs.umich.edu#
284120Sgblack@eecs.umich.edu# Authors: Brad Beckmann
294120Sgblack@eecs.umich.edu
304120Sgblack@eecs.umich.eduimport m5
314120Sgblack@eecs.umich.edufrom m5.objects import *
324120Sgblack@eecs.umich.edufrom m5.defines import buildEnv
334120Sgblack@eecs.umich.edufrom m5.util import addToPath
344120Sgblack@eecs.umich.edu
354120Sgblack@eecs.umich.edu#
364120Sgblack@eecs.umich.edu# Note: the cache latency is only used by the sequencer on fast path hits
374120Sgblack@eecs.umich.edu#
384120Sgblack@eecs.umich.educlass Cache(RubyCache):
394120Sgblack@eecs.umich.edu    latency = 3
404120Sgblack@eecs.umich.edu
414120Sgblack@eecs.umich.edudef create_system(options, phys_mem, piobus, dma_devices):
424120Sgblack@eecs.umich.edu
437720Sgblack@eecs.umich.edu    if buildEnv['PROTOCOL'] != 'MI_example':
444241Sgblack@eecs.umich.edu        panic("This script requires the MI_example protocol to be built.")
458768Sgblack@eecs.umich.edu
464148Sgblack@eecs.umich.edu    cpu_sequencers = []
474120Sgblack@eecs.umich.edu
484120Sgblack@eecs.umich.edu    #
497720Sgblack@eecs.umich.edu    # The ruby network creation expects the list of nodes in the system to be
507720Sgblack@eecs.umich.edu    # consistent with the NetDest list.  Therefore the l1 controller nodes must be
517720Sgblack@eecs.umich.edu    # listed before the directory nodes and directory nodes before dma nodes, etc.
527720Sgblack@eecs.umich.edu    #
537720Sgblack@eecs.umich.edu    l1_cntrl_nodes = []
547720Sgblack@eecs.umich.edu    dir_cntrl_nodes = []
557720Sgblack@eecs.umich.edu    dma_cntrl_nodes = []
567720Sgblack@eecs.umich.edu
577720Sgblack@eecs.umich.edu    #
587707Sgblack@eecs.umich.edu    # Must create the individual controllers before the network to ensure the
597707Sgblack@eecs.umich.edu    # controller constructors are called before the network constructor
605086Sgblack@eecs.umich.edu    #
614148Sgblack@eecs.umich.edu
624148Sgblack@eecs.umich.edu    for i in xrange(options.num_cpus):
634148Sgblack@eecs.umich.edu        #
648768Sgblack@eecs.umich.edu        # First create the Ruby objects associated with this cpu
658768Sgblack@eecs.umich.edu        # Only one cache exists for this protocol, so by default use the L1D
668768Sgblack@eecs.umich.edu        # config parameters.
678768Sgblack@eecs.umich.edu        #
688768Sgblack@eecs.umich.edu        cache = Cache(size = options.l1d_size,
698768Sgblack@eecs.umich.edu                      assoc = options.l1d_assoc)
704148Sgblack@eecs.umich.edu
714148Sgblack@eecs.umich.edu        #
724148Sgblack@eecs.umich.edu        # Only one unified L1 cache exists.  Can cache instructions and data.
734148Sgblack@eecs.umich.edu        #
744148Sgblack@eecs.umich.edu        cpu_seq = RubySequencer(icache = cache,
754148Sgblack@eecs.umich.edu                                dcache = cache,
764148Sgblack@eecs.umich.edu                                physMemPort = phys_mem.port,
774148Sgblack@eecs.umich.edu                                physmem = phys_mem)
784148Sgblack@eecs.umich.edu
795135Sgblack@eecs.umich.edu        if piobus != None:
805135Sgblack@eecs.umich.edu            cpu_seq.pio_port = piobus.port
815135Sgblack@eecs.umich.edu
826329Sgblack@eecs.umich.edu        l1_cntrl = L1Cache_Controller(version = i,
836329Sgblack@eecs.umich.edu                                      sequencer = cpu_seq,
846329Sgblack@eecs.umich.edu                                      cacheMemory = cache)
856329Sgblack@eecs.umich.edu        #
867693SAli.Saidi@ARM.com        # Add controllers and sequencers to the appropriate lists
877693SAli.Saidi@ARM.com        #
887720Sgblack@eecs.umich.edu        cpu_sequencers.append(cpu_seq)
897720Sgblack@eecs.umich.edu        l1_cntrl_nodes.append(l1_cntrl)
9010417Sandreas.hansson@arm.com
917720Sgblack@eecs.umich.edu    phys_mem_size = long(phys_mem.range.second) - long(phys_mem.range.first) + 1
927720Sgblack@eecs.umich.edu    mem_module_size = phys_mem_size / options.num_dirs
937720Sgblack@eecs.umich.edu
948300Schander.sudanthi@arm.com    for i in xrange(options.num_dirs):
958300Schander.sudanthi@arm.com        #
968300Schander.sudanthi@arm.com        # Create the Ruby objects associated with the directory controller
978300Schander.sudanthi@arm.com        #
988300Schander.sudanthi@arm.com
998300Schander.sudanthi@arm.com        mem_cntrl = RubyMemoryControl(version = i)
1008300Schander.sudanthi@arm.com
1019759Sandreas@sandberg.pp.se        dir_size = MemorySize('0B')
1029759Sandreas@sandberg.pp.se        dir_size.value = mem_module_size
1039759Sandreas@sandberg.pp.se
1049759Sandreas@sandberg.pp.se        dir_cntrl = Directory_Controller(version = i,
1059759Sandreas@sandberg.pp.se                                         directory = \
1069759Sandreas@sandberg.pp.se                                         RubyDirectoryMemory(version = i,
1079759Sandreas@sandberg.pp.se                                                             size = dir_size),
1089759Sandreas@sandberg.pp.se                                         memBuffer = mem_cntrl)
1099759Sandreas@sandberg.pp.se
1109759Sandreas@sandberg.pp.se        dir_cntrl_nodes.append(dir_cntrl)
1119759Sandreas@sandberg.pp.se
1129759Sandreas@sandberg.pp.se    for i, dma_device in enumerate(dma_devices):
1139759Sandreas@sandberg.pp.se        #
1149759Sandreas@sandberg.pp.se        # Create the Ruby objects associated with the dma controller
1159759Sandreas@sandberg.pp.se        #
1169759Sandreas@sandberg.pp.se        dma_seq = DMASequencer(version = i,
1179759Sandreas@sandberg.pp.se                               physMemPort = phys_mem.port,
1189759Sandreas@sandberg.pp.se                               physmem = phys_mem)
1199759Sandreas@sandberg.pp.se
1209759Sandreas@sandberg.pp.se        dma_cntrl = DMA_Controller(version = i,
1219759Sandreas@sandberg.pp.se                                   dma_sequencer = dma_seq)
1229759Sandreas@sandberg.pp.se
1239759Sandreas@sandberg.pp.se        dma_cntrl.dma_sequencer.port = dma_device.dma
1249759Sandreas@sandberg.pp.se        dma_cntrl_nodes.append(dma_cntrl)
1259759Sandreas@sandberg.pp.se
1269759Sandreas@sandberg.pp.se    all_cntrls = l1_cntrl_nodes + dir_cntrl_nodes + dma_cntrl_nodes
1279759Sandreas@sandberg.pp.se
1289759Sandreas@sandberg.pp.se    return (cpu_sequencers, dir_cntrl_nodes, all_cntrls)
1299759Sandreas@sandberg.pp.se