BaseCPU.py revision 4776
14486Sbinkertn@umich.edu# Copyright (c) 2005-2007 The Regents of The University of Michigan
24486Sbinkertn@umich.edu# All rights reserved.
34486Sbinkertn@umich.edu#
44486Sbinkertn@umich.edu# Redistribution and use in source and binary forms, with or without
54486Sbinkertn@umich.edu# modification, are permitted provided that the following conditions are
64486Sbinkertn@umich.edu# met: redistributions of source code must retain the above copyright
74486Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer;
84486Sbinkertn@umich.edu# redistributions in binary form must reproduce the above copyright
94486Sbinkertn@umich.edu# notice, this list of conditions and the following disclaimer in the
104486Sbinkertn@umich.edu# documentation and/or other materials provided with the distribution;
114486Sbinkertn@umich.edu# neither the name of the copyright holders nor the names of its
124486Sbinkertn@umich.edu# contributors may be used to endorse or promote products derived from
134486Sbinkertn@umich.edu# this software without specific prior written permission.
144486Sbinkertn@umich.edu#
154486Sbinkertn@umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
164486Sbinkertn@umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
174486Sbinkertn@umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
184486Sbinkertn@umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
194486Sbinkertn@umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
204486Sbinkertn@umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
214486Sbinkertn@umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
224486Sbinkertn@umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
234486Sbinkertn@umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
244486Sbinkertn@umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
254486Sbinkertn@umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
264486Sbinkertn@umich.edu#
274486Sbinkertn@umich.edu# Authors: Nathan Binkert
284486Sbinkertn@umich.edu
293102SN/Afrom m5.SimObject import SimObject
303102SN/Afrom m5.params import *
313102SN/Afrom m5.proxy import *
322667SN/Afrom m5 import build_env
332998SN/Afrom Bus import Bus
344776Sgblack@eecs.umich.edufrom InstTracer import InstTracer
354776Sgblack@eecs.umich.edufrom ExeTracer import ExeTracer
363584SN/Aimport sys
372667SN/A
384776Sgblack@eecs.umich.edudefault_tracer = ExeTracer()
394776Sgblack@eecs.umich.edu
404486Sbinkertn@umich.eduif build_env['FULL_SYSTEM']:
414486Sbinkertn@umich.edu    if build_env['TARGET_ISA'] == 'alpha':
424486Sbinkertn@umich.edu        from AlphaTLB import AlphaDTB, AlphaITB
434486Sbinkertn@umich.edu
444486Sbinkertn@umich.edu    if build_env['TARGET_ISA'] == 'sparc':
454486Sbinkertn@umich.edu        from SparcTLB import SparcDTB, SparcITB
464486Sbinkertn@umich.edu
471692SN/Aclass BaseCPU(SimObject):
481366SN/A    type = 'BaseCPU'
491310SN/A    abstract = True
501310SN/A
512901SN/A    system = Param.System(Parent.any, "system object")
523170SN/A    cpu_id = Param.Int("CPU identifier")
533170SN/A
541530SN/A    if build_env['FULL_SYSTEM']:
553620SN/A        do_quiesce = Param.Bool(True, "enable quiesce instructions")
563617SN/A        do_checkpoint_insts = Param.Bool(True,
573617SN/A            "enable checkpoint pseudo instructions")
583617SN/A        do_statistics_insts = Param.Bool(True,
593617SN/A            "enable statistics pseudo instructions")
603617SN/A
613584SN/A        if build_env['TARGET_ISA'] == 'sparc':
623584SN/A            dtb = Param.SparcDTB(SparcDTB(), "Data TLB")
633584SN/A            itb = Param.SparcITB(SparcITB(), "Instruction TLB")
643584SN/A        elif build_env['TARGET_ISA'] == 'alpha':
653584SN/A            dtb = Param.AlphaDTB(AlphaDTB(), "Data TLB")
663584SN/A            itb = Param.AlphaITB(AlphaITB(), "Instruction TLB")
673584SN/A        else:
683584SN/A            print "Unknown architecture, can't pick TLBs"
693584SN/A            sys.exit(1)
701445SN/A    else:
711445SN/A        workload = VectorParam.Process("processes to run")
721310SN/A
731310SN/A    max_insts_all_threads = Param.Counter(0,
741310SN/A        "terminate when all threads have reached this inst count")
751310SN/A    max_insts_any_thread = Param.Counter(0,
761310SN/A        "terminate when any thread reaches this inst count")
771310SN/A    max_loads_all_threads = Param.Counter(0,
781310SN/A        "terminate when all threads have reached this load count")
791310SN/A    max_loads_any_thread = Param.Counter(0,
801310SN/A        "terminate when any thread reaches this load count")
813878SN/A    progress_interval = Param.Tick(0,
823878SN/A        "interval to print out the progress message")
831310SN/A
841369SN/A    defer_registration = Param.Bool(False,
851310SN/A        "defer registration with system (for sampling)")
861634SN/A
874167SN/A    clock = Param.Clock('1t', "clock speed")
884167SN/A    phase = Param.Latency('0ns', "clock phase")
892998SN/A
904776Sgblack@eecs.umich.edu    tracer = Param.InstTracer(default_tracer, "Instruction tracer")
914776Sgblack@eecs.umich.edu
922998SN/A    _mem_ports = []
932998SN/A
942998SN/A    def connectMemPorts(self, bus):
952998SN/A        for p in self._mem_ports:
962998SN/A            exec('self.%s = bus.port' % p)
972998SN/A
982998SN/A    def addPrivateSplitL1Caches(self, ic, dc):
992998SN/A        assert(len(self._mem_ports) == 2)
1002998SN/A        self.icache = ic
1012998SN/A        self.dcache = dc
1022998SN/A        self.icache_port = ic.cpu_side
1032998SN/A        self.dcache_port = dc.cpu_side
1042998SN/A        self._mem_ports = ['icache.mem_side', 'dcache.mem_side']
1052998SN/A
1062998SN/A    def addTwoLevelCacheHierarchy(self, ic, dc, l2c):
1072998SN/A        self.addPrivateSplitL1Caches(ic, dc)
1082998SN/A        self.toL2Bus = Bus()
1092998SN/A        self.connectMemPorts(self.toL2Bus)
1102998SN/A        self.l2cache = l2c
1113017SN/A        self.l2cache.cpu_side = self.toL2Bus.port
1122998SN/A        self._mem_ports = ['l2cache.mem_side']
113