BaseCPU.py revision 5335
15335Shines@cs.fsu.edu# Copyright (c) 2005-2008 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
404997Sgblack@eecs.umich.eduif build_env['TARGET_ISA'] == 'alpha':
414997Sgblack@eecs.umich.edu    from AlphaTLB import AlphaDTB, AlphaITB
424997Sgblack@eecs.umich.eduelif build_env['TARGET_ISA'] == 'sparc':
434997Sgblack@eecs.umich.edu    from SparcTLB import SparcDTB, SparcITB
444997Sgblack@eecs.umich.eduelif build_env['TARGET_ISA'] == 'x86':
454997Sgblack@eecs.umich.edu    from X86TLB import X86DTB, X86ITB
464997Sgblack@eecs.umich.eduelif build_env['TARGET_ISA'] == 'mips':
475222Sksewell@umich.edu    from MipsTLB import MipsTLB,MipsDTB, MipsITB, MipsUTB
485335Shines@cs.fsu.eduelif build_env['TARGET_ISA'] == 'arm':
495335Shines@cs.fsu.edu    from ArmTLB import ArmTLB, ArmDTB, ArmITB, ArmUTB
504486Sbinkertn@umich.edu
511692SN/Aclass BaseCPU(SimObject):
521366SN/A    type = 'BaseCPU'
531310SN/A    abstract = True
541310SN/A
552901SN/A    system = Param.System(Parent.any, "system object")
563170SN/A    cpu_id = Param.Int("CPU identifier")
573170SN/A
581530SN/A    if build_env['FULL_SYSTEM']:
593620SN/A        do_quiesce = Param.Bool(True, "enable quiesce instructions")
603617SN/A        do_checkpoint_insts = Param.Bool(True,
613617SN/A            "enable checkpoint pseudo instructions")
623617SN/A        do_statistics_insts = Param.Bool(True,
633617SN/A            "enable statistics pseudo instructions")
641445SN/A    else:
651445SN/A        workload = VectorParam.Process("processes to run")
661310SN/A
674997Sgblack@eecs.umich.edu    if build_env['TARGET_ISA'] == 'sparc':
684997Sgblack@eecs.umich.edu        dtb = Param.SparcDTB(SparcDTB(), "Data TLB")
694997Sgblack@eecs.umich.edu        itb = Param.SparcITB(SparcITB(), "Instruction TLB")
704997Sgblack@eecs.umich.edu    elif build_env['TARGET_ISA'] == 'alpha':
714997Sgblack@eecs.umich.edu        dtb = Param.AlphaDTB(AlphaDTB(), "Data TLB")
724997Sgblack@eecs.umich.edu        itb = Param.AlphaITB(AlphaITB(), "Instruction TLB")
734997Sgblack@eecs.umich.edu    elif build_env['TARGET_ISA'] == 'x86':
744997Sgblack@eecs.umich.edu        dtb = Param.X86DTB(X86DTB(), "Data TLB")
754997Sgblack@eecs.umich.edu        itb = Param.X86ITB(X86ITB(), "Instruction TLB")
764997Sgblack@eecs.umich.edu    elif build_env['TARGET_ISA'] == 'mips':
775222Sksewell@umich.edu        UnifiedTLB = Param.Bool(True, "Is this a Unified TLB?")
784997Sgblack@eecs.umich.edu        dtb = Param.MipsDTB(MipsDTB(), "Data TLB")
794997Sgblack@eecs.umich.edu        itb = Param.MipsITB(MipsITB(), "Instruction TLB")
805222Sksewell@umich.edu        tlb = Param.MipsUTB(MipsUTB(), "Unified TLB")
815335Shines@cs.fsu.edu    elif build_env['TARGET_ISA'] == 'arm':
825335Shines@cs.fsu.edu        UnifiedTLB = Param.Bool(True, "Is this a Unified TLB?")
835335Shines@cs.fsu.edu        dtb = Param.ArmDTB(ArmDTB(), "Data TLB")
845335Shines@cs.fsu.edu        itb = Param.ArmITB(ArmITB(), "Instruction TLB")
855335Shines@cs.fsu.edu        tlb = Param.ArmUTB(ArmUTB(), "Unified TLB")
864997Sgblack@eecs.umich.edu    else:
874997Sgblack@eecs.umich.edu        print "Don't know what TLB to use for ISA %s" % \
884997Sgblack@eecs.umich.edu            build_env['TARGET_ISA']
894997Sgblack@eecs.umich.edu        sys.exit(1)
904997Sgblack@eecs.umich.edu
911310SN/A    max_insts_all_threads = Param.Counter(0,
921310SN/A        "terminate when all threads have reached this inst count")
931310SN/A    max_insts_any_thread = Param.Counter(0,
941310SN/A        "terminate when any thread reaches this inst count")
951310SN/A    max_loads_all_threads = Param.Counter(0,
961310SN/A        "terminate when all threads have reached this load count")
971310SN/A    max_loads_any_thread = Param.Counter(0,
981310SN/A        "terminate when any thread reaches this load count")
993878SN/A    progress_interval = Param.Tick(0,
1003878SN/A        "interval to print out the progress message")
1011310SN/A
1021369SN/A    defer_registration = Param.Bool(False,
1031310SN/A        "defer registration with system (for sampling)")
1041634SN/A
1054167SN/A    clock = Param.Clock('1t', "clock speed")
1064167SN/A    phase = Param.Latency('0ns', "clock phase")
1072998SN/A
1084776Sgblack@eecs.umich.edu    tracer = Param.InstTracer(default_tracer, "Instruction tracer")
1094776Sgblack@eecs.umich.edu
1102998SN/A    _mem_ports = []
1115281Sgblack@eecs.umich.edu    if build_env['TARGET_ISA'] == 'x86' and build_env['FULL_SYSTEM']:
1125281Sgblack@eecs.umich.edu        _mem_ports = ["itb.walker.port", "dtb.walker.port"]
1132998SN/A
1142998SN/A    def connectMemPorts(self, bus):
1152998SN/A        for p in self._mem_ports:
1164968Sacolyte@umich.edu            if p != 'physmem_port':
1174968Sacolyte@umich.edu                exec('self.%s = bus.port' % p)
1182998SN/A
1192998SN/A    def addPrivateSplitL1Caches(self, ic, dc):
1205281Sgblack@eecs.umich.edu        assert(len(self._mem_ports) < 6)
1212998SN/A        self.icache = ic
1222998SN/A        self.dcache = dc
1232998SN/A        self.icache_port = ic.cpu_side
1242998SN/A        self.dcache_port = dc.cpu_side
1252998SN/A        self._mem_ports = ['icache.mem_side', 'dcache.mem_side']
1265281Sgblack@eecs.umich.edu        if build_env['TARGET_ISA'] == 'x86' and build_env['FULL_SYSTEM']:
1275281Sgblack@eecs.umich.edu            self._mem_ports += ["itb.walker_port", "dtb.walker_port"]
1282998SN/A
1292998SN/A    def addTwoLevelCacheHierarchy(self, ic, dc, l2c):
1302998SN/A        self.addPrivateSplitL1Caches(ic, dc)
1312998SN/A        self.toL2Bus = Bus()
1322998SN/A        self.connectMemPorts(self.toL2Bus)
1332998SN/A        self.l2cache = l2c
1343017SN/A        self.l2cache.cpu_side = self.toL2Bus.port
1352998SN/A        self._mem_ports = ['l2cache.mem_side']
1365222Sksewell@umich.edu
1375222Sksewell@umich.edu    if build_env['TARGET_ISA'] == 'mips':
1385222Sksewell@umich.edu        CP0_IntCtl_IPTI = Param.Unsigned(0,"No Description")
1395222Sksewell@umich.edu        CP0_IntCtl_IPPCI = Param.Unsigned(0,"No Description")
1405222Sksewell@umich.edu        CP0_SrsCtl_HSS = Param.Unsigned(0,"No Description")
1415222Sksewell@umich.edu        CP0_EBase_CPUNum = Param.Unsigned(0,"No Description")
1425222Sksewell@umich.edu        CP0_PRId_CompanyOptions = Param.Unsigned(0,"Company Options in Processor ID Register")
1435222Sksewell@umich.edu        CP0_PRId_CompanyID = Param.Unsigned(0,"Company Identifier in Processor ID Register")
1445222Sksewell@umich.edu        CP0_PRId_ProcessorID = Param.Unsigned(1,"Processor ID (0=>Not MIPS32/64 Processor, 1=>MIPS, 2-255 => Other Company")
1455222Sksewell@umich.edu        CP0_PRId_Revision = Param.Unsigned(0,"Processor Revision Number in Processor ID Register")
1465222Sksewell@umich.edu        CP0_Config_BE = Param.Unsigned(0,"Big Endian?")
1475222Sksewell@umich.edu        CP0_Config_AT = Param.Unsigned(0,"No Description")
1485222Sksewell@umich.edu        CP0_Config_AR = Param.Unsigned(0,"No Description")
1495222Sksewell@umich.edu        CP0_Config_MT = Param.Unsigned(0,"No Description")
1505222Sksewell@umich.edu        CP0_Config_VI = Param.Unsigned(0,"No Description")
1515222Sksewell@umich.edu        CP0_Config1_M = Param.Unsigned(0,"Config2 Implemented?")
1525222Sksewell@umich.edu        CP0_Config1_MMU = Param.Unsigned(0,"MMU Type")
1535222Sksewell@umich.edu        CP0_Config1_IS = Param.Unsigned(0,"No Description")
1545222Sksewell@umich.edu        CP0_Config1_IL = Param.Unsigned(0,"No Description")
1555222Sksewell@umich.edu        CP0_Config1_IA = Param.Unsigned(0,"No Description")
1565222Sksewell@umich.edu        CP0_Config1_DS = Param.Unsigned(0,"No Description")
1575222Sksewell@umich.edu        CP0_Config1_DL = Param.Unsigned(0,"No Description")
1585222Sksewell@umich.edu        CP0_Config1_DA = Param.Unsigned(0,"No Description")
1595222Sksewell@umich.edu        CP0_Config1_C2 = Param.Bool(False,"No Description")
1605222Sksewell@umich.edu        CP0_Config1_MD = Param.Bool(False,"No Description")
1615222Sksewell@umich.edu        CP0_Config1_PC = Param.Bool(False,"No Description")
1625222Sksewell@umich.edu        CP0_Config1_WR = Param.Bool(False,"No Description")
1635222Sksewell@umich.edu        CP0_Config1_CA = Param.Bool(False,"No Description")
1645222Sksewell@umich.edu        CP0_Config1_EP = Param.Bool(False,"No Description")
1655222Sksewell@umich.edu        CP0_Config1_FP = Param.Bool(False,"FPU Implemented?")
1665222Sksewell@umich.edu        CP0_Config2_M = Param.Bool(False,"Config3 Implemented?")
1675222Sksewell@umich.edu        CP0_Config2_TU = Param.Unsigned(0,"No Description")
1685222Sksewell@umich.edu        CP0_Config2_TS = Param.Unsigned(0,"No Description")
1695222Sksewell@umich.edu        CP0_Config2_TL = Param.Unsigned(0,"No Description")
1705222Sksewell@umich.edu        CP0_Config2_TA = Param.Unsigned(0,"No Description")
1715222Sksewell@umich.edu        CP0_Config2_SU = Param.Unsigned(0,"No Description")
1725222Sksewell@umich.edu        CP0_Config2_SS = Param.Unsigned(0,"No Description")
1735222Sksewell@umich.edu        CP0_Config2_SL = Param.Unsigned(0,"No Description")
1745222Sksewell@umich.edu        CP0_Config2_SA = Param.Unsigned(0,"No Description")
1755222Sksewell@umich.edu        CP0_Config3_M = Param.Bool(False,"Config4 Implemented?")
1765222Sksewell@umich.edu        CP0_Config3_DSPP = Param.Bool(False,"DSP Extensions Present?")
1775222Sksewell@umich.edu        CP0_Config3_LPA = Param.Bool(False,"No Description")
1785222Sksewell@umich.edu        CP0_Config3_VEIC = Param.Bool(False,"No Description")
1795222Sksewell@umich.edu        CP0_Config3_VInt = Param.Bool(False,"No Description")
1805222Sksewell@umich.edu        CP0_Config3_SP = Param.Bool(False,"No Description")
1815222Sksewell@umich.edu        CP0_Config3_MT = Param.Bool(False,"Multithreading Extensions Present?")
1825222Sksewell@umich.edu        CP0_Config3_SM = Param.Bool(False,"No Description")
1835222Sksewell@umich.edu        CP0_Config3_TL = Param.Bool(False,"No Description")
1845222Sksewell@umich.edu        CP0_WatchHi_M = Param.Bool(False,"No Description")
1855222Sksewell@umich.edu        CP0_PerfCtr_M = Param.Bool(False,"No Description")
1865222Sksewell@umich.edu        CP0_PerfCtr_W = Param.Bool(False,"No Description")
1875222Sksewell@umich.edu        CP0_PRId = Param.Unsigned(0,"CP0 Status Register")
1885222Sksewell@umich.edu        CP0_Config = Param.Unsigned(0,"CP0 Config Register")
1895222Sksewell@umich.edu        CP0_Config1 = Param.Unsigned(0,"CP0 Config1 Register")
1905222Sksewell@umich.edu        CP0_Config2 = Param.Unsigned(0,"CP0 Config2 Register")
1915222Sksewell@umich.edu        CP0_Config3 = Param.Unsigned(0,"CP0 Config3 Register")
192