MinorCPU.py revision 13172
113883Sdavid.hashe@amd.com# Copyright (c) 2012-2014,2018 ARM Limited 213883Sdavid.hashe@amd.com# All rights reserved. 313883Sdavid.hashe@amd.com# 413883Sdavid.hashe@amd.com# The license below extends only to copyright in the software and shall 513883Sdavid.hashe@amd.com# not be construed as granting a license to any other intellectual 613883Sdavid.hashe@amd.com# property including but not limited to intellectual property relating 713883Sdavid.hashe@amd.com# to a hardware implementation of the functionality of the software 813883Sdavid.hashe@amd.com# licensed hereunder. You may use the software subject to the license 913883Sdavid.hashe@amd.com# terms below provided that you ensure that this notice is replicated 1013883Sdavid.hashe@amd.com# unmodified and in its entirety in all distributions of the software, 1113883Sdavid.hashe@amd.com# modified or unmodified, in source code or in binary form. 1213883Sdavid.hashe@amd.com# 1313883Sdavid.hashe@amd.com# Copyright (c) 2007 The Regents of The University of Michigan 1413883Sdavid.hashe@amd.com# All rights reserved. 1513883Sdavid.hashe@amd.com# 1613883Sdavid.hashe@amd.com# Redistribution and use in source and binary forms, with or without 1713883Sdavid.hashe@amd.com# modification, are permitted provided that the following conditions are 1813883Sdavid.hashe@amd.com# met: redistributions of source code must retain the above copyright 1913883Sdavid.hashe@amd.com# notice, this list of conditions and the following disclaimer; 2013883Sdavid.hashe@amd.com# redistributions in binary form must reproduce the above copyright 2113883Sdavid.hashe@amd.com# notice, this list of conditions and the following disclaimer in the 2213883Sdavid.hashe@amd.com# documentation and/or other materials provided with the distribution; 2313883Sdavid.hashe@amd.com# neither the name of the copyright holders nor the names of its 2413883Sdavid.hashe@amd.com# contributors may be used to endorse or promote products derived from 2513883Sdavid.hashe@amd.com# this software without specific prior written permission. 2613883Sdavid.hashe@amd.com# 2713883Sdavid.hashe@amd.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2813883Sdavid.hashe@amd.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2913883Sdavid.hashe@amd.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 3013883Sdavid.hashe@amd.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3113883Sdavid.hashe@amd.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 3213883Sdavid.hashe@amd.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3313883Sdavid.hashe@amd.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3413883Sdavid.hashe@amd.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3513883Sdavid.hashe@amd.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3613883Sdavid.hashe@amd.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3713883Sdavid.hashe@amd.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3813883Sdavid.hashe@amd.com# 3913883Sdavid.hashe@amd.com# Authors: Gabe Black 4013883Sdavid.hashe@amd.com# Nathan Binkert 4113883Sdavid.hashe@amd.com# Andrew Bardsley 4213883Sdavid.hashe@amd.com 4313883Sdavid.hashe@amd.comfrom __future__ import print_function 4413883Sdavid.hashe@amd.com 4513883Sdavid.hashe@amd.comfrom m5.defines import buildEnv 4613883Sdavid.hashe@amd.comfrom m5.params import * 4713883Sdavid.hashe@amd.comfrom m5.proxy import * 4813883Sdavid.hashe@amd.comfrom m5.SimObject import SimObject 4913883Sdavid.hashe@amd.comfrom BaseCPU import BaseCPU 5013883Sdavid.hashe@amd.comfrom DummyChecker import DummyChecker 5113883Sdavid.hashe@amd.comfrom BranchPredictor import * 5213883Sdavid.hashe@amd.comfrom TimingExpr import TimingExpr 5313883Sdavid.hashe@amd.com 5413883Sdavid.hashe@amd.comfrom FuncUnit import OpClass 5513883Sdavid.hashe@amd.com 5613883Sdavid.hashe@amd.comclass MinorOpClass(SimObject): 5713883Sdavid.hashe@amd.com """Boxing of OpClass to get around build problems and provide a hook for 5813883Sdavid.hashe@amd.com future additions to OpClass checks""" 5913883Sdavid.hashe@amd.com 6013883Sdavid.hashe@amd.com type = 'MinorOpClass' 6113883Sdavid.hashe@amd.com cxx_header = "cpu/minor/func_unit.hh" 6213883Sdavid.hashe@amd.com 6313883Sdavid.hashe@amd.com opClass = Param.OpClass("op class to match") 6413883Sdavid.hashe@amd.com 6513883Sdavid.hashe@amd.comclass MinorOpClassSet(SimObject): 6613883Sdavid.hashe@amd.com """A set of matchable op classes""" 6713883Sdavid.hashe@amd.com 6813883Sdavid.hashe@amd.com type = 'MinorOpClassSet' 6913883Sdavid.hashe@amd.com cxx_header = "cpu/minor/func_unit.hh" 7013883Sdavid.hashe@amd.com 7113883Sdavid.hashe@amd.com opClasses = VectorParam.MinorOpClass([], "op classes to be matched." 7213883Sdavid.hashe@amd.com " An empty list means any class") 7313883Sdavid.hashe@amd.com 7413883Sdavid.hashe@amd.comclass MinorFUTiming(SimObject): 7513883Sdavid.hashe@amd.com type = 'MinorFUTiming' 7613883Sdavid.hashe@amd.com cxx_header = "cpu/minor/func_unit.hh" 7713883Sdavid.hashe@amd.com 7813883Sdavid.hashe@amd.com mask = Param.UInt64(0, "mask for testing ExtMachInst") 7913883Sdavid.hashe@amd.com match = Param.UInt64(0, "match value for testing ExtMachInst:" 8013883Sdavid.hashe@amd.com " (ext_mach_inst & mask) == match") 8113883Sdavid.hashe@amd.com suppress = Param.Bool(False, "if true, this inst. is not executed by" 8213883Sdavid.hashe@amd.com " this FU") 8313883Sdavid.hashe@amd.com extraCommitLat = Param.Cycles(0, "extra cycles to stall commit for" 8413883Sdavid.hashe@amd.com " this inst.") 8513883Sdavid.hashe@amd.com extraCommitLatExpr = Param.TimingExpr(NULL, "extra cycles as a" 8613883Sdavid.hashe@amd.com " run-time evaluated expression") 8713883Sdavid.hashe@amd.com extraAssumedLat = Param.Cycles(0, "extra cycles to add to scoreboard" 8813883Sdavid.hashe@amd.com " retire time for this insts dest registers once it leaves the" 8913883Sdavid.hashe@amd.com " functional unit. For mem refs, if this is 0, the result's time" 9013883Sdavid.hashe@amd.com " is marked as unpredictable and no forwarding can take place.") 9113883Sdavid.hashe@amd.com srcRegsRelativeLats = VectorParam.Cycles("the maximum number of cycles" 9213883Sdavid.hashe@amd.com " after inst. issue that each src reg can be available for this" 9313883Sdavid.hashe@amd.com " inst. to issue") 9413883Sdavid.hashe@amd.com opClasses = Param.MinorOpClassSet(MinorOpClassSet(), 9513883Sdavid.hashe@amd.com "op classes to be considered for this decode. An empty set means any" 9613883Sdavid.hashe@amd.com " class") 9713883Sdavid.hashe@amd.com description = Param.String('', "description string of the decoding/inst." 9813883Sdavid.hashe@amd.com " class") 9913883Sdavid.hashe@amd.com 10013883Sdavid.hashe@amd.comdef minorMakeOpClassSet(op_classes): 10113883Sdavid.hashe@amd.com """Make a MinorOpClassSet from a list of OpClass enum value strings""" 10213883Sdavid.hashe@amd.com def boxOpClass(op_class): 10313883Sdavid.hashe@amd.com return MinorOpClass(opClass=op_class) 10413883Sdavid.hashe@amd.com 10513883Sdavid.hashe@amd.com return MinorOpClassSet(opClasses=map(boxOpClass, op_classes)) 10613883Sdavid.hashe@amd.com 10713883Sdavid.hashe@amd.comclass MinorFU(SimObject): 10813883Sdavid.hashe@amd.com type = 'MinorFU' 10913883Sdavid.hashe@amd.com cxx_header = "cpu/minor/func_unit.hh" 11013883Sdavid.hashe@amd.com 11113883Sdavid.hashe@amd.com opClasses = Param.MinorOpClassSet(MinorOpClassSet(), "type of operations" 11213883Sdavid.hashe@amd.com " allowed on this functional unit") 11313883Sdavid.hashe@amd.com opLat = Param.Cycles(1, "latency in cycles") 11413883Sdavid.hashe@amd.com issueLat = Param.Cycles(1, "cycles until another instruction can be" 11513883Sdavid.hashe@amd.com " issued") 11613883Sdavid.hashe@amd.com timings = VectorParam.MinorFUTiming([], "extra decoding rules") 11713883Sdavid.hashe@amd.com 11813883Sdavid.hashe@amd.com cantForwardFromFUIndices = VectorParam.Unsigned([], 11913883Sdavid.hashe@amd.com "list of FU indices from which this FU can't receive and early" 12013883Sdavid.hashe@amd.com " (forwarded) result") 12113883Sdavid.hashe@amd.com 12213883Sdavid.hashe@amd.comclass MinorFUPool(SimObject): 12313883Sdavid.hashe@amd.com type = 'MinorFUPool' 12413883Sdavid.hashe@amd.com cxx_header = "cpu/minor/func_unit.hh" 12513883Sdavid.hashe@amd.com 12613883Sdavid.hashe@amd.com funcUnits = VectorParam.MinorFU("functional units") 12713883Sdavid.hashe@amd.com 12813883Sdavid.hashe@amd.comclass MinorDefaultIntFU(MinorFU): 12913883Sdavid.hashe@amd.com opClasses = minorMakeOpClassSet(['IntAlu']) 13013883Sdavid.hashe@amd.com timings = [MinorFUTiming(description="Int", 13113883Sdavid.hashe@amd.com srcRegsRelativeLats=[2])] 13213883Sdavid.hashe@amd.com opLat = 3 13313883Sdavid.hashe@amd.com 13413883Sdavid.hashe@amd.comclass MinorDefaultIntMulFU(MinorFU): 13513883Sdavid.hashe@amd.com opClasses = minorMakeOpClassSet(['IntMult']) 13613883Sdavid.hashe@amd.com timings = [MinorFUTiming(description='Mul', 13713883Sdavid.hashe@amd.com srcRegsRelativeLats=[0])] 13813883Sdavid.hashe@amd.com opLat = 3 13913883Sdavid.hashe@amd.com 14013883Sdavid.hashe@amd.comclass MinorDefaultIntDivFU(MinorFU): 14113883Sdavid.hashe@amd.com opClasses = minorMakeOpClassSet(['IntDiv']) 14213883Sdavid.hashe@amd.com issueLat = 9 14313883Sdavid.hashe@amd.com opLat = 9 14413883Sdavid.hashe@amd.com 14513883Sdavid.hashe@amd.comclass MinorDefaultFloatSimdFU(MinorFU): 14613883Sdavid.hashe@amd.com opClasses = minorMakeOpClassSet([ 14713883Sdavid.hashe@amd.com 'FloatAdd', 'FloatCmp', 'FloatCvt', 'FloatMisc', 'FloatMult', 14813883Sdavid.hashe@amd.com 'FloatMultAcc', 'FloatDiv', 'FloatSqrt', 14913883Sdavid.hashe@amd.com 'SimdAdd', 'SimdAddAcc', 'SimdAlu', 'SimdCmp', 'SimdCvt', 15013883Sdavid.hashe@amd.com 'SimdMisc', 'SimdMult', 'SimdMultAcc', 'SimdShift', 'SimdShiftAcc', 15113883Sdavid.hashe@amd.com 'SimdSqrt', 'SimdFloatAdd', 'SimdFloatAlu', 'SimdFloatCmp', 15213883Sdavid.hashe@amd.com 'SimdFloatCvt', 'SimdFloatDiv', 'SimdFloatMisc', 'SimdFloatMult', 15313883Sdavid.hashe@amd.com 'SimdFloatMultAcc', 'SimdFloatSqrt', 'SimdAes', 'SimdAesMix', 15413883Sdavid.hashe@amd.com 'SimdSha1Hash', 'SimdSha1Hash2', 'SimdSha256Hash', 15513883Sdavid.hashe@amd.com 'SimdSha256Hash2', 'SimdShaSigma2', 'SimdShaSigma3']) 15613883Sdavid.hashe@amd.com timings = [MinorFUTiming(description='FloatSimd', 15713883Sdavid.hashe@amd.com srcRegsRelativeLats=[2])] 15813883Sdavid.hashe@amd.com opLat = 6 15913883Sdavid.hashe@amd.com 16013883Sdavid.hashe@amd.comclass MinorDefaultMemFU(MinorFU): 16113883Sdavid.hashe@amd.com opClasses = minorMakeOpClassSet(['MemRead', 'MemWrite', 'FloatMemRead', 16213883Sdavid.hashe@amd.com 'FloatMemWrite']) 16313883Sdavid.hashe@amd.com timings = [MinorFUTiming(description='Mem', 16413883Sdavid.hashe@amd.com srcRegsRelativeLats=[1], extraAssumedLat=2)] 16513883Sdavid.hashe@amd.com opLat = 1 16613883Sdavid.hashe@amd.com 16713883Sdavid.hashe@amd.comclass MinorDefaultMiscFU(MinorFU): 16813883Sdavid.hashe@amd.com opClasses = minorMakeOpClassSet(['IprAccess', 'InstPrefetch']) 16913883Sdavid.hashe@amd.com opLat = 1 17013883Sdavid.hashe@amd.com 17113883Sdavid.hashe@amd.comclass MinorDefaultFUPool(MinorFUPool): 17213883Sdavid.hashe@amd.com funcUnits = [MinorDefaultIntFU(), MinorDefaultIntFU(), 17313883Sdavid.hashe@amd.com MinorDefaultIntMulFU(), MinorDefaultIntDivFU(), 17413883Sdavid.hashe@amd.com MinorDefaultFloatSimdFU(), MinorDefaultMemFU(), 17513883Sdavid.hashe@amd.com MinorDefaultMiscFU()] 176 177class ThreadPolicy(Enum): vals = ['SingleThreaded', 'RoundRobin', 'Random'] 178 179class MinorCPU(BaseCPU): 180 type = 'MinorCPU' 181 cxx_header = "cpu/minor/cpu.hh" 182 183 @classmethod 184 def memory_mode(cls): 185 return 'timing' 186 187 @classmethod 188 def require_caches(cls): 189 return True 190 191 @classmethod 192 def support_take_over(cls): 193 return True 194 195 threadPolicy = Param.ThreadPolicy('RoundRobin', 196 "Thread scheduling policy") 197 fetch1FetchLimit = Param.Unsigned(1, 198 "Number of line fetches allowable in flight at once") 199 fetch1LineSnapWidth = Param.Unsigned(0, 200 "Fetch1 'line' fetch snap size in bytes" 201 " (0 means use system cache line size)") 202 fetch1LineWidth = Param.Unsigned(0, 203 "Fetch1 maximum fetch size in bytes (0 means use system cache" 204 " line size)") 205 fetch1ToFetch2ForwardDelay = Param.Cycles(1, 206 "Forward cycle delay from Fetch1 to Fetch2 (1 means next cycle)") 207 fetch1ToFetch2BackwardDelay = Param.Cycles(1, 208 "Backward cycle delay from Fetch2 to Fetch1 for branch prediction" 209 " signalling (0 means in the same cycle, 1 mean the next cycle)") 210 211 fetch2InputBufferSize = Param.Unsigned(2, 212 "Size of input buffer to Fetch2 in cycles-worth of insts.") 213 fetch2ToDecodeForwardDelay = Param.Cycles(1, 214 "Forward cycle delay from Fetch2 to Decode (1 means next cycle)") 215 fetch2CycleInput = Param.Bool(True, 216 "Allow Fetch2 to cross input lines to generate full output each" 217 " cycle") 218 219 decodeInputBufferSize = Param.Unsigned(3, 220 "Size of input buffer to Decode in cycles-worth of insts.") 221 decodeToExecuteForwardDelay = Param.Cycles(1, 222 "Forward cycle delay from Decode to Execute (1 means next cycle)") 223 decodeInputWidth = Param.Unsigned(2, 224 "Width (in instructions) of input to Decode (and implicitly" 225 " Decode's own width)") 226 decodeCycleInput = Param.Bool(True, 227 "Allow Decode to pack instructions from more than one input cycle" 228 " to fill its output each cycle") 229 230 executeInputWidth = Param.Unsigned(2, 231 "Width (in instructions) of input to Execute") 232 executeCycleInput = Param.Bool(True, 233 "Allow Execute to use instructions from more than one input cycle" 234 " each cycle") 235 executeIssueLimit = Param.Unsigned(2, 236 "Number of issuable instructions in Execute each cycle") 237 executeMemoryIssueLimit = Param.Unsigned(1, 238 "Number of issuable memory instructions in Execute each cycle") 239 executeCommitLimit = Param.Unsigned(2, 240 "Number of committable instructions in Execute each cycle") 241 executeMemoryCommitLimit = Param.Unsigned(1, 242 "Number of committable memory references in Execute each cycle") 243 executeInputBufferSize = Param.Unsigned(7, 244 "Size of input buffer to Execute in cycles-worth of insts.") 245 executeMemoryWidth = Param.Unsigned(0, 246 "Width (and snap) in bytes of the data memory interface. (0 mean use" 247 " the system cacheLineSize)") 248 executeMaxAccessesInMemory = Param.Unsigned(2, 249 "Maximum number of concurrent accesses allowed to the memory system" 250 " from the dcache port") 251 executeLSQMaxStoreBufferStoresPerCycle = Param.Unsigned(2, 252 "Maximum number of stores that the store buffer can issue per cycle") 253 executeLSQRequestsQueueSize = Param.Unsigned(1, 254 "Size of LSQ requests queue (address translation queue)") 255 executeLSQTransfersQueueSize = Param.Unsigned(2, 256 "Size of LSQ transfers queue (memory transaction queue)") 257 executeLSQStoreBufferSize = Param.Unsigned(5, 258 "Size of LSQ store buffer") 259 executeBranchDelay = Param.Cycles(1, 260 "Delay from Execute deciding to branch and Fetch1 reacting" 261 " (1 means next cycle)") 262 263 executeFuncUnits = Param.MinorFUPool(MinorDefaultFUPool(), 264 "FUlines for this processor") 265 266 executeSetTraceTimeOnCommit = Param.Bool(True, 267 "Set inst. trace times to be commit times") 268 executeSetTraceTimeOnIssue = Param.Bool(False, 269 "Set inst. trace times to be issue times") 270 271 executeAllowEarlyMemoryIssue = Param.Bool(True, 272 "Allow mem refs to be issued to the LSQ before reaching the head of" 273 " the in flight insts queue") 274 275 enableIdling = Param.Bool(True, 276 "Enable cycle skipping when the processor is idle\n"); 277 278 branchPred = Param.BranchPredictor(TournamentBP( 279 numThreads = Parent.numThreads), "Branch Predictor") 280 281 def addCheckerCpu(self): 282 print("Checker not yet supported by MinorCPU") 283 exit(1) 284