BaseCPU.py revision 5529
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
295529Snate@binkert.orgfrom MemObject import MemObject
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
515529Snate@binkert.orgclass BaseCPU(MemObject):
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")
575529Snate@binkert.org    numThreads = Param.Unsigned(1, "number of HW thread contexts")
585529Snate@binkert.org
595529Snate@binkert.org    function_trace = Param.Bool(False, "Enable function trace")
605529Snate@binkert.org    function_trace_start = Param.Tick(0, "Cycle to start function trace")
615529Snate@binkert.org
625529Snate@binkert.org    checker = Param.BaseCPU("checker CPU")
633170SN/A
641530SN/A    if build_env['FULL_SYSTEM']:
655529Snate@binkert.org        profile = Param.Latency('0ns', "trace the kernel stack")
663620SN/A        do_quiesce = Param.Bool(True, "enable quiesce instructions")
673617SN/A        do_checkpoint_insts = Param.Bool(True,
683617SN/A            "enable checkpoint pseudo instructions")
693617SN/A        do_statistics_insts = Param.Bool(True,
703617SN/A            "enable statistics pseudo instructions")
711445SN/A    else:
721445SN/A        workload = VectorParam.Process("processes to run")
731310SN/A
744997Sgblack@eecs.umich.edu    if build_env['TARGET_ISA'] == 'sparc':
754997Sgblack@eecs.umich.edu        dtb = Param.SparcDTB(SparcDTB(), "Data TLB")
764997Sgblack@eecs.umich.edu        itb = Param.SparcITB(SparcITB(), "Instruction TLB")
774997Sgblack@eecs.umich.edu    elif build_env['TARGET_ISA'] == 'alpha':
784997Sgblack@eecs.umich.edu        dtb = Param.AlphaDTB(AlphaDTB(), "Data TLB")
794997Sgblack@eecs.umich.edu        itb = Param.AlphaITB(AlphaITB(), "Instruction TLB")
804997Sgblack@eecs.umich.edu    elif build_env['TARGET_ISA'] == 'x86':
814997Sgblack@eecs.umich.edu        dtb = Param.X86DTB(X86DTB(), "Data TLB")
824997Sgblack@eecs.umich.edu        itb = Param.X86ITB(X86ITB(), "Instruction TLB")
834997Sgblack@eecs.umich.edu    elif build_env['TARGET_ISA'] == 'mips':
845222Sksewell@umich.edu        UnifiedTLB = Param.Bool(True, "Is this a Unified TLB?")
854997Sgblack@eecs.umich.edu        dtb = Param.MipsDTB(MipsDTB(), "Data TLB")
864997Sgblack@eecs.umich.edu        itb = Param.MipsITB(MipsITB(), "Instruction TLB")
875222Sksewell@umich.edu        tlb = Param.MipsUTB(MipsUTB(), "Unified TLB")
885335Shines@cs.fsu.edu    elif build_env['TARGET_ISA'] == 'arm':
895335Shines@cs.fsu.edu        UnifiedTLB = Param.Bool(True, "Is this a Unified TLB?")
905335Shines@cs.fsu.edu        dtb = Param.ArmDTB(ArmDTB(), "Data TLB")
915335Shines@cs.fsu.edu        itb = Param.ArmITB(ArmITB(), "Instruction TLB")
925335Shines@cs.fsu.edu        tlb = Param.ArmUTB(ArmUTB(), "Unified TLB")
934997Sgblack@eecs.umich.edu    else:
944997Sgblack@eecs.umich.edu        print "Don't know what TLB to use for ISA %s" % \
954997Sgblack@eecs.umich.edu            build_env['TARGET_ISA']
964997Sgblack@eecs.umich.edu        sys.exit(1)
974997Sgblack@eecs.umich.edu
981310SN/A    max_insts_all_threads = Param.Counter(0,
991310SN/A        "terminate when all threads have reached this inst count")
1001310SN/A    max_insts_any_thread = Param.Counter(0,
1011310SN/A        "terminate when any thread reaches this inst count")
1021310SN/A    max_loads_all_threads = Param.Counter(0,
1031310SN/A        "terminate when all threads have reached this load count")
1041310SN/A    max_loads_any_thread = Param.Counter(0,
1051310SN/A        "terminate when any thread reaches this load count")
1063878SN/A    progress_interval = Param.Tick(0,
1073878SN/A        "interval to print out the progress message")
1081310SN/A
1091369SN/A    defer_registration = Param.Bool(False,
1101310SN/A        "defer registration with system (for sampling)")
1111634SN/A
1124167SN/A    clock = Param.Clock('1t', "clock speed")
1134167SN/A    phase = Param.Latency('0ns', "clock phase")
1142998SN/A
1154776Sgblack@eecs.umich.edu    tracer = Param.InstTracer(default_tracer, "Instruction tracer")
1164776Sgblack@eecs.umich.edu
1172998SN/A    _mem_ports = []
1185281Sgblack@eecs.umich.edu    if build_env['TARGET_ISA'] == 'x86' and build_env['FULL_SYSTEM']:
1195281Sgblack@eecs.umich.edu        _mem_ports = ["itb.walker.port", "dtb.walker.port"]
1202998SN/A
1212998SN/A    def connectMemPorts(self, bus):
1222998SN/A        for p in self._mem_ports:
1234968Sacolyte@umich.edu            if p != 'physmem_port':
1244968Sacolyte@umich.edu                exec('self.%s = bus.port' % p)
1252998SN/A
1262998SN/A    def addPrivateSplitL1Caches(self, ic, dc):
1275281Sgblack@eecs.umich.edu        assert(len(self._mem_ports) < 6)
1282998SN/A        self.icache = ic
1292998SN/A        self.dcache = dc
1302998SN/A        self.icache_port = ic.cpu_side
1312998SN/A        self.dcache_port = dc.cpu_side
1322998SN/A        self._mem_ports = ['icache.mem_side', 'dcache.mem_side']
1335281Sgblack@eecs.umich.edu        if build_env['TARGET_ISA'] == 'x86' and build_env['FULL_SYSTEM']:
1345281Sgblack@eecs.umich.edu            self._mem_ports += ["itb.walker_port", "dtb.walker_port"]
1352998SN/A
1362998SN/A    def addTwoLevelCacheHierarchy(self, ic, dc, l2c):
1372998SN/A        self.addPrivateSplitL1Caches(ic, dc)
1382998SN/A        self.toL2Bus = Bus()
1392998SN/A        self.connectMemPorts(self.toL2Bus)
1402998SN/A        self.l2cache = l2c
1413017SN/A        self.l2cache.cpu_side = self.toL2Bus.port
1422998SN/A        self._mem_ports = ['l2cache.mem_side']
1435222Sksewell@umich.edu
1445222Sksewell@umich.edu    if build_env['TARGET_ISA'] == 'mips':
1455222Sksewell@umich.edu        CP0_IntCtl_IPTI = Param.Unsigned(0,"No Description")
1465222Sksewell@umich.edu        CP0_IntCtl_IPPCI = Param.Unsigned(0,"No Description")
1475222Sksewell@umich.edu        CP0_SrsCtl_HSS = Param.Unsigned(0,"No Description")
1485222Sksewell@umich.edu        CP0_EBase_CPUNum = Param.Unsigned(0,"No Description")
1495222Sksewell@umich.edu        CP0_PRId_CompanyOptions = Param.Unsigned(0,"Company Options in Processor ID Register")
1505222Sksewell@umich.edu        CP0_PRId_CompanyID = Param.Unsigned(0,"Company Identifier in Processor ID Register")
1515222Sksewell@umich.edu        CP0_PRId_ProcessorID = Param.Unsigned(1,"Processor ID (0=>Not MIPS32/64 Processor, 1=>MIPS, 2-255 => Other Company")
1525222Sksewell@umich.edu        CP0_PRId_Revision = Param.Unsigned(0,"Processor Revision Number in Processor ID Register")
1535222Sksewell@umich.edu        CP0_Config_BE = Param.Unsigned(0,"Big Endian?")
1545222Sksewell@umich.edu        CP0_Config_AT = Param.Unsigned(0,"No Description")
1555222Sksewell@umich.edu        CP0_Config_AR = Param.Unsigned(0,"No Description")
1565222Sksewell@umich.edu        CP0_Config_MT = Param.Unsigned(0,"No Description")
1575222Sksewell@umich.edu        CP0_Config_VI = Param.Unsigned(0,"No Description")
1585222Sksewell@umich.edu        CP0_Config1_M = Param.Unsigned(0,"Config2 Implemented?")
1595222Sksewell@umich.edu        CP0_Config1_MMU = Param.Unsigned(0,"MMU Type")
1605222Sksewell@umich.edu        CP0_Config1_IS = Param.Unsigned(0,"No Description")
1615222Sksewell@umich.edu        CP0_Config1_IL = Param.Unsigned(0,"No Description")
1625222Sksewell@umich.edu        CP0_Config1_IA = Param.Unsigned(0,"No Description")
1635222Sksewell@umich.edu        CP0_Config1_DS = Param.Unsigned(0,"No Description")
1645222Sksewell@umich.edu        CP0_Config1_DL = Param.Unsigned(0,"No Description")
1655222Sksewell@umich.edu        CP0_Config1_DA = Param.Unsigned(0,"No Description")
1665222Sksewell@umich.edu        CP0_Config1_C2 = Param.Bool(False,"No Description")
1675222Sksewell@umich.edu        CP0_Config1_MD = Param.Bool(False,"No Description")
1685222Sksewell@umich.edu        CP0_Config1_PC = Param.Bool(False,"No Description")
1695222Sksewell@umich.edu        CP0_Config1_WR = Param.Bool(False,"No Description")
1705222Sksewell@umich.edu        CP0_Config1_CA = Param.Bool(False,"No Description")
1715222Sksewell@umich.edu        CP0_Config1_EP = Param.Bool(False,"No Description")
1725222Sksewell@umich.edu        CP0_Config1_FP = Param.Bool(False,"FPU Implemented?")
1735222Sksewell@umich.edu        CP0_Config2_M = Param.Bool(False,"Config3 Implemented?")
1745222Sksewell@umich.edu        CP0_Config2_TU = Param.Unsigned(0,"No Description")
1755222Sksewell@umich.edu        CP0_Config2_TS = Param.Unsigned(0,"No Description")
1765222Sksewell@umich.edu        CP0_Config2_TL = Param.Unsigned(0,"No Description")
1775222Sksewell@umich.edu        CP0_Config2_TA = Param.Unsigned(0,"No Description")
1785222Sksewell@umich.edu        CP0_Config2_SU = Param.Unsigned(0,"No Description")
1795222Sksewell@umich.edu        CP0_Config2_SS = Param.Unsigned(0,"No Description")
1805222Sksewell@umich.edu        CP0_Config2_SL = Param.Unsigned(0,"No Description")
1815222Sksewell@umich.edu        CP0_Config2_SA = Param.Unsigned(0,"No Description")
1825222Sksewell@umich.edu        CP0_Config3_M = Param.Bool(False,"Config4 Implemented?")
1835222Sksewell@umich.edu        CP0_Config3_DSPP = Param.Bool(False,"DSP Extensions Present?")
1845222Sksewell@umich.edu        CP0_Config3_LPA = Param.Bool(False,"No Description")
1855222Sksewell@umich.edu        CP0_Config3_VEIC = Param.Bool(False,"No Description")
1865222Sksewell@umich.edu        CP0_Config3_VInt = Param.Bool(False,"No Description")
1875222Sksewell@umich.edu        CP0_Config3_SP = Param.Bool(False,"No Description")
1885222Sksewell@umich.edu        CP0_Config3_MT = Param.Bool(False,"Multithreading Extensions Present?")
1895222Sksewell@umich.edu        CP0_Config3_SM = Param.Bool(False,"No Description")
1905222Sksewell@umich.edu        CP0_Config3_TL = Param.Bool(False,"No Description")
1915222Sksewell@umich.edu        CP0_WatchHi_M = Param.Bool(False,"No Description")
1925222Sksewell@umich.edu        CP0_PerfCtr_M = Param.Bool(False,"No Description")
1935222Sksewell@umich.edu        CP0_PerfCtr_W = Param.Bool(False,"No Description")
1945222Sksewell@umich.edu        CP0_PRId = Param.Unsigned(0,"CP0 Status Register")
1955222Sksewell@umich.edu        CP0_Config = Param.Unsigned(0,"CP0 Config Register")
1965222Sksewell@umich.edu        CP0_Config1 = Param.Unsigned(0,"CP0 Config1 Register")
1975222Sksewell@umich.edu        CP0_Config2 = Param.Unsigned(0,"CP0 Config2 Register")
1985222Sksewell@umich.edu        CP0_Config3 = Param.Unsigned(0,"CP0 Config3 Register")
199