From f388fb1659e14cd55fdd22e35e260129b8e2fc10 Mon Sep 17 00:00:00 2001 From: Jerry Zhao Date: Sat, 29 Jun 2024 14:03:46 -0700 Subject: [PATCH 1/7] Split RocketConfigs into separate file --- src/main/scala/subsystem/Configs.scala | 576 +----------------- src/main/scala/subsystem/RocketConfigs.scala | 586 +++++++++++++++++++ 2 files changed, 588 insertions(+), 574 deletions(-) create mode 100644 src/main/scala/subsystem/RocketConfigs.scala diff --git a/src/main/scala/subsystem/Configs.scala b/src/main/scala/subsystem/Configs.scala index 195fff022ef..c280920ff98 100644 --- a/src/main/scala/subsystem/Configs.scala +++ b/src/main/scala/subsystem/Configs.scala @@ -19,9 +19,9 @@ import freechips.rocketchip.diplomacy.{ import freechips.rocketchip.resources.{ DTSModel, DTSCompat, DTSTimebase, BigIntHexContext } -import freechips.rocketchip.rocket.{PgLevels, RocketCoreParams, MulDivParams, DCacheParams, ICacheParams, BTBParams, DebugROBParams} +import freechips.rocketchip.rocket.{PgLevels} import freechips.rocketchip.tile.{ - XLen, MaxHartIdBits, RocketTileParams, BuildRoCC, AccumulatorExample, OpcodeSet, TranslatorExample, CharacterCountExample, BlackBoxExample + XLen, MaxHartIdBits, RocketTileParams } import freechips.rocketchip.util.ClockGateModelFile @@ -102,148 +102,6 @@ class WithCoherentBusTopology extends Config((site, here, up) => { driveMBusClockFromSBus = site(DriveClocksFromSBus))) }) -class WithNBigCores( - n: Int, - location: HierarchicalLocation, - crossing: RocketCrossingParams, -) extends Config((site, here, up) => { - case TilesLocated(`location`) => { - val prev = up(TilesLocated(`location`), site) - val idOffset = up(NumTiles) - val big = RocketTileParams( - core = RocketCoreParams(mulDiv = Some(MulDivParams( - mulUnroll = 8, - mulEarlyOut = true, - divEarlyOut = true))), - dcache = Some(DCacheParams( - rowBits = site(SystemBusKey).beatBits, - nMSHRs = 0, - blockBytes = site(CacheBlockBytes))), - icache = Some(ICacheParams( - rowBits = site(SystemBusKey).beatBits, - blockBytes = site(CacheBlockBytes)))) - List.tabulate(n)(i => RocketTileAttachParams( - big.copy(tileId = i + idOffset), - crossing - )) ++ prev - } - case NumTiles => up(NumTiles) + n -}) { - def this(n: Int, location: HierarchicalLocation = InSubsystem) = this(n, location, RocketCrossingParams( - master = HierarchicalElementMasterPortParams.locationDefault(location), - slave = HierarchicalElementSlavePortParams.locationDefault(location), - mmioBaseAddressPrefixWhere = location match { - case InSubsystem => CBUS - case InCluster(clusterId) => CCBUS(clusterId) - } - )) -} - - - -class WithNMedCores( - n: Int, - crossing: RocketCrossingParams = RocketCrossingParams(), -) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => { - val prev = up(TilesLocated(InSubsystem), site) - val idOffset = up(NumTiles) - val med = RocketTileParams( - core = RocketCoreParams(fpu = None), - btb = None, - dcache = Some(DCacheParams( - rowBits = site(SystemBusKey).beatBits, - nSets = 64, - nWays = 1, - nTLBSets = 1, - nTLBWays = 4, - nMSHRs = 0, - blockBytes = site(CacheBlockBytes))), - icache = Some(ICacheParams( - rowBits = site(SystemBusKey).beatBits, - nSets = 64, - nWays = 1, - nTLBSets = 1, - nTLBWays = 4, - blockBytes = site(CacheBlockBytes)))) - List.tabulate(n)(i => RocketTileAttachParams( - med.copy(tileId = i + idOffset), - crossing - )) ++ prev - } - case NumTiles => up(NumTiles) + n -}) - -class WithNSmallCores( - n: Int, - crossing: RocketCrossingParams = RocketCrossingParams() -) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => { - val prev = up(TilesLocated(InSubsystem), site) - val idOffset = up(NumTiles) - val small = RocketTileParams( - core = RocketCoreParams(useVM = false, fpu = None), - btb = None, - dcache = Some(DCacheParams( - rowBits = site(SystemBusKey).beatBits, - nSets = 64, - nWays = 1, - nTLBSets = 1, - nTLBWays = 4, - nMSHRs = 0, - blockBytes = site(CacheBlockBytes))), - icache = Some(ICacheParams( - rowBits = site(SystemBusKey).beatBits, - nSets = 64, - nWays = 1, - nTLBSets = 1, - nTLBWays = 4, - blockBytes = site(CacheBlockBytes)))) - List.tabulate(n)(i => RocketTileAttachParams( - small.copy(tileId = i + idOffset), - crossing - )) ++ prev - } - case NumTiles => up(NumTiles) + n -}) - -class With1TinyCore extends Config((site, here, up) => { - case XLen => 32 - case TilesLocated(InSubsystem) => { - val tiny = RocketTileParams( - core = RocketCoreParams( - useVM = false, - fpu = None, - mulDiv = Some(MulDivParams(mulUnroll = 8))), - btb = None, - dcache = Some(DCacheParams( - rowBits = site(SystemBusKey).beatBits, - nSets = 256, // 16Kb scratchpad - nWays = 1, - nTLBSets = 1, - nTLBWays = 4, - nMSHRs = 0, - blockBytes = site(CacheBlockBytes), - scratch = Some(0x80000000L))), - icache = Some(ICacheParams( - rowBits = site(SystemBusKey).beatBits, - nSets = 64, - nWays = 1, - nTLBSets = 1, - nTLBWays = 4, - blockBytes = site(CacheBlockBytes))) - ) - List(RocketTileAttachParams( - tiny, - RocketCrossingParams( - crossingType = SynchronousCrossing(), - master = HierarchicalElementMasterPortParams()) - )) - } - case NumTiles => 1 - case ClustersLocated(_) => Nil -}) - class WithCluster( clusterId: Int, location: HierarchicalLocation = InSubsystem, @@ -275,177 +133,6 @@ class WithNTrackersPerBank(n: Int) extends Config((site, here, up) => { case BroadcastKey => up(BroadcastKey, site).copy(nTrackers = n) }) -// This is the number of icache sets for all Rocket tiles -class WithL1ICacheSets(sets: Int) extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - icache = tp.tileParams.icache.map(_.copy(nSets = sets)))) - case t => t - } -}) - -// This is the number of icache sets for all Rocket tiles -class WithL1DCacheSets(sets: Int) extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map(_.copy(nSets = sets)))) - case t => t - } -}) - -class WithL1ICacheWays(ways: Int) extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - icache = tp.tileParams.icache.map(_.copy(nWays = ways)))) - case t => t - } -}) - -class WithL1DCacheWays(ways: Int) extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map(_.copy(nWays = ways)))) - case t => t - } -}) - -class WithL1ICacheECC(dataECC: String, tagECC: String) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - icache = tp.tileParams.icache.map(_.copy(dataECC = Some(dataECC), tagECC = Some(tagECC))))) - case t => t - } -}) - -class WithL1DCacheECC(dataECC: String, tagECC: String) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map(_.copy(dataECC = Some(dataECC), tagECC = Some(tagECC), dataECCBytes=8)))) - case t => t - } -}) - -class WithL1ICacheTLBSets(tlbsets: Int) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - icache = tp.tileParams.icache.map(_.copy(nTLBSets = tlbsets)))) - case t => t - } -}) - -class WithL1DCacheTLBSets(tlbsets: Int) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map(_.copy(nTLBSets = tlbsets)))) - case t => t - } -}) - -class WithL1ICacheTLBWays(tlbways: Int) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - icache = tp.tileParams.icache.map(_.copy(nTLBWays = tlbways)))) - case t => t - } -}) - -class WithL1DCacheTLBWays(tlbways: Int) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map(_.copy(nTLBWays = tlbways)))) - case t => t - } -}) - -class WithL1ICacheTLBBasePageSectors(pagesectors: Int) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - icache = tp.tileParams.icache.map(_.copy(nTLBBasePageSectors = pagesectors)))) - case t => t - } -}) - -class WithL1DCacheTLBBasePageSectors(pagesectors: Int) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map(_.copy(nTLBBasePageSectors = pagesectors)))) - case t => t - } -}) - -class WithL1ICacheTLBSuperpages(superpages: Int) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - icache = tp.tileParams.icache.map(_.copy(nTLBSuperpages = superpages)))) - case t => t - } -}) - -class WithL1DCacheTLBSuperpages(superpages: Int) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map(_.copy(nTLBSuperpages = superpages)))) - case t => t - } -}) - -class WithRocketICacheRowBits(n: Int) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - icache = tp.tileParams.icache.map(_.copy(rowBits = n)))) - case t => t - } -}) - -class WithRocketDCacheRowBits(n: Int) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map(_.copy(rowBits = n)))) - case t => t - } -}) - -class WithL1ICacheBlockBytes(bytes: Int = 64) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - icache = tp.tileParams.icache.map(_.copy(blockBytes = bytes)))) - case t => t - } -}) - -class WithL1DCacheBlockBytes(bytes: Int = 64) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map(_.copy(blockBytes = bytes)))) - case t => t - } -}) - -class WithoutVM extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(useVM = false))) - case t => t - } -}) - -class WithCFlushEnabled extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(haveCFlush = true))) - case t => t - } -}) - -class WithRocketCacheRowBits(n: Int) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map(_.copy(rowBits = n)), - icache = tp.tileParams.icache.map(_.copy(rowBits = n)))) - case t => t - } -}) - class WithCacheBlockBytes(linesize: Int) extends Config((site, here, up) => { case CacheBlockBytes => linesize }) @@ -480,198 +167,6 @@ class WithIncoherentTiles extends Config((site, here, up) => { ) }) -class WithRV32 extends Config((site, here, up) => { - case XLen => 32 - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy( - fpu = tp.tileParams.core.fpu.map(_.copy(fLen = 32)), - mulDiv = Some(MulDivParams(mulUnroll = 8))))) - case t => t - } -}) - -class WithFP16 extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy( - fpu = tp.tileParams.core.fpu.map(_.copy(minFLen = 16)) - ) - )) - case t => t - } -}) - -class WithNonblockingL1(nMSHRs: Int) extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map(_.copy(nMSHRs = nMSHRs)))) - case t => t - } -}) - -class WithNBreakpoints(hwbp: Int) extends Config ((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(nBreakpoints = hwbp))) - case t => t - } -}) - -class WithHypervisor(hext: Boolean = true) extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(useHypervisor = hext))) - case t => t - } -}) - -class WithRoccExample extends Config((site, here, up) => { - case BuildRoCC => List( - (p: Parameters) => { - val accumulator = LazyModule(new AccumulatorExample(OpcodeSet.custom0, n = 4)(p)) - accumulator - }, - (p: Parameters) => { - val translator = LazyModule(new TranslatorExample(OpcodeSet.custom1)(p)) - translator - }, - (p: Parameters) => { - val counter = LazyModule(new CharacterCountExample(OpcodeSet.custom2)(p)) - counter - }, - (p: Parameters) => { - val blackbox = LazyModule(new BlackBoxExample(OpcodeSet.custom3, "RoccBlackBox")(p)) - blackbox - }) -}) - -class WithDefaultBtb extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - btb = Some(BTBParams()))) - case t => t - } -}) - -class WithNoBtb extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - btb = None)) - case t => t - } -}) - -class WithFastMulDiv extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(mulDiv = Some( - MulDivParams(mulUnroll = 8, mulEarlyOut = (site(XLen) > 32), divEarlyOut = true))))) - case t => t - } -}) - -class WithCustomFastMulDiv(mUnroll: Int = 8, mEarlyOut: Boolean = true, dUnroll: Int = 1, dEarlyOut: Boolean = true, dEarlyOutGranularity: Int = 1) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(mulDiv = Some( - MulDivParams(mulUnroll = mUnroll, mulEarlyOut = mEarlyOut, divUnroll = dUnroll, divEarlyOut = dEarlyOut, divEarlyOutGranularity = dEarlyOutGranularity))))) - case t => t - } -}) - -class WithoutMulDiv extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(mulDiv = None))) - case t => t - } -}) - -class WithoutFPU extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(fpu = None))) - case t => t - } -}) - -class WithFPUWithoutDivSqrt extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(fpu = tp.tileParams.core.fpu.map(_.copy(divSqrt = false))))) - case t => t - } -}) - -class WithBEU(addr: BigInt) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy(beuAddr = Some(addr))) - case t => t - } -}) - -class WithRocketTileCDC(crossingType: ClockCrossingType = SynchronousCrossing()) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(crossingParams = tp.crossingParams.copy( - crossingType = crossingType - )) - case other => other - } -}) - -class WithSeperateClockReset extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(crossingParams = tp.crossingParams.copy( - forceSeparateClockReset = true - )) - case other => other - } -}) - - -class WithRocketDebugROB(enable: Boolean = true, size: Int = 0) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams if (enable) => - tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(debugROB = Some(DebugROBParams(size))) - )) - } -}) - -class WithRocketCease(enable: Boolean = true) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(haveCease = enable) - )) - } -}) - -class WithCoreClockGatingEnabled extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(clockGate = true) - )) - case t => t - } -}) - -class WithDCacheClockGatingEnabled extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map(_.copy(clockGate = true)))) - case t => t - } -}) - -class WithNoSimulationTimeout extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(haveSimTimeout = false))) - case t => t - } -}) - class WithBootROMFile(bootROMFile: String) extends Config((site, here, up) => { case BootROMLocated(x) => up(BootROMLocated(x), site).map(_.copy(contentFileName = bootROMFile)) }) @@ -680,30 +175,6 @@ class WithClockGateModel(file: String = "/vsrc/EICG_wrapper.v") extends Config(( case ClockGateModelFile => Some(file) }) -class WithSynchronousRocketTiles extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(crossingParams = tp.crossingParams.copy( - crossingType = SynchronousCrossing())) - case t => t - } -}) - -class WithAsynchronousRocketTiles(depth: Int, sync: Int) extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(crossingParams = tp.crossingParams.copy( - crossingType = AsynchronousCrossing())) - case t => t - } -}) - -class WithRationalRocketTiles extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(crossingParams = tp.crossingParams.copy( - crossingType = RationalCrossing())) - case t => t - } -}) - class WithEdgeDataBits(dataBits: Int) extends Config((site, here, up) => { case MemoryBusKey => up(MemoryBusKey, site).copy(beatBytes = dataBits/8) case ExtIn => up(ExtIn, site).map(_.copy(beatBytes = dataBits/8)) @@ -809,29 +280,6 @@ class WithNoSlavePort extends Config((site, here, up) => { case ExtIn => None }) -class WithScratchpadsBaseAddress(address: BigInt) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map( - _.copy(scratch = Some(address)) - ) - )) - case t => t - } -}) - -class WithScratchpadsOnly extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(useVM = false), - dcache = tp.tileParams.dcache.map(_.copy( - nSets = 256, // 16Kb scratchpad - nWays = 1, - scratch = Some(0x80000000L))))) - case t => t - } -}) - /** * Mixins to specify crossing types between the 5 traditional TL buses * @@ -880,26 +328,6 @@ class WithDontDriveBusClocksFromSBus extends Config((site, here, up) => { case DriveClocksFromSBus => false }) -class WithCloneRocketTiles( - n: Int = 1, - cloneTileId: Int = 0, - location: HierarchicalLocation = InSubsystem, - cloneLocation: HierarchicalLocation = InSubsystem -) extends Config((site, here, up) => { - case TilesLocated(`location`) => { - val prev = up(TilesLocated(location), site) - val idOffset = up(NumTiles) - val tileAttachParams = up(TilesLocated(cloneLocation)).find(_.tileParams.tileId == cloneTileId) - .get.asInstanceOf[RocketTileAttachParams] - (0 until n).map { i => - CloneTileAttachParams(cloneTileId, tileAttachParams.copy( - tileParams = tileAttachParams.tileParams.copy(tileId = i + idOffset) - )) - } ++ prev - } - case NumTiles => up(NumTiles) + n -}) - class WithCloneCluster( clusterId: Int, cloneClusterId: Int = 0, diff --git a/src/main/scala/subsystem/RocketConfigs.scala b/src/main/scala/subsystem/RocketConfigs.scala new file mode 100644 index 00000000000..00ced60cade --- /dev/null +++ b/src/main/scala/subsystem/RocketConfigs.scala @@ -0,0 +1,586 @@ +package freechips.rocketchip.subsystem +// TODO move to freechips.rocketchip.rocket + +import chisel3.util._ + +import org.chipsalliance.cde.config._ +import org.chipsalliance.diplomacy.lazymodule._ + +import freechips.rocketchip.prci.{SynchronousCrossing, AsynchronousCrossing, RationalCrossing, ClockCrossingType} +import freechips.rocketchip.rocket.{PgLevels, RocketCoreParams, MulDivParams, DCacheParams, ICacheParams, BTBParams, DebugROBParams} +import freechips.rocketchip.tile.{ + XLen, MaxHartIdBits, RocketTileParams, BuildRoCC, AccumulatorExample, OpcodeSet, TranslatorExample, CharacterCountExample, BlackBoxExample +} + +class WithNBigCores( + n: Int, + location: HierarchicalLocation, + crossing: RocketCrossingParams, +) extends Config((site, here, up) => { + case TilesLocated(`location`) => { + val prev = up(TilesLocated(`location`), site) + val idOffset = up(NumTiles) + val big = RocketTileParams( + core = RocketCoreParams(mulDiv = Some(MulDivParams( + mulUnroll = 8, + mulEarlyOut = true, + divEarlyOut = true))), + dcache = Some(DCacheParams( + rowBits = site(SystemBusKey).beatBits, + nMSHRs = 0, + blockBytes = site(CacheBlockBytes))), + icache = Some(ICacheParams( + rowBits = site(SystemBusKey).beatBits, + blockBytes = site(CacheBlockBytes)))) + List.tabulate(n)(i => RocketTileAttachParams( + big.copy(tileId = i + idOffset), + crossing + )) ++ prev + } + case NumTiles => up(NumTiles) + n +}) { + def this(n: Int, location: HierarchicalLocation = InSubsystem) = this(n, location, RocketCrossingParams( + master = HierarchicalElementMasterPortParams.locationDefault(location), + slave = HierarchicalElementSlavePortParams.locationDefault(location), + mmioBaseAddressPrefixWhere = location match { + case InSubsystem => CBUS + case InCluster(clusterId) => CCBUS(clusterId) + } + )) +} + + + +class WithNMedCores( + n: Int, + crossing: RocketCrossingParams = RocketCrossingParams(), +) extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => { + val prev = up(TilesLocated(InSubsystem), site) + val idOffset = up(NumTiles) + val med = RocketTileParams( + core = RocketCoreParams(fpu = None), + btb = None, + dcache = Some(DCacheParams( + rowBits = site(SystemBusKey).beatBits, + nSets = 64, + nWays = 1, + nTLBSets = 1, + nTLBWays = 4, + nMSHRs = 0, + blockBytes = site(CacheBlockBytes))), + icache = Some(ICacheParams( + rowBits = site(SystemBusKey).beatBits, + nSets = 64, + nWays = 1, + nTLBSets = 1, + nTLBWays = 4, + blockBytes = site(CacheBlockBytes)))) + List.tabulate(n)(i => RocketTileAttachParams( + med.copy(tileId = i + idOffset), + crossing + )) ++ prev + } + case NumTiles => up(NumTiles) + n +}) + +class WithNSmallCores( + n: Int, + crossing: RocketCrossingParams = RocketCrossingParams() +) extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => { + val prev = up(TilesLocated(InSubsystem), site) + val idOffset = up(NumTiles) + val small = RocketTileParams( + core = RocketCoreParams(useVM = false, fpu = None), + btb = None, + dcache = Some(DCacheParams( + rowBits = site(SystemBusKey).beatBits, + nSets = 64, + nWays = 1, + nTLBSets = 1, + nTLBWays = 4, + nMSHRs = 0, + blockBytes = site(CacheBlockBytes))), + icache = Some(ICacheParams( + rowBits = site(SystemBusKey).beatBits, + nSets = 64, + nWays = 1, + nTLBSets = 1, + nTLBWays = 4, + blockBytes = site(CacheBlockBytes)))) + List.tabulate(n)(i => RocketTileAttachParams( + small.copy(tileId = i + idOffset), + crossing + )) ++ prev + } + case NumTiles => up(NumTiles) + n +}) + +class With1TinyCore extends Config((site, here, up) => { + case XLen => 32 + case TilesLocated(InSubsystem) => { + val tiny = RocketTileParams( + core = RocketCoreParams( + useVM = false, + fpu = None, + mulDiv = Some(MulDivParams(mulUnroll = 8))), + btb = None, + dcache = Some(DCacheParams( + rowBits = site(SystemBusKey).beatBits, + nSets = 256, // 16Kb scratchpad + nWays = 1, + nTLBSets = 1, + nTLBWays = 4, + nMSHRs = 0, + blockBytes = site(CacheBlockBytes), + scratch = Some(0x80000000L))), + icache = Some(ICacheParams( + rowBits = site(SystemBusKey).beatBits, + nSets = 64, + nWays = 1, + nTLBSets = 1, + nTLBWays = 4, + blockBytes = site(CacheBlockBytes))) + ) + List(RocketTileAttachParams( + tiny, + RocketCrossingParams( + crossingType = SynchronousCrossing(), + master = HierarchicalElementMasterPortParams()) + )) + } + case NumTiles => 1 + case ClustersLocated(_) => Nil +}) + +// This is the number of icache sets for all Rocket tiles +class WithL1ICacheSets(sets: Int) extends Config((site, here, up) => { + case TilesLocated(location) => up(TilesLocated(location), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + icache = tp.tileParams.icache.map(_.copy(nSets = sets)))) + case t => t + } +}) + +// This is the number of icache sets for all Rocket tiles +class WithL1DCacheSets(sets: Int) extends Config((site, here, up) => { + case TilesLocated(location) => up(TilesLocated(location), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + dcache = tp.tileParams.dcache.map(_.copy(nSets = sets)))) + case t => t + } +}) + +class WithL1ICacheWays(ways: Int) extends Config((site, here, up) => { + case TilesLocated(location) => up(TilesLocated(location), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + icache = tp.tileParams.icache.map(_.copy(nWays = ways)))) + case t => t + } +}) + +class WithL1DCacheWays(ways: Int) extends Config((site, here, up) => { + case TilesLocated(location) => up(TilesLocated(location), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + dcache = tp.tileParams.dcache.map(_.copy(nWays = ways)))) + case t => t + } +}) + +class WithL1ICacheECC(dataECC: String, tagECC: String) extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + icache = tp.tileParams.icache.map(_.copy(dataECC = Some(dataECC), tagECC = Some(tagECC))))) + case t => t + } +}) + +class WithL1DCacheECC(dataECC: String, tagECC: String) extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + dcache = tp.tileParams.dcache.map(_.copy(dataECC = Some(dataECC), tagECC = Some(tagECC), dataECCBytes=8)))) + case t => t + } +}) + +class WithL1ICacheTLBSets(tlbsets: Int) extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + icache = tp.tileParams.icache.map(_.copy(nTLBSets = tlbsets)))) + case t => t + } +}) + +class WithL1DCacheTLBSets(tlbsets: Int) extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + dcache = tp.tileParams.dcache.map(_.copy(nTLBSets = tlbsets)))) + case t => t + } +}) + +class WithL1ICacheTLBWays(tlbways: Int) extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + icache = tp.tileParams.icache.map(_.copy(nTLBWays = tlbways)))) + case t => t + } +}) + +class WithL1DCacheTLBWays(tlbways: Int) extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + dcache = tp.tileParams.dcache.map(_.copy(nTLBWays = tlbways)))) + case t => t + } +}) + +class WithL1ICacheTLBBasePageSectors(pagesectors: Int) extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + icache = tp.tileParams.icache.map(_.copy(nTLBBasePageSectors = pagesectors)))) + case t => t + } +}) + +class WithL1DCacheTLBBasePageSectors(pagesectors: Int) extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + dcache = tp.tileParams.dcache.map(_.copy(nTLBBasePageSectors = pagesectors)))) + case t => t + } +}) + +class WithL1ICacheTLBSuperpages(superpages: Int) extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + icache = tp.tileParams.icache.map(_.copy(nTLBSuperpages = superpages)))) + case t => t + } +}) + +class WithL1DCacheTLBSuperpages(superpages: Int) extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + dcache = tp.tileParams.dcache.map(_.copy(nTLBSuperpages = superpages)))) + case t => t + } +}) + +class WithRocketICacheRowBits(n: Int) extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + icache = tp.tileParams.icache.map(_.copy(rowBits = n)))) + case t => t + } +}) + +class WithRocketDCacheRowBits(n: Int) extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + dcache = tp.tileParams.dcache.map(_.copy(rowBits = n)))) + case t => t + } +}) + +class WithL1ICacheBlockBytes(bytes: Int = 64) extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + icache = tp.tileParams.icache.map(_.copy(blockBytes = bytes)))) + case t => t + } +}) + +class WithL1DCacheBlockBytes(bytes: Int = 64) extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + dcache = tp.tileParams.dcache.map(_.copy(blockBytes = bytes)))) + case t => t + } +}) + +class WithoutVM extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + core = tp.tileParams.core.copy(useVM = false))) + case t => t + } +}) + +class WithCFlushEnabled extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + core = tp.tileParams.core.copy(haveCFlush = true))) + case t => t + } +}) + +class WithRocketCacheRowBits(n: Int) extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + dcache = tp.tileParams.dcache.map(_.copy(rowBits = n)), + icache = tp.tileParams.icache.map(_.copy(rowBits = n)))) + case t => t + } +}) + +class WithRV32 extends Config((site, here, up) => { + case XLen => 32 + case TilesLocated(location) => up(TilesLocated(location), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + core = tp.tileParams.core.copy( + fpu = tp.tileParams.core.fpu.map(_.copy(fLen = 32)), + mulDiv = Some(MulDivParams(mulUnroll = 8))))) + case t => t + } +}) + +class WithFP16 extends Config((site, here, up) => { + case TilesLocated(location) => up(TilesLocated(location), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + core = tp.tileParams.core.copy( + fpu = tp.tileParams.core.fpu.map(_.copy(minFLen = 16)) + ) + )) + case t => t + } +}) + +class WithNonblockingL1(nMSHRs: Int) extends Config((site, here, up) => { + case TilesLocated(location) => up(TilesLocated(location), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + dcache = tp.tileParams.dcache.map(_.copy(nMSHRs = nMSHRs)))) + case t => t + } +}) + +class WithNBreakpoints(hwbp: Int) extends Config ((site, here, up) => { + case TilesLocated(location) => up(TilesLocated(location), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + core = tp.tileParams.core.copy(nBreakpoints = hwbp))) + case t => t + } +}) + +class WithHypervisor(hext: Boolean = true) extends Config((site, here, up) => { + case TilesLocated(location) => up(TilesLocated(location), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + core = tp.tileParams.core.copy(useHypervisor = hext))) + case t => t + } +}) + +class WithRoccExample extends Config((site, here, up) => { + case BuildRoCC => List( + (p: Parameters) => { + val accumulator = LazyModule(new AccumulatorExample(OpcodeSet.custom0, n = 4)(p)) + accumulator + }, + (p: Parameters) => { + val translator = LazyModule(new TranslatorExample(OpcodeSet.custom1)(p)) + translator + }, + (p: Parameters) => { + val counter = LazyModule(new CharacterCountExample(OpcodeSet.custom2)(p)) + counter + }, + (p: Parameters) => { + val blackbox = LazyModule(new BlackBoxExample(OpcodeSet.custom3, "RoccBlackBox")(p)) + blackbox + }) +}) + +class WithDefaultBtb extends Config((site, here, up) => { + case TilesLocated(location) => up(TilesLocated(location), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + btb = Some(BTBParams()))) + case t => t + } +}) + +class WithNoBtb extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + btb = None)) + case t => t + } +}) + +class WithFastMulDiv extends Config((site, here, up) => { + case TilesLocated(location) => up(TilesLocated(location), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + core = tp.tileParams.core.copy(mulDiv = Some( + MulDivParams(mulUnroll = 8, mulEarlyOut = (site(XLen) > 32), divEarlyOut = true))))) + case t => t + } +}) + +class WithCustomFastMulDiv(mUnroll: Int = 8, mEarlyOut: Boolean = true, dUnroll: Int = 1, dEarlyOut: Boolean = true, dEarlyOutGranularity: Int = 1) extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + core = tp.tileParams.core.copy(mulDiv = Some( + MulDivParams(mulUnroll = mUnroll, mulEarlyOut = mEarlyOut, divUnroll = dUnroll, divEarlyOut = dEarlyOut, divEarlyOutGranularity = dEarlyOutGranularity))))) + case t => t + } +}) + +class WithoutMulDiv extends Config((site, here, up) => { + case TilesLocated(location) => up(TilesLocated(location), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + core = tp.tileParams.core.copy(mulDiv = None))) + case t => t + } +}) + +class WithoutFPU extends Config((site, here, up) => { + case TilesLocated(location) => up(TilesLocated(location), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + core = tp.tileParams.core.copy(fpu = None))) + case t => t + } +}) + +class WithFPUWithoutDivSqrt extends Config((site, here, up) => { + case TilesLocated(location) => up(TilesLocated(location), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + core = tp.tileParams.core.copy(fpu = tp.tileParams.core.fpu.map(_.copy(divSqrt = false))))) + case t => t + } +}) + +class WithBEU(addr: BigInt) extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy(beuAddr = Some(addr))) + case t => t + } +}) + +class WithRocketTileCDC(crossingType: ClockCrossingType = SynchronousCrossing()) extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(crossingParams = tp.crossingParams.copy( + crossingType = crossingType + )) + case other => other + } +}) + +class WithSeperateClockReset extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(crossingParams = tp.crossingParams.copy( + forceSeparateClockReset = true + )) + case other => other + } +}) + + +class WithRocketDebugROB(enable: Boolean = true, size: Int = 0) extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams if (enable) => + tp.copy(tileParams = tp.tileParams.copy( + core = tp.tileParams.core.copy(debugROB = Some(DebugROBParams(size))) + )) + } +}) + +class WithRocketCease(enable: Boolean = true) extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + core = tp.tileParams.core.copy(haveCease = enable) + )) + } +}) + +class WithCoreClockGatingEnabled extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + core = tp.tileParams.core.copy(clockGate = true) + )) + case t => t + } +}) + +class WithDCacheClockGatingEnabled extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + dcache = tp.tileParams.dcache.map(_.copy(clockGate = true)))) + case t => t + } +}) + +class WithNoSimulationTimeout extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + core = tp.tileParams.core.copy(haveSimTimeout = false))) + case t => t + } +}) + +class WithSynchronousRocketTiles extends Config((site, here, up) => { + case TilesLocated(location) => up(TilesLocated(location), site) map { + case tp: RocketTileAttachParams => tp.copy(crossingParams = tp.crossingParams.copy( + crossingType = SynchronousCrossing())) + case t => t + } +}) + +class WithAsynchronousRocketTiles(depth: Int, sync: Int) extends Config((site, here, up) => { + case TilesLocated(location) => up(TilesLocated(location), site) map { + case tp: RocketTileAttachParams => tp.copy(crossingParams = tp.crossingParams.copy( + crossingType = AsynchronousCrossing())) + case t => t + } +}) + +class WithRationalRocketTiles extends Config((site, here, up) => { + case TilesLocated(location) => up(TilesLocated(location), site) map { + case tp: RocketTileAttachParams => tp.copy(crossingParams = tp.crossingParams.copy( + crossingType = RationalCrossing())) + case t => t + } +}) + +class WithScratchpadsBaseAddress(address: BigInt) extends Config((site, here, up) => { + case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + dcache = tp.tileParams.dcache.map( + _.copy(scratch = Some(address)) + ) + )) + case t => t + } +}) + +class WithScratchpadsOnly extends Config((site, here, up) => { + case TilesLocated(location) => up(TilesLocated(location), site) map { + case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( + core = tp.tileParams.core.copy(useVM = false), + dcache = tp.tileParams.dcache.map(_.copy( + nSets = 256, // 16Kb scratchpad + nWays = 1, + scratch = Some(0x80000000L))))) + case t => t + } +}) + +class WithCloneRocketTiles( + n: Int = 1, + cloneTileId: Int = 0, + location: HierarchicalLocation = InSubsystem, + cloneLocation: HierarchicalLocation = InSubsystem +) extends Config((site, here, up) => { + case TilesLocated(`location`) => { + val prev = up(TilesLocated(location), site) + val idOffset = up(NumTiles) + val tileAttachParams = up(TilesLocated(cloneLocation)).find(_.tileParams.tileId == cloneTileId) + .get.asInstanceOf[RocketTileAttachParams] + (0 until n).map { i => + CloneTileAttachParams(cloneTileId, tileAttachParams.copy( + tileParams = tileAttachParams.tileParams.copy(tileId = i + idOffset) + )) + } ++ prev + } + case NumTiles => up(NumTiles) + n +}) + From 53bf2636f302ad926ce4c8fcadd015094d048c55 Mon Sep 17 00:00:00 2001 From: Jerry Zhao Date: Sat, 29 Jun 2024 19:03:59 -0700 Subject: [PATCH 2/7] Move xLen/pgLevels to tile-local parameters --- src/main/scala/groundtest/Configs.scala | 6 ++--- src/main/scala/groundtest/TraceGen.scala | 8 +++---- src/main/scala/rocket/RVC.scala | 4 ++-- src/main/scala/rocket/RocketCore.scala | 2 ++ src/main/scala/rocket/TLB.scala | 1 - src/main/scala/subsystem/Configs.scala | 24 +++++++++++--------- src/main/scala/subsystem/RocketConfigs.scala | 14 ++++++------ src/main/scala/tile/BaseTile.scala | 8 +++---- src/main/scala/tile/BusErrorUnit.scala | 4 ++-- src/main/scala/tile/Core.scala | 3 ++- src/main/scala/tile/RocketTile.scala | 2 +- 11 files changed, 40 insertions(+), 36 deletions(-) diff --git a/src/main/scala/groundtest/Configs.scala b/src/main/scala/groundtest/Configs.scala index 997abc2e52d..e9b00689aa9 100644 --- a/src/main/scala/groundtest/Configs.scala +++ b/src/main/scala/groundtest/Configs.scala @@ -10,7 +10,6 @@ import freechips.rocketchip.devices.debug.{DebugModuleKey} import freechips.rocketchip.subsystem._ import freechips.rocketchip.system.BaseConfig import freechips.rocketchip.rocket.{DCacheParams} -import freechips.rocketchip.tile.{XLen} /** Actual testing target Configs */ @@ -39,7 +38,8 @@ class WithTraceGen( n: Int = 2, overrideMemOffset: Option[BigInt] = None)( params: Seq[DCacheParams] = List.fill(n){ DCacheParams(nSets = 16, nWays = 1) }, - nReqs: Int = 8192 + nReqs: Int = 8192, + wordBits: Int = 32 ) extends Config((site, here, up) => { case TilesLocated(InSubsystem) => { val prev = up(TilesLocated(InSubsystem), site) @@ -50,7 +50,7 @@ class WithTraceGen( tileParams = TraceGenParams( tileId = i + idOffset, dcache = Some(dcp), - wordBits = site(XLen), + wordBits = wordBits, addrBits = 32, addrBag = { val nSets = dcp.nSets diff --git a/src/main/scala/groundtest/TraceGen.scala b/src/main/scala/groundtest/TraceGen.scala index dfcb6cc426b..588f930978d 100644 --- a/src/main/scala/groundtest/TraceGen.scala +++ b/src/main/scala/groundtest/TraceGen.scala @@ -62,11 +62,11 @@ import freechips.rocketchip.prci.{ClockSinkParameters, ClockCrossingType} // to repeatedly recompile with a different address bag.) case class TraceGenParams( - wordBits: Int, // p(XLen) - addrBits: Int, // p(PAddrBits) - addrBag: List[BigInt], // p(AddressBag) + wordBits: Int, + addrBits: Int, + addrBag: List[BigInt], maxRequests: Int, - memStart: BigInt, //p(ExtMem).base + memStart: BigInt, numGens: Int, dcache: Option[DCacheParams] = Some(DCacheParams()), tileId: Int = 0 diff --git a/src/main/scala/rocket/RVC.scala b/src/main/scala/rocket/RVC.scala index 71ac35ee480..c9252c086cf 100644 --- a/src/main/scala/rocket/RVC.scala +++ b/src/main/scala/rocket/RVC.scala @@ -197,12 +197,12 @@ class RVCExpander(useAddiForMv: Boolean = false)(implicit val p: Parameters) ext if (usingCompressed) { io.rvc := io.in(1,0) =/= 3.U - val decoder = new RVCDecoder(io.in, p(XLen), fLen, useAddiForMv) + val decoder = new RVCDecoder(io.in, xLen, fLen, useAddiForMv) io.out := decoder.decode io.ill := decoder.ill } else { io.rvc := false.B - io.out := new RVCDecoder(io.in, p(XLen), fLen, useAddiForMv).passthrough + io.out := new RVCDecoder(io.in, xLen, fLen, useAddiForMv).passthrough io.ill := false.B // only used for RVC } } diff --git a/src/main/scala/rocket/RocketCore.scala b/src/main/scala/rocket/RocketCore.scala index 8fbe232824e..d82f3175108 100644 --- a/src/main/scala/rocket/RocketCore.scala +++ b/src/main/scala/rocket/RocketCore.scala @@ -13,6 +13,8 @@ import freechips.rocketchip.util.property import scala.collection.mutable.ArrayBuffer case class RocketCoreParams( + xLen: Int = 64, + pgLevels: Int = 32, // sv39 default bootFreqHz: BigInt = 0, useVM: Boolean = true, useUser: Boolean = false, diff --git a/src/main/scala/rocket/TLB.scala b/src/main/scala/rocket/TLB.scala index e0a6ddea797..8cc4a2c67c9 100644 --- a/src/main/scala/rocket/TLB.scala +++ b/src/main/scala/rocket/TLB.scala @@ -23,7 +23,6 @@ import freechips.rocketchip.util.UIntIsOneOf import freechips.rocketchip.util.SeqToAugmentedSeq import freechips.rocketchip.util.SeqBoolBitwiseOps -case object PgLevels extends Field[Int](2) case object ASIdBits extends Field[Int](0) case object VMIdBits extends Field[Int](0) diff --git a/src/main/scala/subsystem/Configs.scala b/src/main/scala/subsystem/Configs.scala index c280920ff98..cd9c7412690 100644 --- a/src/main/scala/subsystem/Configs.scala +++ b/src/main/scala/subsystem/Configs.scala @@ -19,42 +19,44 @@ import freechips.rocketchip.diplomacy.{ import freechips.rocketchip.resources.{ DTSModel, DTSCompat, DTSTimebase, BigIntHexContext } -import freechips.rocketchip.rocket.{PgLevels} import freechips.rocketchip.tile.{ - XLen, MaxHartIdBits, RocketTileParams + MaxHartIdBits, RocketTileParams } import freechips.rocketchip.util.ClockGateModelFile +import scala.reflect.ClassTag + +case object MaxXLen extends Field[Int] class BaseSubsystemConfig extends Config ((site, here, up) => { // Tile parameters - case PgLevels => if (site(XLen) == 64) 3 /* Sv39 */ else 2 /* Sv32 */ - case XLen => 64 // Applies to all cores + case MaxXLen => (site(PossibleTileLocations).flatMap(loc => site(TilesLocated(loc))) + .map(_.tileParams.core.xLen) :+ 32).max case MaxHartIdBits => log2Up((site(PossibleTileLocations).flatMap(loc => site(TilesLocated(loc))) .map(_.tileParams.tileId) :+ 0).max+1) // Interconnect parameters case SystemBusKey => SystemBusParams( - beatBytes = site(XLen)/8, + beatBytes = site(MaxXLen)/8, blockBytes = site(CacheBlockBytes)) case ControlBusKey => PeripheryBusParams( - beatBytes = site(XLen)/8, + beatBytes = site(MaxXLen)/8, blockBytes = site(CacheBlockBytes), dtsFrequency = Some(100000000), // Default to 100 MHz cbus clock errorDevice = Some(BuiltInErrorDeviceParams( - errorParams = DevNullParams(List(AddressSet(0x3000, 0xfff)), maxAtomic=site(XLen)/8, maxTransfer=4096)))) + errorParams = DevNullParams(List(AddressSet(0x3000, 0xfff)), maxAtomic=site(MaxXLen)/8, maxTransfer=4096)))) case PeripheryBusKey => PeripheryBusParams( - beatBytes = site(XLen)/8, + beatBytes = site(MaxXLen)/8, blockBytes = site(CacheBlockBytes), dtsFrequency = Some(100000000)) // Default to 100 MHz pbus clock case MemoryBusKey => MemoryBusParams( - beatBytes = site(XLen)/8, + beatBytes = site(MaxXLen)/8, blockBytes = site(CacheBlockBytes)) case FrontBusKey => FrontBusParams( - beatBytes = site(XLen)/8, + beatBytes = site(MaxXLen)/8, blockBytes = site(CacheBlockBytes)) // Additional device Parameters case BootROMLocated(InSubsystem) => Some(BootROMParams(contentFileName = "./bootrom/bootrom.img")) case HasTilesExternalResetVectorKey => false - case DebugModuleKey => Some(DefaultDebugModuleParams(site(XLen))) + case DebugModuleKey => Some(DefaultDebugModuleParams(site(MaxXLen))) case CLINTKey => Some(CLINTParams()) case PLICKey => Some(PLICParams()) case TilesLocated(InSubsystem) => Nil diff --git a/src/main/scala/subsystem/RocketConfigs.scala b/src/main/scala/subsystem/RocketConfigs.scala index 00ced60cade..6919c014672 100644 --- a/src/main/scala/subsystem/RocketConfigs.scala +++ b/src/main/scala/subsystem/RocketConfigs.scala @@ -7,9 +7,9 @@ import org.chipsalliance.cde.config._ import org.chipsalliance.diplomacy.lazymodule._ import freechips.rocketchip.prci.{SynchronousCrossing, AsynchronousCrossing, RationalCrossing, ClockCrossingType} -import freechips.rocketchip.rocket.{PgLevels, RocketCoreParams, MulDivParams, DCacheParams, ICacheParams, BTBParams, DebugROBParams} +import freechips.rocketchip.rocket.{RocketCoreParams, MulDivParams, DCacheParams, ICacheParams, BTBParams, DebugROBParams} import freechips.rocketchip.tile.{ - XLen, MaxHartIdBits, RocketTileParams, BuildRoCC, AccumulatorExample, OpcodeSet, TranslatorExample, CharacterCountExample, BlackBoxExample + MaxHartIdBits, RocketTileParams, BuildRoCC, AccumulatorExample, OpcodeSet, TranslatorExample, CharacterCountExample, BlackBoxExample } class WithNBigCores( @@ -49,8 +49,6 @@ class WithNBigCores( )) } - - class WithNMedCores( n: Int, crossing: RocketCrossingParams = RocketCrossingParams(), @@ -118,10 +116,11 @@ class WithNSmallCores( }) class With1TinyCore extends Config((site, here, up) => { - case XLen => 32 case TilesLocated(InSubsystem) => { val tiny = RocketTileParams( core = RocketCoreParams( + xLen = 32, + pgLevels = 2, // sv32 useVM = false, fpu = None, mulDiv = Some(MulDivParams(mulUnroll = 8))), @@ -326,10 +325,11 @@ class WithRocketCacheRowBits(n: Int) extends Config((site, here, up) => { }) class WithRV32 extends Config((site, here, up) => { - case XLen => 32 case TilesLocated(location) => up(TilesLocated(location), site) map { case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( core = tp.tileParams.core.copy( + xLen = 32, + pgLevels = 2, // sv32 fpu = tp.tileParams.core.fpu.map(_.copy(fLen = 32)), mulDiv = Some(MulDivParams(mulUnroll = 8))))) case t => t @@ -411,7 +411,7 @@ class WithFastMulDiv extends Config((site, here, up) => { case TilesLocated(location) => up(TilesLocated(location), site) map { case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( core = tp.tileParams.core.copy(mulDiv = Some( - MulDivParams(mulUnroll = 8, mulEarlyOut = (site(XLen) > 32), divEarlyOut = true))))) + MulDivParams(mulUnroll = 8, mulEarlyOut = tp.tileParams.core.xLen > 32, divEarlyOut = true))))) case t => t } }) diff --git a/src/main/scala/tile/BaseTile.scala b/src/main/scala/tile/BaseTile.scala index 4520381887f..4e0c5d3b49d 100644 --- a/src/main/scala/tile/BaseTile.scala +++ b/src/main/scala/tile/BaseTile.scala @@ -12,7 +12,7 @@ import org.chipsalliance.diplomacy.bundlebridge._ import freechips.rocketchip.resources.{PropertyMap, PropertyOption, ResourceReference, DTSTimebase} import freechips.rocketchip.interrupts.{IntInwardNode, IntOutwardNode} -import freechips.rocketchip.rocket.{ICacheParams, DCacheParams, BTBParams, PgLevels, ASIdBits, VMIdBits, TraceAux, BPWatch} +import freechips.rocketchip.rocket.{ICacheParams, DCacheParams, BTBParams, ASIdBits, VMIdBits, TraceAux, BPWatch} import freechips.rocketchip.subsystem.{ HierarchicalElementParams, InstantiableHierarchicalElementParams, HierarchicalElementCrossingParamsLike, CacheBlockBytes, SystemBusKey, BaseHierarchicalElement, InsertTimingClosureRegistersOnHartIds, BaseHierarchicalElementModuleImp @@ -61,12 +61,12 @@ trait HasNonDiplomaticTileParameters { def usingPTW: Boolean = usingVM def usingDataScratchpad: Boolean = tileParams.dcache.flatMap(_.scratch).isDefined - def xLen: Int = p(XLen) + def xLen: Int = tileParams.core.xLen def xBytes: Int = xLen / 8 def iLen: Int = 32 def pgIdxBits: Int = 12 def pgLevelBits: Int = 10 - log2Ceil(xLen / 32) - def pgLevels: Int = p(PgLevels) + def pgLevels: Int = tileParams.core.pgLevels def maxSVAddrBits: Int = pgIdxBits + pgLevels * pgLevelBits def maxHypervisorExtraAddrBits: Int = 2 def hypervisorExtraAddrBits: Int = { @@ -128,7 +128,7 @@ trait HasNonDiplomaticTileParameters { tileParams.core.customIsaExt.map(Seq(_)) ).flatten val multiLetterString = multiLetterExt.mkString("_") - s"rv${p(XLen)}$ie$m$a$f$d$c$v$h$multiLetterString" + s"rv$xLen$ie$m$a$f$d$c$v$h$multiLetterString" } def tileProperties: PropertyMap = { diff --git a/src/main/scala/tile/BusErrorUnit.scala b/src/main/scala/tile/BusErrorUnit.scala index bbfe3fb3628..850550afb80 100644 --- a/src/main/scala/tile/BusErrorUnit.scala +++ b/src/main/scala/tile/BusErrorUnit.scala @@ -36,14 +36,14 @@ class L1BusErrors(implicit p: Parameters) extends CoreBundle()(p) with BusErrors case class BusErrorUnitParams(addr: BigInt, size: Int = 4096) -class BusErrorUnit[T <: BusErrors](t: => T, params: BusErrorUnitParams)(implicit p: Parameters) extends LazyModule { +class BusErrorUnit[T <: BusErrors](t: => T, params: BusErrorUnitParams, beatBytes: Int)(implicit p: Parameters) extends LazyModule { val regWidth = 64 val device = new SimpleDevice("bus-error-unit", Seq("sifive,buserror0")) val intNode = IntSourceNode(IntSourcePortSimple(resources = device.int)) val node = TLRegisterNode( address = Seq(AddressSet(params.addr, params.size-1)), device = device, - beatBytes = p(XLen)/8) + beatBytes = beatBytes) lazy val module = new Impl class Impl extends LazyModuleImp(this) { diff --git a/src/main/scala/tile/Core.scala b/src/main/scala/tile/Core.scala index 449af093b0c..e33ac109a8d 100644 --- a/src/main/scala/tile/Core.scala +++ b/src/main/scala/tile/Core.scala @@ -8,7 +8,6 @@ import org.chipsalliance.cde.config._ import freechips.rocketchip.rocket._ import freechips.rocketchip.util._ -case object XLen extends Field[Int] case object MaxHartIdBits extends Field[Int] // These parameters can be varied per-core @@ -51,6 +50,8 @@ trait CoreParams { val mtvecInit: Option[BigInt] val mtvecWritable: Boolean val traceHasWdata: Boolean + val xLen: Int + val pgLevels: Int def traceCustom: Option[Data] = None def customIsaExt: Option[String] = None def customCSRs(implicit p: Parameters): CustomCSRs = new CustomCSRs diff --git a/src/main/scala/tile/RocketTile.scala b/src/main/scala/tile/RocketTile.scala index 42cf9b644ed..619e7d836ca 100644 --- a/src/main/scala/tile/RocketTile.scala +++ b/src/main/scala/tile/RocketTile.scala @@ -77,7 +77,7 @@ class RocketTile private( dtim_adapter.foreach(lm => connectTLSlave(lm.node, lm.node.portParams.head.beatBytes)) val bus_error_unit = rocketParams.beuAddr map { a => - val beu = LazyModule(new BusErrorUnit(new L1BusErrors, BusErrorUnitParams(a))) + val beu = LazyModule(new BusErrorUnit(new L1BusErrors, BusErrorUnitParams(a), xLen/8)) intOutwardNode.get := beu.intNode connectTLSlave(beu.node, xBytes) beu From 50559ead7cbbe0ec5d11ec51f2b7929cdbc4cc32 Mon Sep 17 00:00:00 2001 From: Jerry Zhao Date: Sat, 29 Jun 2024 19:35:21 -0700 Subject: [PATCH 3/7] DRY out the RocketConfigs --- src/main/scala/subsystem/Configs.scala | 43 +- src/main/scala/subsystem/RocketConfigs.scala | 516 ++++--------------- 2 files changed, 147 insertions(+), 412 deletions(-) diff --git a/src/main/scala/subsystem/Configs.scala b/src/main/scala/subsystem/Configs.scala index cd9c7412690..76602a0c92c 100644 --- a/src/main/scala/subsystem/Configs.scala +++ b/src/main/scala/subsystem/Configs.scala @@ -20,7 +20,7 @@ import freechips.rocketchip.resources.{ DTSModel, DTSCompat, DTSTimebase, BigIntHexContext } import freechips.rocketchip.tile.{ - MaxHartIdBits, RocketTileParams + MaxHartIdBits, RocketTileParams, BuildRoCC, AccumulatorExample, OpcodeSet, TranslatorExample, CharacterCountExample, BlackBoxExample } import freechips.rocketchip.util.ClockGateModelFile import scala.reflect.ClassTag @@ -143,6 +143,47 @@ class WithBufferlessBroadcastHub extends Config((site, here, up) => { case BroadcastKey => up(BroadcastKey, site).copy(bufferless = true) }) +class TileAttachConfig[T <: CanAttachTile](f: T => T, locationOpt: Option[HierarchicalLocation])(implicit tag: ClassTag[T]) + extends Config((site, here, up) => locationOpt match { + case Some(loc) => { + case TilesLocated(`loc`) => up(TilesLocated(loc)) map { + case tp: T => f(tp) + case t => t + } + } + case None => { + case TilesLocated(loc) => up(TilesLocated(loc)) map { + case tp: T => f(tp) + case t => t + } + } + }) { + // The default constructor applies the modification to all locations + def this(f: T => T)(implicit tag: ClassTag[T]) = this(f, None) + // The atLocation method applies the modification to only the provided location + def atLocation(loc: HierarchicalLocation) = new TileAttachConfig(f, Some(loc)) +} + +class WithRoccExample extends Config((site, here, up) => { + case BuildRoCC => List( + (p: Parameters) => { + val accumulator = LazyModule(new AccumulatorExample(OpcodeSet.custom0, n = 4)(p)) + accumulator + }, + (p: Parameters) => { + val translator = LazyModule(new TranslatorExample(OpcodeSet.custom1)(p)) + translator + }, + (p: Parameters) => { + val counter = LazyModule(new CharacterCountExample(OpcodeSet.custom2)(p)) + counter + }, + (p: Parameters) => { + val blackbox = LazyModule(new BlackBoxExample(OpcodeSet.custom3, "RoccBlackBox")(p)) + blackbox + }) +}) + /** * WARNING!!! IGNORE AT YOUR OWN PERIL!!! * diff --git a/src/main/scala/subsystem/RocketConfigs.scala b/src/main/scala/subsystem/RocketConfigs.scala index 6919c014672..085ffa57e1b 100644 --- a/src/main/scala/subsystem/RocketConfigs.scala +++ b/src/main/scala/subsystem/RocketConfigs.scala @@ -8,9 +8,9 @@ import org.chipsalliance.diplomacy.lazymodule._ import freechips.rocketchip.prci.{SynchronousCrossing, AsynchronousCrossing, RationalCrossing, ClockCrossingType} import freechips.rocketchip.rocket.{RocketCoreParams, MulDivParams, DCacheParams, ICacheParams, BTBParams, DebugROBParams} -import freechips.rocketchip.tile.{ - MaxHartIdBits, RocketTileParams, BuildRoCC, AccumulatorExample, OpcodeSet, TranslatorExample, CharacterCountExample, BlackBoxExample -} +import freechips.rocketchip.tile.{RocketTileParams} +import scala.reflect.ClassTag + class WithNBigCores( n: Int, @@ -153,416 +153,110 @@ class With1TinyCore extends Config((site, here, up) => { case ClustersLocated(_) => Nil }) -// This is the number of icache sets for all Rocket tiles -class WithL1ICacheSets(sets: Int) extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - icache = tp.tileParams.icache.map(_.copy(nSets = sets)))) - case t => t - } -}) - -// This is the number of icache sets for all Rocket tiles -class WithL1DCacheSets(sets: Int) extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map(_.copy(nSets = sets)))) - case t => t - } -}) - -class WithL1ICacheWays(ways: Int) extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - icache = tp.tileParams.icache.map(_.copy(nWays = ways)))) - case t => t - } -}) - -class WithL1DCacheWays(ways: Int) extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map(_.copy(nWays = ways)))) - case t => t - } -}) - -class WithL1ICacheECC(dataECC: String, tagECC: String) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - icache = tp.tileParams.icache.map(_.copy(dataECC = Some(dataECC), tagECC = Some(tagECC))))) - case t => t - } -}) - -class WithL1DCacheECC(dataECC: String, tagECC: String) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map(_.copy(dataECC = Some(dataECC), tagECC = Some(tagECC), dataECCBytes=8)))) - case t => t - } -}) - -class WithL1ICacheTLBSets(tlbsets: Int) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - icache = tp.tileParams.icache.map(_.copy(nTLBSets = tlbsets)))) - case t => t - } -}) - -class WithL1DCacheTLBSets(tlbsets: Int) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map(_.copy(nTLBSets = tlbsets)))) - case t => t - } -}) - -class WithL1ICacheTLBWays(tlbways: Int) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - icache = tp.tileParams.icache.map(_.copy(nTLBWays = tlbways)))) - case t => t - } -}) - -class WithL1DCacheTLBWays(tlbways: Int) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map(_.copy(nTLBWays = tlbways)))) - case t => t - } -}) - -class WithL1ICacheTLBBasePageSectors(pagesectors: Int) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - icache = tp.tileParams.icache.map(_.copy(nTLBBasePageSectors = pagesectors)))) - case t => t - } -}) - -class WithL1DCacheTLBBasePageSectors(pagesectors: Int) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map(_.copy(nTLBBasePageSectors = pagesectors)))) - case t => t - } -}) - -class WithL1ICacheTLBSuperpages(superpages: Int) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - icache = tp.tileParams.icache.map(_.copy(nTLBSuperpages = superpages)))) - case t => t - } -}) - -class WithL1DCacheTLBSuperpages(superpages: Int) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map(_.copy(nTLBSuperpages = superpages)))) - case t => t - } -}) - -class WithRocketICacheRowBits(n: Int) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - icache = tp.tileParams.icache.map(_.copy(rowBits = n)))) - case t => t - } -}) - -class WithRocketDCacheRowBits(n: Int) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map(_.copy(rowBits = n)))) - case t => t - } -}) - -class WithL1ICacheBlockBytes(bytes: Int = 64) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - icache = tp.tileParams.icache.map(_.copy(blockBytes = bytes)))) - case t => t - } -}) - -class WithL1DCacheBlockBytes(bytes: Int = 64) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map(_.copy(blockBytes = bytes)))) - case t => t - } -}) - -class WithoutVM extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(useVM = false))) - case t => t - } -}) +class RocketTileAttachConfig(f: RocketTileAttachParams => RocketTileAttachParams) extends TileAttachConfig[RocketTileAttachParams](f) + +class RocketTileConfig(f: RocketTileParams => RocketTileParams) extends RocketTileAttachConfig(tp => tp.copy( + tileParams = f(tp.tileParams) +)) + +class RocketCrossingConfig(f: RocketCrossingParams => RocketCrossingParams) extends RocketTileAttachConfig(tp => tp.copy( + crossingParams = f(tp.crossingParams) +)) + +class RocketCoreConfig(f: RocketCoreParams => RocketCoreParams) extends RocketTileConfig(tp => tp.copy( + core = f(tp.core) +)) + +class RocketICacheConfig(f: ICacheParams => ICacheParams) extends RocketTileConfig(tp => tp.copy( + icache = tp.icache.map(ic => f(ic)) +)) + +class RocketDCacheConfig(f: DCacheParams => DCacheParams) extends RocketTileConfig(tp => tp.copy( + dcache = tp.dcache.map(dc => f(dc)) +)) + +class WithL1ICacheSets(sets: Int) extends RocketICacheConfig(_.copy(nSets=sets)) +class WithL1ICacheWays(ways: Int) extends RocketICacheConfig(_.copy(nWays=ways)) +class WithL1ICacheECC(dataECC: String, tagECC: String) extends RocketICacheConfig(_.copy(dataECC = Some(dataECC), tagECC = Some(tagECC))) +class WithL1ICacheRowBits(n: Int) extends RocketICacheConfig(_.copy(rowBits = n)) +class WithL1ICacheTLBSets(sets: Int) extends RocketICacheConfig(_.copy(nTLBSets = sets)) +class WithL1ICacheTLBWays(ways: Int) extends RocketICacheConfig(_.copy(nTLBWays = ways)) +class WithL1ICacheTLBBasePageSectors(sectors: Int) extends RocketICacheConfig(_.copy(nTLBBasePageSectors = sectors)) +class WithL1ICacheTLBSuperpages(superpages: Int) extends RocketICacheConfig(_.copy(nTLBSuperpages = superpages)) +class WithL1ICacheBlockBytes(bytes: Int = 64) extends RocketICacheConfig(_.copy(blockBytes = bytes)) + +class WithL1DCacheSets(sets: Int) extends RocketDCacheConfig(_.copy(nSets=sets)) +class WithL1DCacheWays(ways: Int) extends RocketDCacheConfig(_.copy(nWays=ways)) +class WithL1DCacheECC(dataECC: String, tagECC: String) extends RocketDCacheConfig(_.copy(dataECC = Some(dataECC), tagECC = Some(tagECC))) +class WithL1DCacheRowBits(n: Int) extends RocketDCacheConfig(_.copy(rowBits = n)) +class WithL1DCacheTLBSets(sets: Int) extends RocketDCacheConfig(_.copy(nTLBSets = sets)) +class WithL1DCacheTLBWays(ways: Int) extends RocketDCacheConfig(_.copy(nTLBWays = ways)) +class WithL1DCacheTLBBasePageSectors(sectors: Int) extends RocketDCacheConfig(_.copy(nTLBBasePageSectors = sectors)) +class WithL1DCacheTLBSuperpages(superpages: Int) extends RocketDCacheConfig(_.copy(nTLBSuperpages = superpages)) +class WithL1DCacheBlockBytes(bytes: Int = 64) extends RocketDCacheConfig(_.copy(blockBytes = bytes)) +class WithL1DCacheNonblocking(nMSHRs: Int) extends RocketDCacheConfig(_.copy(nMSHRs = nMSHRs)) +class WithL1DCacheClockGating extends RocketDCacheConfig(_.copy(clockGate = true)) +class WithL1DCacheDTIMAddress(address: BigInt) extends RocketDCacheConfig(_.copy(scratch = Some(address))) + +class WithScratchpadsOnly extends RocketTileConfig(tp => tp.copy( + core = tp.core.copy(useVM = false), + dcache = tp.dcache.map(_.copy( + nSets = 256, // 16Kb scratchpad + nWays = 1, + scratch = Some(0x80000000L))) +)) + +class WithCacheRowBits(n: Int) extends RocketTileConfig(tp => tp.copy( + dcache = tp.dcache.map(_.copy(rowBits = n)), + icache = tp.icache.map(_.copy(rowBits = n)) +)) + +class WithBEU(addr: BigInt) extends RocketTileConfig(_.copy(beuAddr = Some(addr))) + +class WithRV32 extends RocketCoreConfig(c => c.copy( + xLen =32, + pgLevels = 2, // sv32 + fpu = c.fpu.map(_.copy(fLen = 32)), + mulDiv = Some(MulDivParams(mulUnroll = 8)) +)) + +class WithoutVM extends RocketCoreConfig(_.copy(useVM = false)) +class WithCFlushEnabled extends RocketCoreConfig(_.copy(haveCFlush = true)) +class WithNBreakpoints(hwbp: Int) extends RocketCoreConfig(_.copy(nBreakpoints = hwbp)) +class WithHypervisor(hext: Boolean = true) extends RocketCoreConfig(_.copy(useHypervisor = hext)) +class WithCease(enable: Boolean = true) extends RocketCoreConfig(_.copy(haveCease = enable)) +class WithCoreClockGatingEnabled extends RocketCoreConfig(_.copy(clockGate = true)) + +// Simulation-only configs +class WithNoSimulationTimeout extends RocketCoreConfig(_.copy(haveSimTimeout = false)) +class WithDebugROB(enable: Boolean = true, size: Int = 0) extends RocketCoreConfig(_.copy(debugROB = Option.when(enable)(DebugROBParams(size)))) + +// FPU configs +class WithoutFPU extends RocketCoreConfig(_.copy(fpu = None)) +class WithFP16 extends RocketCoreConfig(c => c.copy(fpu = c.fpu.map(_.copy(minFLen = 16)))) +class WithFPUWithoutDivSqrt extends RocketCoreConfig(c => c.copy(fpu = c.fpu.map(_.copy(divSqrt = false)))) + +// mul-div configs +class WithFastMulDiv extends RocketCoreConfig(c => c.copy(mulDiv = Some( + MulDivParams(mulUnroll = 8, mulEarlyOut = c.xLen > 32, divEarlyOut = true) +))) +class WithCustomFastMulDiv(mUnroll: Int = 8, mEarlyOut: Boolean = true, dUnroll: Int = 1, dEarlyOut: Boolean = true, dEarlyOutGranularity: Int = 1) extends RocketCoreConfig(_.copy(mulDiv = Some( + MulDivParams(mulUnroll = mUnroll, mulEarlyOut = mEarlyOut, divUnroll = dUnroll, divEarlyOut = dEarlyOut, divEarlyOutGranularity = dEarlyOutGranularity) +))) +class WithoutMulDiv extends RocketCoreConfig(_.copy(mulDiv = None)) + +// Branch-prediction configs +class WithDefaultBtb extends RocketTileConfig(t => t.copy(btb = Some(BTBParams()))) +class WithNoBtb extends RocketTileConfig(_.copy(btb = None)) + +// Tile CDC configs +class WithCDC(crossingType: ClockCrossingType = SynchronousCrossing()) extends RocketCrossingConfig(_.copy(crossingType = crossingType)) +class WithSeperateClockReset extends RocketCrossingConfig(_.copy(forceSeparateClockReset = true)) +class WithSynchronousCDCs extends WithCDC(SynchronousCrossing()) +class WithAsynchronouCDCs(depth: Int, sync: Int) extends WithCDC(AsynchronousCrossing(depth, sync)) +class WithRationalCDCs extends WithCDC(RationalCrossing()) -class WithCFlushEnabled extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(haveCFlush = true))) - case t => t - } -}) - -class WithRocketCacheRowBits(n: Int) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map(_.copy(rowBits = n)), - icache = tp.tileParams.icache.map(_.copy(rowBits = n)))) - case t => t - } -}) -class WithRV32 extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy( - xLen = 32, - pgLevels = 2, // sv32 - fpu = tp.tileParams.core.fpu.map(_.copy(fLen = 32)), - mulDiv = Some(MulDivParams(mulUnroll = 8))))) - case t => t - } -}) - -class WithFP16 extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy( - fpu = tp.tileParams.core.fpu.map(_.copy(minFLen = 16)) - ) - )) - case t => t - } -}) - -class WithNonblockingL1(nMSHRs: Int) extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map(_.copy(nMSHRs = nMSHRs)))) - case t => t - } -}) - -class WithNBreakpoints(hwbp: Int) extends Config ((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(nBreakpoints = hwbp))) - case t => t - } -}) - -class WithHypervisor(hext: Boolean = true) extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(useHypervisor = hext))) - case t => t - } -}) - -class WithRoccExample extends Config((site, here, up) => { - case BuildRoCC => List( - (p: Parameters) => { - val accumulator = LazyModule(new AccumulatorExample(OpcodeSet.custom0, n = 4)(p)) - accumulator - }, - (p: Parameters) => { - val translator = LazyModule(new TranslatorExample(OpcodeSet.custom1)(p)) - translator - }, - (p: Parameters) => { - val counter = LazyModule(new CharacterCountExample(OpcodeSet.custom2)(p)) - counter - }, - (p: Parameters) => { - val blackbox = LazyModule(new BlackBoxExample(OpcodeSet.custom3, "RoccBlackBox")(p)) - blackbox - }) -}) - -class WithDefaultBtb extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - btb = Some(BTBParams()))) - case t => t - } -}) - -class WithNoBtb extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - btb = None)) - case t => t - } -}) - -class WithFastMulDiv extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(mulDiv = Some( - MulDivParams(mulUnroll = 8, mulEarlyOut = tp.tileParams.core.xLen > 32, divEarlyOut = true))))) - case t => t - } -}) - -class WithCustomFastMulDiv(mUnroll: Int = 8, mEarlyOut: Boolean = true, dUnroll: Int = 1, dEarlyOut: Boolean = true, dEarlyOutGranularity: Int = 1) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(mulDiv = Some( - MulDivParams(mulUnroll = mUnroll, mulEarlyOut = mEarlyOut, divUnroll = dUnroll, divEarlyOut = dEarlyOut, divEarlyOutGranularity = dEarlyOutGranularity))))) - case t => t - } -}) - -class WithoutMulDiv extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(mulDiv = None))) - case t => t - } -}) - -class WithoutFPU extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(fpu = None))) - case t => t - } -}) - -class WithFPUWithoutDivSqrt extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(fpu = tp.tileParams.core.fpu.map(_.copy(divSqrt = false))))) - case t => t - } -}) - -class WithBEU(addr: BigInt) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy(beuAddr = Some(addr))) - case t => t - } -}) - -class WithRocketTileCDC(crossingType: ClockCrossingType = SynchronousCrossing()) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(crossingParams = tp.crossingParams.copy( - crossingType = crossingType - )) - case other => other - } -}) - -class WithSeperateClockReset extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(crossingParams = tp.crossingParams.copy( - forceSeparateClockReset = true - )) - case other => other - } -}) - - -class WithRocketDebugROB(enable: Boolean = true, size: Int = 0) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams if (enable) => - tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(debugROB = Some(DebugROBParams(size))) - )) - } -}) - -class WithRocketCease(enable: Boolean = true) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(haveCease = enable) - )) - } -}) - -class WithCoreClockGatingEnabled extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(clockGate = true) - )) - case t => t - } -}) - -class WithDCacheClockGatingEnabled extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map(_.copy(clockGate = true)))) - case t => t - } -}) - -class WithNoSimulationTimeout extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(haveSimTimeout = false))) - case t => t - } -}) - -class WithSynchronousRocketTiles extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(crossingParams = tp.crossingParams.copy( - crossingType = SynchronousCrossing())) - case t => t - } -}) - -class WithAsynchronousRocketTiles(depth: Int, sync: Int) extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(crossingParams = tp.crossingParams.copy( - crossingType = AsynchronousCrossing())) - case t => t - } -}) - -class WithRationalRocketTiles extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(crossingParams = tp.crossingParams.copy( - crossingType = RationalCrossing())) - case t => t - } -}) - -class WithScratchpadsBaseAddress(address: BigInt) extends Config((site, here, up) => { - case TilesLocated(InSubsystem) => up(TilesLocated(InSubsystem), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - dcache = tp.tileParams.dcache.map( - _.copy(scratch = Some(address)) - ) - )) - case t => t - } -}) - -class WithScratchpadsOnly extends Config((site, here, up) => { - case TilesLocated(location) => up(TilesLocated(location), site) map { - case tp: RocketTileAttachParams => tp.copy(tileParams = tp.tileParams.copy( - core = tp.tileParams.core.copy(useVM = false), - dcache = tp.tileParams.dcache.map(_.copy( - nSets = 256, // 16Kb scratchpad - nWays = 1, - scratch = Some(0x80000000L))))) - case t => t - } -}) class WithCloneRocketTiles( n: Int = 1, From c558393280802dd5eb245dba9b74aa14cd0a0433 Mon Sep 17 00:00:00 2001 From: Jerry Zhao Date: Sat, 29 Jun 2024 19:41:12 -0700 Subject: [PATCH 4/7] Move RocketConfigs to rocket.Configs --- .../{subsystem/RocketConfigs.scala => rocket/Configs.scala} | 5 ++--- src/main/scala/system/Configs.scala | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) rename src/main/scala/{subsystem/RocketConfigs.scala => rocket/Configs.scala} (96%) diff --git a/src/main/scala/subsystem/RocketConfigs.scala b/src/main/scala/rocket/Configs.scala similarity index 96% rename from src/main/scala/subsystem/RocketConfigs.scala rename to src/main/scala/rocket/Configs.scala index 085ffa57e1b..4d6d204c8e8 100644 --- a/src/main/scala/subsystem/RocketConfigs.scala +++ b/src/main/scala/rocket/Configs.scala @@ -1,5 +1,4 @@ -package freechips.rocketchip.subsystem -// TODO move to freechips.rocketchip.rocket +package freechips.rocketchip.rocket import chisel3.util._ @@ -7,7 +6,7 @@ import org.chipsalliance.cde.config._ import org.chipsalliance.diplomacy.lazymodule._ import freechips.rocketchip.prci.{SynchronousCrossing, AsynchronousCrossing, RationalCrossing, ClockCrossingType} -import freechips.rocketchip.rocket.{RocketCoreParams, MulDivParams, DCacheParams, ICacheParams, BTBParams, DebugROBParams} +import freechips.rocketchip.subsystem.{TilesLocated, NumTiles, HierarchicalLocation, RocketCrossingParams, SystemBusKey, CacheBlockBytes, RocketTileAttachParams, InSubsystem, InCluster, HierarchicalElementMasterPortParams, HierarchicalElementSlavePortParams, CBUS, CCBUS, ClustersLocated, TileAttachConfig, CloneTileAttachParams} import freechips.rocketchip.tile.{RocketTileParams} import scala.reflect.ClassTag diff --git a/src/main/scala/system/Configs.scala b/src/main/scala/system/Configs.scala index 9827cf428c0..a78712c91ad 100644 --- a/src/main/scala/system/Configs.scala +++ b/src/main/scala/system/Configs.scala @@ -5,6 +5,7 @@ package freechips.rocketchip.system import org.chipsalliance.cde.config.Config import freechips.rocketchip.subsystem._ +import freechips.rocketchip.rocket.{WithNBigCores, WithNMedCores, WithNSmallCores, WithRV32, WithFP16, WithHypervisor, With1TinyCore, WithScratchpadsOnly, WithCloneRocketTiles} class WithJtagDTMSystem extends freechips.rocketchip.subsystem.WithJtagDTM class WithDebugSBASystem extends freechips.rocketchip.subsystem.WithDebugSBA From e3da6bdf464252a384bfb10bc35918720abcf86d Mon Sep 17 00:00:00 2001 From: Jerry Zhao Date: Sat, 29 Jun 2024 21:04:11 -0700 Subject: [PATCH 5/7] Clean up and add some Rocket configs --- src/main/scala/rocket/Configs.scala | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/scala/rocket/Configs.scala b/src/main/scala/rocket/Configs.scala index 4d6d204c8e8..1e2cc94c655 100644 --- a/src/main/scala/rocket/Configs.scala +++ b/src/main/scala/rocket/Configs.scala @@ -7,7 +7,7 @@ import org.chipsalliance.diplomacy.lazymodule._ import freechips.rocketchip.prci.{SynchronousCrossing, AsynchronousCrossing, RationalCrossing, ClockCrossingType} import freechips.rocketchip.subsystem.{TilesLocated, NumTiles, HierarchicalLocation, RocketCrossingParams, SystemBusKey, CacheBlockBytes, RocketTileAttachParams, InSubsystem, InCluster, HierarchicalElementMasterPortParams, HierarchicalElementSlavePortParams, CBUS, CCBUS, ClustersLocated, TileAttachConfig, CloneTileAttachParams} -import freechips.rocketchip.tile.{RocketTileParams} +import freechips.rocketchip.tile.{RocketTileParams, RocketTileBoundaryBufferParams} import scala.reflect.ClassTag @@ -211,9 +211,10 @@ class WithCacheRowBits(n: Int) extends RocketTileConfig(tp => tp.copy( )) class WithBEU(addr: BigInt) extends RocketTileConfig(_.copy(beuAddr = Some(addr))) +class WithBoundaryBuffers(buffers: Option[RocketTileBoundaryBufferParams] = Some(RocketTileBoundaryBufferParams(true))) extends RocketTileConfig(_.copy(boundaryBuffers = buffers)) class WithRV32 extends RocketCoreConfig(c => c.copy( - xLen =32, + xLen = 32, pgLevels = 2, // sv32 fpu = c.fpu.map(_.copy(fLen = 32)), mulDiv = Some(MulDivParams(mulUnroll = 8)) @@ -225,6 +226,9 @@ class WithNBreakpoints(hwbp: Int) extends RocketCoreConf class WithHypervisor(hext: Boolean = true) extends RocketCoreConfig(_.copy(useHypervisor = hext)) class WithCease(enable: Boolean = true) extends RocketCoreConfig(_.copy(haveCease = enable)) class WithCoreClockGatingEnabled extends RocketCoreConfig(_.copy(clockGate = true)) +class WithPgLevels(n: Int) extends RocketCoreConfig(_.copy(pgLevels = n)) +class WithSV48 extends WithPgLevels(4) +class WithSV39 extends WithPgLevels(3) // Simulation-only configs class WithNoSimulationTimeout extends RocketCoreConfig(_.copy(haveSimTimeout = false)) @@ -252,7 +256,7 @@ class WithNoBtb extends RocketTileConfig(_.copy(btb = None)) class WithCDC(crossingType: ClockCrossingType = SynchronousCrossing()) extends RocketCrossingConfig(_.copy(crossingType = crossingType)) class WithSeperateClockReset extends RocketCrossingConfig(_.copy(forceSeparateClockReset = true)) class WithSynchronousCDCs extends WithCDC(SynchronousCrossing()) -class WithAsynchronouCDCs(depth: Int, sync: Int) extends WithCDC(AsynchronousCrossing(depth, sync)) +class WithAsynchronousCDCs(depth: Int, sync: Int) extends WithCDC(AsynchronousCrossing(depth, sync)) class WithRationalCDCs extends WithCDC(RationalCrossing()) From 93cef4edfe8d940e3dbd06d90541f3c4645c11fc Mon Sep 17 00:00:00 2001 From: Jerry Zhao Date: Sat, 29 Jun 2024 21:04:18 -0700 Subject: [PATCH 6/7] Add pgLevels check to Tile --- src/main/scala/rocket/RocketCore.scala | 2 +- src/main/scala/subsystem/Configs.scala | 14 +++++++------- src/main/scala/tile/Core.scala | 8 ++++++++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main/scala/rocket/RocketCore.scala b/src/main/scala/rocket/RocketCore.scala index d82f3175108..605a5fd12b3 100644 --- a/src/main/scala/rocket/RocketCore.scala +++ b/src/main/scala/rocket/RocketCore.scala @@ -14,7 +14,7 @@ import scala.collection.mutable.ArrayBuffer case class RocketCoreParams( xLen: Int = 64, - pgLevels: Int = 32, // sv39 default + pgLevels: Int = 3, // sv39 default bootFreqHz: BigInt = 0, useVM: Boolean = true, useUser: Boolean = false, diff --git a/src/main/scala/subsystem/Configs.scala b/src/main/scala/subsystem/Configs.scala index 76602a0c92c..399973bbed0 100644 --- a/src/main/scala/subsystem/Configs.scala +++ b/src/main/scala/subsystem/Configs.scala @@ -35,28 +35,28 @@ class BaseSubsystemConfig extends Config ((site, here, up) => { .map(_.tileParams.tileId) :+ 0).max+1) // Interconnect parameters case SystemBusKey => SystemBusParams( - beatBytes = site(MaxXLen)/8, + beatBytes = 8, blockBytes = site(CacheBlockBytes)) case ControlBusKey => PeripheryBusParams( - beatBytes = site(MaxXLen)/8, + beatBytes = 8, blockBytes = site(CacheBlockBytes), dtsFrequency = Some(100000000), // Default to 100 MHz cbus clock errorDevice = Some(BuiltInErrorDeviceParams( - errorParams = DevNullParams(List(AddressSet(0x3000, 0xfff)), maxAtomic=site(MaxXLen)/8, maxTransfer=4096)))) + errorParams = DevNullParams(List(AddressSet(0x3000, 0xfff)), maxAtomic=8, maxTransfer=4096)))) case PeripheryBusKey => PeripheryBusParams( - beatBytes = site(MaxXLen)/8, + beatBytes = 8, blockBytes = site(CacheBlockBytes), dtsFrequency = Some(100000000)) // Default to 100 MHz pbus clock case MemoryBusKey => MemoryBusParams( - beatBytes = site(MaxXLen)/8, + beatBytes = 8, blockBytes = site(CacheBlockBytes)) case FrontBusKey => FrontBusParams( - beatBytes = site(MaxXLen)/8, + beatBytes = 8, blockBytes = site(CacheBlockBytes)) // Additional device Parameters case BootROMLocated(InSubsystem) => Some(BootROMParams(contentFileName = "./bootrom/bootrom.img")) case HasTilesExternalResetVectorKey => false - case DebugModuleKey => Some(DefaultDebugModuleParams(site(MaxXLen))) + case DebugModuleKey => Some(DefaultDebugModuleParams(64)) case CLINTKey => Some(CLINTParams()) case PLICKey => Some(PLICParams()) case TilesLocated(InSubsystem) => Nil diff --git a/src/main/scala/tile/Core.scala b/src/main/scala/tile/Core.scala index e33ac109a8d..603eba21523 100644 --- a/src/main/scala/tile/Core.scala +++ b/src/main/scala/tile/Core.scala @@ -121,6 +121,14 @@ trait HasCoreParameters extends HasTileParameters { require(vfLen <= eLen) } + if (coreParams.useVM) { + if (coreParams.xLen == 32) { + require(coreParams.pgLevels == 2) + } else { + require(coreParams.pgLevels >= 3) + } + } + lazy val hartIdLen: Int = p(MaxHartIdBits) lazy val resetVectorLen: Int = { val externalLen = paddrBits From 0464c212711f41805e7b2c01f0288e0745859e88 Mon Sep 17 00:00:00 2001 From: Jerry Zhao Date: Sun, 30 Jun 2024 14:12:50 -0700 Subject: [PATCH 7/7] Clean up TileAttachConfig | add atTileIds method --- src/main/scala/subsystem/Configs.scala | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/main/scala/subsystem/Configs.scala b/src/main/scala/subsystem/Configs.scala index 399973bbed0..37001b39fd3 100644 --- a/src/main/scala/subsystem/Configs.scala +++ b/src/main/scala/subsystem/Configs.scala @@ -143,25 +143,21 @@ class WithBufferlessBroadcastHub extends Config((site, here, up) => { case BroadcastKey => up(BroadcastKey, site).copy(bufferless = true) }) -class TileAttachConfig[T <: CanAttachTile](f: T => T, locationOpt: Option[HierarchicalLocation])(implicit tag: ClassTag[T]) - extends Config((site, here, up) => locationOpt match { - case Some(loc) => { - case TilesLocated(`loc`) => up(TilesLocated(loc)) map { - case tp: T => f(tp) - case t => t - } - } - case None => { - case TilesLocated(loc) => up(TilesLocated(loc)) map { - case tp: T => f(tp) - case t => t - } +class TileAttachConfig[T <: CanAttachTile](f: T => T, locationOpt: Option[HierarchicalLocation], tileIdOpt: Seq[Int])(implicit tag: ClassTag[T]) + extends Config((site, here, up) => { + val partialFn: PartialFunction[CanAttachTile, CanAttachTile] = { case tp: T => if (tileIdOpt.contains(tp.tileParams.tileId) || tileIdOpt.isEmpty) f(tp) else tp } + val alterFn: CanAttachTile => CanAttachTile = x => partialFn.applyOrElse(x, identity[CanAttachTile]) + locationOpt match { + case Some(loc) => { case TilesLocated(`loc`) => up(TilesLocated(loc)) map { alterFn(_) } } + case None => { case TilesLocated(loc) => up(TilesLocated(loc)) map { alterFn(_) } } } }) { // The default constructor applies the modification to all locations - def this(f: T => T)(implicit tag: ClassTag[T]) = this(f, None) + def this(f: T => T)(implicit tag: ClassTag[T]) = this(f, None, Nil) // The atLocation method applies the modification to only the provided location - def atLocation(loc: HierarchicalLocation) = new TileAttachConfig(f, Some(loc)) + def atLocation(loc: HierarchicalLocation) = new TileAttachConfig(f, Some(loc), tileIdOpt) + // The atTileIds method applies the modification only to specified tileIds + def atTileIds(ids: Int*) = new TileAttachConfig(f, locationOpt, tileIdOpt ++ ids) } class WithRoccExample extends Config((site, here, up) => {