BaseCPU.py revision 5651
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 425647Sgblack@eecs.umich.edu if build_env['FULL_SYSTEM']: 435647Sgblack@eecs.umich.edu from AlphaInterrupts import AlphaInterrupts 444997Sgblack@eecs.umich.eduelif build_env['TARGET_ISA'] == 'sparc': 454997Sgblack@eecs.umich.edu from SparcTLB import SparcDTB, SparcITB 465647Sgblack@eecs.umich.edu if build_env['FULL_SYSTEM']: 475647Sgblack@eecs.umich.edu from SparcInterrupts import SparcInterrupts 484997Sgblack@eecs.umich.eduelif build_env['TARGET_ISA'] == 'x86': 494997Sgblack@eecs.umich.edu from X86TLB import X86DTB, X86ITB 505647Sgblack@eecs.umich.edu if build_env['FULL_SYSTEM']: 515647Sgblack@eecs.umich.edu from X86LocalApic import X86LocalApic 524997Sgblack@eecs.umich.eduelif build_env['TARGET_ISA'] == 'mips': 535222Sksewell@umich.edu from MipsTLB import MipsTLB,MipsDTB, MipsITB, MipsUTB 545647Sgblack@eecs.umich.edu if build_env['FULL_SYSTEM']: 555647Sgblack@eecs.umich.edu from MipsInterrupts import MipsInterrupts 565335Shines@cs.fsu.eduelif build_env['TARGET_ISA'] == 'arm': 575335Shines@cs.fsu.edu from ArmTLB import ArmTLB, ArmDTB, ArmITB, ArmUTB 585647Sgblack@eecs.umich.edu if build_env['FULL_SYSTEM']: 595647Sgblack@eecs.umich.edu from ArmInterrupts import ArmInterrupts 604486Sbinkertn@umich.edu 615529Snate@binkert.orgclass BaseCPU(MemObject): 621366SN/A type = 'BaseCPU' 631310SN/A abstract = True 641310SN/A 652901SN/A system = Param.System(Parent.any, "system object") 663170SN/A cpu_id = Param.Int("CPU identifier") 675529Snate@binkert.org numThreads = Param.Unsigned(1, "number of HW thread contexts") 685529Snate@binkert.org 695529Snate@binkert.org function_trace = Param.Bool(False, "Enable function trace") 705529Snate@binkert.org function_trace_start = Param.Tick(0, "Cycle to start function trace") 715529Snate@binkert.org 725529Snate@binkert.org checker = Param.BaseCPU("checker CPU") 733170SN/A 741530SN/A if build_env['FULL_SYSTEM']: 755529Snate@binkert.org profile = Param.Latency('0ns', "trace the kernel stack") 763620SN/A do_quiesce = Param.Bool(True, "enable quiesce instructions") 773617SN/A do_checkpoint_insts = Param.Bool(True, 783617SN/A "enable checkpoint pseudo instructions") 793617SN/A do_statistics_insts = Param.Bool(True, 803617SN/A "enable statistics pseudo instructions") 811445SN/A else: 821445SN/A workload = VectorParam.Process("processes to run") 831310SN/A 844997Sgblack@eecs.umich.edu if build_env['TARGET_ISA'] == 'sparc': 854997Sgblack@eecs.umich.edu dtb = Param.SparcDTB(SparcDTB(), "Data TLB") 864997Sgblack@eecs.umich.edu itb = Param.SparcITB(SparcITB(), "Instruction TLB") 875647Sgblack@eecs.umich.edu if build_env['FULL_SYSTEM']: 885647Sgblack@eecs.umich.edu interrupts = Param.SparcInterrupts( 895647Sgblack@eecs.umich.edu SparcInterrupts(), "Interrupt Controller") 904997Sgblack@eecs.umich.edu elif build_env['TARGET_ISA'] == 'alpha': 914997Sgblack@eecs.umich.edu dtb = Param.AlphaDTB(AlphaDTB(), "Data TLB") 924997Sgblack@eecs.umich.edu itb = Param.AlphaITB(AlphaITB(), "Instruction TLB") 935647Sgblack@eecs.umich.edu if build_env['FULL_SYSTEM']: 945647Sgblack@eecs.umich.edu interrupts = Param.AlphaInterrupts( 955647Sgblack@eecs.umich.edu AlphaInterrupts(), "Interrupt Controller") 964997Sgblack@eecs.umich.edu elif build_env['TARGET_ISA'] == 'x86': 974997Sgblack@eecs.umich.edu dtb = Param.X86DTB(X86DTB(), "Data TLB") 984997Sgblack@eecs.umich.edu itb = Param.X86ITB(X86ITB(), "Instruction TLB") 995647Sgblack@eecs.umich.edu if build_env['FULL_SYSTEM']: 1005648Sgblack@eecs.umich.edu _localApic = X86LocalApic(pio_addr=0xa000000000000000) 1015648Sgblack@eecs.umich.edu interrupts = \ 1025648Sgblack@eecs.umich.edu Param.X86LocalApic(_localApic, "Interrupt Controller") 1034997Sgblack@eecs.umich.edu elif build_env['TARGET_ISA'] == 'mips': 1045222Sksewell@umich.edu UnifiedTLB = Param.Bool(True, "Is this a Unified TLB?") 1054997Sgblack@eecs.umich.edu dtb = Param.MipsDTB(MipsDTB(), "Data TLB") 1064997Sgblack@eecs.umich.edu itb = Param.MipsITB(MipsITB(), "Instruction TLB") 1075222Sksewell@umich.edu tlb = Param.MipsUTB(MipsUTB(), "Unified TLB") 1085647Sgblack@eecs.umich.edu if build_env['FULL_SYSTEM']: 1095647Sgblack@eecs.umich.edu interrupts = Param.MipsInterrupts( 1105647Sgblack@eecs.umich.edu MipsInterrupts(), "Interrupt Controller") 1115335Shines@cs.fsu.edu elif build_env['TARGET_ISA'] == 'arm': 1125335Shines@cs.fsu.edu UnifiedTLB = Param.Bool(True, "Is this a Unified TLB?") 1135335Shines@cs.fsu.edu dtb = Param.ArmDTB(ArmDTB(), "Data TLB") 1145335Shines@cs.fsu.edu itb = Param.ArmITB(ArmITB(), "Instruction TLB") 1155335Shines@cs.fsu.edu tlb = Param.ArmUTB(ArmUTB(), "Unified TLB") 1165647Sgblack@eecs.umich.edu if build_env['FULL_SYSTEM']: 1175647Sgblack@eecs.umich.edu interrupts = Param.ArmInterrupts( 1185647Sgblack@eecs.umich.edu ArmInterrupts(), "Interrupt Controller") 1194997Sgblack@eecs.umich.edu else: 1204997Sgblack@eecs.umich.edu print "Don't know what TLB to use for ISA %s" % \ 1214997Sgblack@eecs.umich.edu build_env['TARGET_ISA'] 1224997Sgblack@eecs.umich.edu sys.exit(1) 1234997Sgblack@eecs.umich.edu 1241310SN/A max_insts_all_threads = Param.Counter(0, 1251310SN/A "terminate when all threads have reached this inst count") 1261310SN/A max_insts_any_thread = Param.Counter(0, 1271310SN/A "terminate when any thread reaches this inst count") 1281310SN/A max_loads_all_threads = Param.Counter(0, 1291310SN/A "terminate when all threads have reached this load count") 1301310SN/A max_loads_any_thread = Param.Counter(0, 1311310SN/A "terminate when any thread reaches this load count") 1323878SN/A progress_interval = Param.Tick(0, 1333878SN/A "interval to print out the progress message") 1341310SN/A 1351369SN/A defer_registration = Param.Bool(False, 1361310SN/A "defer registration with system (for sampling)") 1371634SN/A 1384167SN/A clock = Param.Clock('1t', "clock speed") 1394167SN/A phase = Param.Latency('0ns', "clock phase") 1402998SN/A 1414776Sgblack@eecs.umich.edu tracer = Param.InstTracer(default_tracer, "Instruction tracer") 1424776Sgblack@eecs.umich.edu 1432998SN/A _mem_ports = [] 1445281Sgblack@eecs.umich.edu if build_env['TARGET_ISA'] == 'x86' and build_env['FULL_SYSTEM']: 1455648Sgblack@eecs.umich.edu _mem_ports = ["itb.walker.port", 1465648Sgblack@eecs.umich.edu "dtb.walker.port", 1475651Sgblack@eecs.umich.edu "interrupts.pio", 1485651Sgblack@eecs.umich.edu "interrupts.int_port"] 1492998SN/A 1502998SN/A def connectMemPorts(self, bus): 1512998SN/A for p in self._mem_ports: 1524968Sacolyte@umich.edu if p != 'physmem_port': 1534968Sacolyte@umich.edu exec('self.%s = bus.port' % p) 1542998SN/A 1552998SN/A def addPrivateSplitL1Caches(self, ic, dc): 1565281Sgblack@eecs.umich.edu assert(len(self._mem_ports) < 6) 1572998SN/A self.icache = ic 1582998SN/A self.dcache = dc 1592998SN/A self.icache_port = ic.cpu_side 1602998SN/A self.dcache_port = dc.cpu_side 1612998SN/A self._mem_ports = ['icache.mem_side', 'dcache.mem_side'] 1625281Sgblack@eecs.umich.edu if build_env['TARGET_ISA'] == 'x86' and build_env['FULL_SYSTEM']: 1635281Sgblack@eecs.umich.edu self._mem_ports += ["itb.walker_port", "dtb.walker_port"] 1642998SN/A 1652998SN/A def addTwoLevelCacheHierarchy(self, ic, dc, l2c): 1662998SN/A self.addPrivateSplitL1Caches(ic, dc) 1672998SN/A self.toL2Bus = Bus() 1682998SN/A self.connectMemPorts(self.toL2Bus) 1692998SN/A self.l2cache = l2c 1703017SN/A self.l2cache.cpu_side = self.toL2Bus.port 1712998SN/A self._mem_ports = ['l2cache.mem_side'] 1725222Sksewell@umich.edu 1735222Sksewell@umich.edu if build_env['TARGET_ISA'] == 'mips': 1745222Sksewell@umich.edu CP0_IntCtl_IPTI = Param.Unsigned(0,"No Description") 1755222Sksewell@umich.edu CP0_IntCtl_IPPCI = Param.Unsigned(0,"No Description") 1765222Sksewell@umich.edu CP0_SrsCtl_HSS = Param.Unsigned(0,"No Description") 1775222Sksewell@umich.edu CP0_EBase_CPUNum = Param.Unsigned(0,"No Description") 1785222Sksewell@umich.edu CP0_PRId_CompanyOptions = Param.Unsigned(0,"Company Options in Processor ID Register") 1795222Sksewell@umich.edu CP0_PRId_CompanyID = Param.Unsigned(0,"Company Identifier in Processor ID Register") 1805222Sksewell@umich.edu CP0_PRId_ProcessorID = Param.Unsigned(1,"Processor ID (0=>Not MIPS32/64 Processor, 1=>MIPS, 2-255 => Other Company") 1815222Sksewell@umich.edu CP0_PRId_Revision = Param.Unsigned(0,"Processor Revision Number in Processor ID Register") 1825222Sksewell@umich.edu CP0_Config_BE = Param.Unsigned(0,"Big Endian?") 1835222Sksewell@umich.edu CP0_Config_AT = Param.Unsigned(0,"No Description") 1845222Sksewell@umich.edu CP0_Config_AR = Param.Unsigned(0,"No Description") 1855222Sksewell@umich.edu CP0_Config_MT = Param.Unsigned(0,"No Description") 1865222Sksewell@umich.edu CP0_Config_VI = Param.Unsigned(0,"No Description") 1875222Sksewell@umich.edu CP0_Config1_M = Param.Unsigned(0,"Config2 Implemented?") 1885222Sksewell@umich.edu CP0_Config1_MMU = Param.Unsigned(0,"MMU Type") 1895222Sksewell@umich.edu CP0_Config1_IS = Param.Unsigned(0,"No Description") 1905222Sksewell@umich.edu CP0_Config1_IL = Param.Unsigned(0,"No Description") 1915222Sksewell@umich.edu CP0_Config1_IA = Param.Unsigned(0,"No Description") 1925222Sksewell@umich.edu CP0_Config1_DS = Param.Unsigned(0,"No Description") 1935222Sksewell@umich.edu CP0_Config1_DL = Param.Unsigned(0,"No Description") 1945222Sksewell@umich.edu CP0_Config1_DA = Param.Unsigned(0,"No Description") 1955222Sksewell@umich.edu CP0_Config1_C2 = Param.Bool(False,"No Description") 1965222Sksewell@umich.edu CP0_Config1_MD = Param.Bool(False,"No Description") 1975222Sksewell@umich.edu CP0_Config1_PC = Param.Bool(False,"No Description") 1985222Sksewell@umich.edu CP0_Config1_WR = Param.Bool(False,"No Description") 1995222Sksewell@umich.edu CP0_Config1_CA = Param.Bool(False,"No Description") 2005222Sksewell@umich.edu CP0_Config1_EP = Param.Bool(False,"No Description") 2015222Sksewell@umich.edu CP0_Config1_FP = Param.Bool(False,"FPU Implemented?") 2025222Sksewell@umich.edu CP0_Config2_M = Param.Bool(False,"Config3 Implemented?") 2035222Sksewell@umich.edu CP0_Config2_TU = Param.Unsigned(0,"No Description") 2045222Sksewell@umich.edu CP0_Config2_TS = Param.Unsigned(0,"No Description") 2055222Sksewell@umich.edu CP0_Config2_TL = Param.Unsigned(0,"No Description") 2065222Sksewell@umich.edu CP0_Config2_TA = Param.Unsigned(0,"No Description") 2075222Sksewell@umich.edu CP0_Config2_SU = Param.Unsigned(0,"No Description") 2085222Sksewell@umich.edu CP0_Config2_SS = Param.Unsigned(0,"No Description") 2095222Sksewell@umich.edu CP0_Config2_SL = Param.Unsigned(0,"No Description") 2105222Sksewell@umich.edu CP0_Config2_SA = Param.Unsigned(0,"No Description") 2115222Sksewell@umich.edu CP0_Config3_M = Param.Bool(False,"Config4 Implemented?") 2125222Sksewell@umich.edu CP0_Config3_DSPP = Param.Bool(False,"DSP Extensions Present?") 2135222Sksewell@umich.edu CP0_Config3_LPA = Param.Bool(False,"No Description") 2145222Sksewell@umich.edu CP0_Config3_VEIC = Param.Bool(False,"No Description") 2155222Sksewell@umich.edu CP0_Config3_VInt = Param.Bool(False,"No Description") 2165222Sksewell@umich.edu CP0_Config3_SP = Param.Bool(False,"No Description") 2175222Sksewell@umich.edu CP0_Config3_MT = Param.Bool(False,"Multithreading Extensions Present?") 2185222Sksewell@umich.edu CP0_Config3_SM = Param.Bool(False,"No Description") 2195222Sksewell@umich.edu CP0_Config3_TL = Param.Bool(False,"No Description") 2205222Sksewell@umich.edu CP0_WatchHi_M = Param.Bool(False,"No Description") 2215222Sksewell@umich.edu CP0_PerfCtr_M = Param.Bool(False,"No Description") 2225222Sksewell@umich.edu CP0_PerfCtr_W = Param.Bool(False,"No Description") 2235222Sksewell@umich.edu CP0_PRId = Param.Unsigned(0,"CP0 Status Register") 2245222Sksewell@umich.edu CP0_Config = Param.Unsigned(0,"CP0 Config Register") 2255222Sksewell@umich.edu CP0_Config1 = Param.Unsigned(0,"CP0 Config1 Register") 2265222Sksewell@umich.edu CP0_Config2 = Param.Unsigned(0,"CP0 Config2 Register") 2275222Sksewell@umich.edu CP0_Config3 = Param.Unsigned(0,"CP0 Config3 Register") 228