1
0

Configs: use a uniform syntax without Match exceptions (#507)

* Configs: use a uniform syntax without Match exceptions

The old style of specifying Configs used total functions.  The only way to
indicate that a key was not matched was to throw an exception.  Not only was
this a performance concern, but it also caused confusing error messages
whenever you had a match failure from a lookup within a lookup.  The
exception could get handled by an outer-lookup that then reported the wrong
key as missing.
This commit is contained in:
Wesley W. Terpstra 2017-01-13 14:41:19 -08:00 committed by Henry Cook
parent b448387899
commit 52bb6cd9d9
5 changed files with 405 additions and 549 deletions

View File

@ -3,9 +3,6 @@
package config package config
class Field[T] class Field[T]
class CDEMatchError() extends Exception {
override def fillInStackTrace() = this
}
abstract class View { abstract class View {
final def apply[T](pname: Field[T]): T = apply(pname, this) final def apply[T](pname: Field[T]): T = apply(pname, this)
@ -16,10 +13,8 @@ abstract class View {
abstract class Parameters extends View { abstract class Parameters extends View {
final def ++ (x: Parameters): Parameters = new ChainParameters(this, x) final def ++ (x: Parameters): Parameters = new ChainParameters(this, x)
final def alter(f: (Any, View, View, View) => Any): Parameters = Parameters(f) ++ this final def alter(f: (View, View, View) => PartialFunction[Any,Any]): Parameters = Parameters(f) ++ this
final def alter(m: Map[Any,Any]): Parameters = Parameters(m) ++ this final def alterPartial(f: PartialFunction[Any,Any]): Parameters = Parameters((_,_,_) => f) ++ this
final def alter(f: PartialFunction[Any,Any]): Parameters = Parameters(f) ++ this
final def alterPartial(f: PartialFunction[Any,Any]): Parameters = Parameters(f) ++ this
protected[config] def chain(site: View, tail: View, pname: Any): Any protected[config] def chain(site: View, tail: View, pname: Any): Any
protected[config] def find(pname: Any, site: View) = chain(site, new TerminalView, pname) protected[config] def find(pname: Any, site: View) = chain(site, new TerminalView, pname)
@ -27,26 +22,18 @@ abstract class Parameters extends View {
object Parameters { object Parameters {
def empty: Parameters = new EmptyParameters def empty: Parameters = new EmptyParameters
def apply(f: (Any, View, View, View) => Any): Parameters = new FunctionParameters(f) def apply(f: (View, View, View) => PartialFunction[Any,Any]): Parameters = new PartialParameters(f)
def apply(m: Map[Any,Any]): Parameters = new MapParameters(m)
def apply(f: PartialFunction[Any,Any]): Parameters = new PartialParameters(f)
def partial(f: PartialFunction[Any,Any]): Parameters = new PartialParameters(f)
def root(p: Parameters) = p def root(p: Parameters) = p
} }
class Config(p: Parameters) extends Parameters { class Config(p: Parameters) extends Parameters {
def this(f: (Any, View, View) => Any) = this(Parameters((p,s,h,u) => f(p,s,h))) // backwards compat; don't use def this(f: (View, View, View) => PartialFunction[Any,Any]) = this(Parameters(f))
def this(f: (Any, View, View, View) => Any) = this(Parameters(f))
def this(m: Map[Any,Any]) = this(Parameters(m))
def this(f: PartialFunction[Any,Any]) = this(Parameters(f))
protected[config] def chain(site: View, tail: View, pname: Any) = p.chain(site, tail, pname) protected[config] def chain(site: View, tail: View, pname: Any) = p.chain(site, tail, pname)
override def toString = this.getClass.getSimpleName override def toString = this.getClass.getSimpleName
def toInstance = this def toInstance = this
} }
class ConfigPartial(f: PartialFunction[Any,Any]) extends Config(Parameters(f))
// Internal implementation: // Internal implementation:
private class TerminalView extends View { private class TerminalView extends View {
@ -66,22 +53,9 @@ private class EmptyParameters extends Parameters {
def chain(site: View, tail: View, pname: Any) = tail.find(pname, site) def chain(site: View, tail: View, pname: Any) = tail.find(pname, site)
} }
private class FunctionParameters(f: (Any, View, View, View) => Any) extends Parameters { private class PartialParameters(f: (View, View, View) => PartialFunction[Any,Any]) extends Parameters {
protected[config] def chain(site: View, tail: View, pname: Any) = { protected[config] def chain(site: View, tail: View, pname: Any) = {
try f(pname, site, this, tail) val g = f(site, this, tail)
catch { if (g.isDefinedAt(pname)) g.apply(pname) else tail.find(pname, site)
case e: CDEMatchError => tail.find(pname, site)
case e: scala.MatchError => tail.find(pname, site)
} }
} }
}
private class MapParameters(map: Map[Any, Any]) extends Parameters {
protected[config] def chain(site: View, tail: View, pname: Any) =
map.get(pname).getOrElse(find(pname, site))
}
private class PartialParameters(f: PartialFunction[Any,Any]) extends Parameters {
protected[config] def chain(site: View, tail: View, pname: Any) =
if (f.isDefinedAt(pname)) f.apply(pname) else tail.find(pname, site)
}

View File

@ -17,11 +17,7 @@ import uncore.converters._
import uncore.util._ import uncore.util._
import util._ import util._
class BaseCoreplexConfig extends Config ( class BaseCoreplexConfig extends Config ((site, here, up) => {
{ (pname,site,here) =>
lazy val innerDataBits = site(XLen)
lazy val innerDataBeats = (8 * site(CacheBlockBytes)) / innerDataBits
pname match {
//Memory Parameters //Memory Parameters
case PAddrBits => 32 case PAddrBits => 32
case PgLevels => if (site(XLen) == 64) 3 /* Sv39 */ else 2 /* Sv32 */ case PgLevels => if (site(XLen) == 64) 3 /* Sv39 */ else 2 /* Sv32 */
@ -101,7 +97,7 @@ class BaseCoreplexConfig extends Config (
if (site(BuildRoCC).isEmpty) 1 else site(RoccMaxTaggedMemXacts)).max, if (site(BuildRoCC).isEmpty) 1 else site(RoccMaxTaggedMemXacts)).max,
maxClientsPerPort = if (site(BuildRoCC).isEmpty) 1 else 2, maxClientsPerPort = if (site(BuildRoCC).isEmpty) 1 else 2,
maxManagerXacts = site(NAcquireTransactors) + 2, maxManagerXacts = site(NAcquireTransactors) + 2,
dataBeats = innerDataBeats, dataBeats = (8 * site(CacheBlockBytes)) / site(XLen),
dataBits = site(CacheBlockBytes)*8) dataBits = site(CacheBlockBytes)*8)
} }
case BootROMFile => "./bootrom/bootrom.img" case BootROMFile => "./bootrom/bootrom.img"
@ -111,71 +107,49 @@ class BaseCoreplexConfig extends Config (
case CacheBlockBytes => 64 case CacheBlockBytes => 64
case CacheBlockOffsetBits => log2Up(site(CacheBlockBytes)) case CacheBlockOffsetBits => log2Up(site(CacheBlockBytes))
case EnableL2Logging => false case EnableL2Logging => false
case _ => throw new CDEMatchError })
}
}
)
class WithNCores(n: Int) extends Config( class WithNCores(n: Int) extends Config((site, here, up) => {
(pname,site,here) => pname match {
case NTiles => n case NTiles => n
case _ => throw new CDEMatchError
}) })
class WithNBanksPerMemChannel(n: Int) extends Config( class WithNBanksPerMemChannel(n: Int) extends Config((site, here, up) => {
(pname, site, here, up) => pname match {
case BankedL2Config => up(BankedL2Config, site).copy(nBanksPerChannel = n) case BankedL2Config => up(BankedL2Config, site).copy(nBanksPerChannel = n)
case _ => throw new CDEMatchError
}) })
class WithNTrackersPerBank(n: Int) extends Config( class WithNTrackersPerBank(n: Int) extends Config((site, here, up) => {
(pname, site, here, up) => pname match {
case BroadcastConfig => up(BroadcastConfig, site).copy(nTrackers = n) case BroadcastConfig => up(BroadcastConfig, site).copy(nTrackers = n)
case _ => throw new CDEMatchError
}) })
// This is the number of sets **per way** // This is the number of sets **per way**
class WithL1ICacheSets(sets: Int) extends Config( class WithL1ICacheSets(sets: Int) extends Config((site, here, up) => {
(pname, site, here, up) => pname match {
case CacheName("L1I") => up(CacheName("L1I"), site).copy(nSets = sets) case CacheName("L1I") => up(CacheName("L1I"), site).copy(nSets = sets)
case _ => throw new CDEMatchError
}) })
// This is the number of sets **per way** // This is the number of sets **per way**
class WithL1DCacheSets(sets: Int) extends Config( class WithL1DCacheSets(sets: Int) extends Config((site, here, up) => {
(pname, site, here, up) => pname match {
case CacheName("L1D") => up(CacheName("L1D"), site).copy(nSets = sets) case CacheName("L1D") => up(CacheName("L1D"), site).copy(nSets = sets)
case _ => throw new CDEMatchError
}) })
class WithL1ICacheWays(ways: Int) extends Config( class WithL1ICacheWays(ways: Int) extends Config((site, here, up) => {
(pname, site, here, up) => pname match {
case CacheName("L1I") => up(CacheName("L1I"), site).copy(nWays = ways) case CacheName("L1I") => up(CacheName("L1I"), site).copy(nWays = ways)
case _ => throw new CDEMatchError
}) })
class WithL1DCacheWays(ways: Int) extends Config( class WithL1DCacheWays(ways: Int) extends Config((site, here, up) => {
(pname, site, here, up) => pname match {
case CacheName("L1D") => up(CacheName("L1D"), site).copy(nWays = ways) case CacheName("L1D") => up(CacheName("L1D"), site).copy(nWays = ways)
case _ => throw new CDEMatchError
}) })
class WithCacheBlockBytes(linesize: Int) extends Config( class WithCacheBlockBytes(linesize: Int) extends Config((site, here, up) => {
(pname,site,here) => pname match {
case CacheBlockBytes => linesize case CacheBlockBytes => linesize
case _ => throw new CDEMatchError
}) })
class WithDataScratchpad(n: Int) extends Config( class WithDataScratchpad(n: Int) extends Config((site, here, up) => {
(pname,site,here,up) => pname match {
case DataScratchpadSize => n case DataScratchpadSize => n
case CacheName("L1D") => up(CacheName("L1D"), site).copy(nSets = n / site(CacheBlockBytes)) case CacheName("L1D") => up(CacheName("L1D"), site).copy(nSets = n / site(CacheBlockBytes))
case _ => throw new CDEMatchError
}) })
// TODO: re-add L2 // TODO: re-add L2
class WithL2Cache extends Config( class WithL2Cache extends Config((site, here, up) => {
(pname,site,here) => pname match {
case CacheName("L2") => CacheConfig( case CacheName("L2") => CacheConfig(
nSets = 1024, nSets = 1024,
nWays = 1, nWays = 1,
@ -183,11 +157,9 @@ class WithL2Cache extends Config(
nTLBEntries = 0, nTLBEntries = 0,
cacheIdBits = 1, cacheIdBits = 1,
splitMetadata = false) splitMetadata = false)
case _ => throw new CDEMatchError
}) })
class WithBufferlessBroadcastHub extends Config( class WithBufferlessBroadcastHub extends Config((site, here, up) => {
(pname, site, here, up) => pname match {
case BroadcastConfig => up(BroadcastConfig, site).copy(bufferless = true) case BroadcastConfig => up(BroadcastConfig, site).copy(bufferless = true)
}) })
@ -203,8 +175,7 @@ class WithBufferlessBroadcastHub extends Config(
* system depends on coherence between channels in any way, * system depends on coherence between channels in any way,
* DO NOT use this configuration. * DO NOT use this configuration.
*/ */
class WithStatelessBridge extends Config( class WithStatelessBridge extends Config((site, here, up) => {
(pname,site,here,up) => pname match {
/* !!! FIXME /* !!! FIXME
case BankedL2Config => up(BankedL2Config, site).copy(coherenceManager = { case (_, _) => case BankedL2Config => up(BankedL2Config, site).copy(coherenceManager = { case (_, _) =>
val pass = LazyModule(new TLBuffer(0)(site)) val pass = LazyModule(new TLBuffer(0)(site))
@ -212,39 +183,24 @@ class WithStatelessBridge extends Config(
}) })
*/ */
case DCacheKey => up(DCacheKey, site).copy(nMSHRs = 0) case DCacheKey => up(DCacheKey, site).copy(nMSHRs = 0)
case _ => throw new CDEMatchError
}) })
class WithPLRU extends Config( class WithL2Capacity(size_kb: Int) extends Config(Parameters.empty)
(pname, site, here) => pname match {
case _ => throw new CDEMatchError
})
class WithL2Capacity(size_kb: Int) extends Config( class WithNL2Ways(n: Int) extends Config((site, here, up) => {
(pname,site,here) => pname match {
case _ => throw new CDEMatchError
})
class WithNL2Ways(n: Int) extends Config(
(pname,site,here,up) => pname match {
case CacheName("L2") => up(CacheName("L2"), site).copy(nWays = n) case CacheName("L2") => up(CacheName("L2"), site).copy(nWays = n)
}) })
class WithRV32 extends Config( class WithRV32 extends Config((site, here, up) => {
(pname,site,here) => pname match {
case XLen => 32 case XLen => 32
case FPUKey => Some(FPUConfig(divSqrt = false)) case FPUKey => Some(FPUConfig(divSqrt = false))
case _ => throw new CDEMatchError
}) })
class WithBlockingL1 extends Config( class WithBlockingL1 extends Config((site, here, up) => {
(pname,site,here,up) => pname match {
case DCacheKey => up(DCacheKey, site).copy(nMSHRs = 0) case DCacheKey => up(DCacheKey, site).copy(nMSHRs = 0)
case _ => throw new CDEMatchError
}) })
class WithSmallCores extends Config( class WithSmallCores extends Config((site, here, up) => {
(pname,site,here,up) => pname match {
case MulDivKey => Some(MulDivConfig()) case MulDivKey => Some(MulDivConfig())
case FPUKey => None case FPUKey => None
case UseVM => false case UseVM => false
@ -253,11 +209,9 @@ class WithSmallCores extends Config(
case CacheName("L1D") => up(CacheName("L1D"), site).copy(nSets = 64, nWays = 1, nTLBEntries = 4) case CacheName("L1D") => up(CacheName("L1D"), site).copy(nSets = 64, nWays = 1, nTLBEntries = 4)
case CacheName("L1I") => up(CacheName("L1I"), site).copy(nSets = 64, nWays = 1, nTLBEntries = 4) case CacheName("L1I") => up(CacheName("L1I"), site).copy(nSets = 64, nWays = 1, nTLBEntries = 4)
case DCacheKey => up(DCacheKey, site).copy(nMSHRs = 0) case DCacheKey => up(DCacheKey, site).copy(nMSHRs = 0)
case _ => throw new CDEMatchError
}) })
class WithRoccExample extends Config( class WithRoccExample extends Config((site, here, up) => {
(pname, site, here) => pname match {
case BuildRoCC => Seq( case BuildRoCC => Seq(
RoccParameters( RoccParameters(
opcodes = OpcodeSet.custom0, opcodes = OpcodeSet.custom0,
@ -271,35 +225,24 @@ class WithRoccExample extends Config(
generator = (p: Parameters) => Module(new CharacterCountExample()(p)))) generator = (p: Parameters) => Module(new CharacterCountExample()(p))))
case RoccMaxTaggedMemXacts => 1 case RoccMaxTaggedMemXacts => 1
case _ => throw new CDEMatchError
}) })
class WithDefaultBtb extends Config( class WithDefaultBtb extends Config((site, here, up) => {
(pname,site,here) => pname match {
case BtbKey => BtbParameters() case BtbKey => BtbParameters()
case _ => throw new CDEMatchError
}) })
class WithFastMulDiv extends Config( class WithFastMulDiv extends Config((site, here, up) => {
(pname,site,here) => pname match {
case MulDivKey => Some(MulDivConfig(mulUnroll = 8, mulEarlyOut = (site(XLen) > 32), divEarlyOut = true)) case MulDivKey => Some(MulDivConfig(mulUnroll = 8, mulEarlyOut = (site(XLen) > 32), divEarlyOut = true))
case _ => throw new CDEMatchError
}) })
class WithoutMulDiv extends Config( class WithoutMulDiv extends Config((site, here, up) => {
(pname, site, here) => pname match {
case MulDivKey => None case MulDivKey => None
case _ => throw new CDEMatchError
}) })
class WithoutFPU extends Config( class WithoutFPU extends Config((site, here, up) => {
(pname, site, here) => pname match {
case FPUKey => None case FPUKey => None
case _ => throw new CDEMatchError
}) })
class WithFPUWithoutDivSqrt extends Config ( class WithFPUWithoutDivSqrt extends Config((site, here, up) => {
(pname, site, here) => pname match {
case FPUKey => Some(FPUConfig(divSqrt = false)) case FPUKey => Some(FPUConfig(divSqrt = false))
case _ => throw new CDEMatchError
}) })

View File

@ -45,7 +45,7 @@ class FancyMemtestConfig extends Config(
new WithL2Cache ++ new GroundTestConfig) new WithL2Cache ++ new GroundTestConfig)
class CacheFillTestConfig extends Config( class CacheFillTestConfig extends Config(
new WithNL2Ways(4) ++ new WithL2Capacity(4) ++ new WithCacheFillTest ++ new WithPLRU ++ new WithL2Cache ++ new GroundTestConfig) new WithNL2Ways(4) ++ new WithL2Capacity(4) ++ new WithCacheFillTest ++ new WithL2Cache ++ new GroundTestConfig)
class BroadcastRegressionTestConfig extends Config( class BroadcastRegressionTestConfig extends Config(
new WithBroadcastRegressionTest ++ new GroundTestConfig) new WithBroadcastRegressionTest ++ new GroundTestConfig)
@ -73,8 +73,7 @@ class Edge32BitMemtestConfig extends Config(
new WithEdgeDataBits(32) ++ new MemtestConfig) new WithEdgeDataBits(32) ++ new MemtestConfig)
/* Composable Configs to set individual parameters */ /* Composable Configs to set individual parameters */
class WithGroundTest extends Config( class WithGroundTest extends Config((site, here, up) => {
(pname, site, here) => pname match {
case TLKey("L1toL2") => { case TLKey("L1toL2") => {
val useMEI = site(NTiles) <= 1 val useMEI = site(NTiles) <= 1
val dataBeats = (8 * site(CacheBlockBytes)) / site(XLen) val dataBeats = (8 * site(CacheBlockBytes)) / site(XLen)
@ -96,11 +95,9 @@ class WithGroundTest extends Config(
case FPUKey => None case FPUKey => None
case UseAtomics => false case UseAtomics => false
case UseCompressed => false case UseCompressed => false
case _ => throw new CDEMatchError
}) })
class WithComparator extends Config( class WithComparator extends Config((site, here, up) => {
(pname, site, here) => pname match {
case GroundTestKey => Seq.fill(site(NTiles)) { case GroundTestKey => Seq.fill(site(NTiles)) {
GroundTestTileSettings(uncached = 2) GroundTestTileSettings(uncached = 2)
} }
@ -114,23 +111,17 @@ class WithComparator extends Config(
prefetches = false) prefetches = false)
case FPUConfig => None case FPUConfig => None
case UseAtomics => false case UseAtomics => false
case _ => throw new CDEMatchError
}) })
class WithAtomics extends Config( class WithAtomics extends Config((site, here, up) => {
(pname, site, here) => pname match {
case UseAtomics => true case UseAtomics => true
case _ => throw new CDEMatchError
}) })
class WithPrefetches extends Config( class WithPrefetches extends Config((site, here, up) => {
(pname, site, here, up) => pname match {
case ComparatorKey => up(ComparatorKey, site).copy(prefetches = true) case ComparatorKey => up(ComparatorKey, site).copy(prefetches = true)
case _ => throw new CDEMatchError
}) })
class WithMemtest extends Config( class WithMemtest extends Config((site, here, up) => {
(pname, site, here) => pname match {
case GroundTestKey => Seq.fill(site(NTiles)) { case GroundTestKey => Seq.fill(site(NTiles)) {
GroundTestTileSettings(1, 1) GroundTestTileSettings(1, 1)
} }
@ -139,29 +130,23 @@ class WithMemtest extends Config(
startAddress = BigInt(site(ExtMem).base)) startAddress = BigInt(site(ExtMem).base))
case BuildGroundTest => case BuildGroundTest =>
(p: Parameters) => Module(new GeneratorTest()(p)) (p: Parameters) => Module(new GeneratorTest()(p))
case _ => throw new CDEMatchError
}) })
class WithNGenerators(nUncached: Int, nCached: Int) extends Config( class WithNGenerators(nUncached: Int, nCached: Int) extends Config((site, here, up) => {
(pname, site, here) => pname match {
case GroundTestKey => Seq.fill(site(NTiles)) { case GroundTestKey => Seq.fill(site(NTiles)) {
GroundTestTileSettings(nUncached, nCached) GroundTestTileSettings(nUncached, nCached)
} }
case _ => throw new CDEMatchError
}) })
class WithCacheFillTest extends Config( class WithCacheFillTest extends Config((site, here, up) => {
(pname, site, here) => pname match {
case GroundTestKey => Seq.fill(site(NTiles)) { case GroundTestKey => Seq.fill(site(NTiles)) {
GroundTestTileSettings(uncached = 1) GroundTestTileSettings(uncached = 1)
} }
case BuildGroundTest => case BuildGroundTest =>
(p: Parameters) => Module(new CacheFillTest()(p)) (p: Parameters) => Module(new CacheFillTest()(p))
case _ => throw new CDEMatchError
}) })
class WithBroadcastRegressionTest extends Config( class WithBroadcastRegressionTest extends Config((site, here, up) => {
(pname, site, here) => pname match {
case GroundTestKey => Seq.fill(site(NTiles)) { case GroundTestKey => Seq.fill(site(NTiles)) {
GroundTestTileSettings(1, 1, maxXacts = 3) GroundTestTileSettings(1, 1, maxXacts = 3)
} }
@ -169,11 +154,9 @@ class WithBroadcastRegressionTest extends Config(
(p: Parameters) => Module(new RegressionTest()(p)) (p: Parameters) => Module(new RegressionTest()(p))
case GroundTestRegressions => case GroundTestRegressions =>
(p: Parameters) => RegressionTests.broadcastRegressions(p) (p: Parameters) => RegressionTests.broadcastRegressions(p)
case _ => throw new CDEMatchError
}) })
class WithCacheRegressionTest extends Config( class WithCacheRegressionTest extends Config((site, here, up) => {
(pname, site, here) => pname match {
case GroundTestKey => Seq.fill(site(NTiles)) { case GroundTestKey => Seq.fill(site(NTiles)) {
GroundTestTileSettings(1, 1, maxXacts = 5) GroundTestTileSettings(1, 1, maxXacts = 5)
} }
@ -181,11 +164,9 @@ class WithCacheRegressionTest extends Config(
(p: Parameters) => Module(new RegressionTest()(p)) (p: Parameters) => Module(new RegressionTest()(p))
case GroundTestRegressions => case GroundTestRegressions =>
(p: Parameters) => RegressionTests.cacheRegressions(p) (p: Parameters) => RegressionTests.cacheRegressions(p)
case _ => throw new CDEMatchError
}) })
class WithTraceGen extends Config( class WithTraceGen extends Config((site, here, up) => {
(pname, site, here, up) => pname match {
case GroundTestKey => Seq.fill(site(NTiles)) { case GroundTestKey => Seq.fill(site(NTiles)) {
GroundTestTileSettings(uncached = 1, cached = 1) GroundTestTileSettings(uncached = 1, cached = 1)
} }
@ -205,5 +186,4 @@ class WithTraceGen extends Config(
} }
case UseAtomics => true case UseAtomics => true
case CacheName("L1D") => up(CacheName("L1D"), site).copy(nSets = 16, nWays = 1) case CacheName("L1D") => up(CacheName("L1D"), site).copy(nSets = 16, nWays = 1)
case _ => throw new CDEMatchError
}) })

View File

@ -19,8 +19,7 @@ import scala.collection.immutable.HashMap
import DefaultTestSuites._ import DefaultTestSuites._
import config._ import config._
class BasePlatformConfig extends Config( class BasePlatformConfig extends Config((site, here, up) => {
(pname,site,here) => pname match {
// TileLink connection parameters // TileLink connection parameters
case TLMonitorBuilder => (args: TLMonitorArgs) => Some(LazyModule(new TLMonitor(args))) case TLMonitorBuilder => (args: TLMonitorArgs) => Some(LazyModule(new TLMonitor(args)))
case TLFuzzReadyValid => false case TLFuzzReadyValid => false
@ -36,7 +35,6 @@ class BasePlatformConfig extends Config(
case ExtBus => MasterConfig(base=0x60000000L, size=0x20000000L, beatBytes=8, idBits=4) case ExtBus => MasterConfig(base=0x60000000L, size=0x20000000L, beatBytes=8, idBits=4)
case ExtIn => SlaveConfig(beatBytes=8, idBits=8, sourceBits=2) case ExtIn => SlaveConfig(beatBytes=8, idBits=8, sourceBits=2)
case RTCPeriod => 100 // gives 10 MHz RTC assuming 1 GHz uncore clock case RTCPeriod => 100 // gives 10 MHz RTC assuming 1 GHz uncore clock
case _ => throw new CDEMatchError
}) })
class BaseConfig extends Config(new BaseCoreplexConfig ++ new BasePlatformConfig) class BaseConfig extends Config(new BaseCoreplexConfig ++ new BasePlatformConfig)
@ -46,32 +44,21 @@ class DefaultL2Config extends Config(new WithL2Cache ++ new BaseConfig)
class DefaultBufferlessConfig extends Config( class DefaultBufferlessConfig extends Config(
new WithBufferlessBroadcastHub ++ new BaseConfig) new WithBufferlessBroadcastHub ++ new BaseConfig)
class FPGAConfig extends Config ( class FPGAConfig extends Config ((site, here, up) => {
(pname,site,here) => pname match {
case NAcquireTransactors => 4 case NAcquireTransactors => 4
case _ => throw new CDEMatchError })
}
)
class DefaultFPGAConfig extends Config(new FPGAConfig ++ new BaseConfig) class DefaultFPGAConfig extends Config(new FPGAConfig ++ new BaseConfig)
class DefaultL2FPGAConfig extends Config( class DefaultL2FPGAConfig extends Config(
new WithL2Capacity(64) ++ new WithL2Cache ++ new DefaultFPGAConfig) new WithL2Capacity(64) ++ new WithL2Cache ++ new DefaultFPGAConfig)
class PLRUL2Config extends Config(new WithPLRU ++ new DefaultL2Config) class WithNMemoryChannels(n: Int) extends Config((site, here, up) => {
class WithNMemoryChannels(n: Int) extends Config(
(pname,site,here,up) => pname match {
case BankedL2Config => up(BankedL2Config, site).copy(nMemoryChannels = n) case BankedL2Config => up(BankedL2Config, site).copy(nMemoryChannels = n)
case _ => throw new CDEMatchError })
}
)
class WithExtMemSize(n: Long) extends Config( class WithExtMemSize(n: Long) extends Config((site, here, up) => {
(pname,site,here,up) => pname match {
case ExtMem => up(ExtMem, site).copy(size = n) case ExtMem => up(ExtMem, site).copy(size = n)
case _ => throw new CDEMatchError })
}
)
class WithScratchpads extends Config(new WithNMemoryChannels(0) ++ new WithDataScratchpad(16384)) class WithScratchpads extends Config(new WithNMemoryChannels(0) ++ new WithDataScratchpad(16384))
@ -97,10 +84,8 @@ class DualChannelDualBankL2Config extends Config(
class RoccExampleConfig extends Config(new WithRoccExample ++ new BaseConfig) class RoccExampleConfig extends Config(new WithRoccExample ++ new BaseConfig)
class WithEdgeDataBits(dataBits: Int) extends Config( class WithEdgeDataBits(dataBits: Int) extends Config((site, here, up) => {
(pname, site, here, up) => pname match {
case ExtMem => up(ExtMem, site).copy(beatBytes = dataBits/8) case ExtMem => up(ExtMem, site).copy(beatBytes = dataBits/8)
case _ => throw new CDEMatchError
}) })
class Edge128BitConfig extends Config( class Edge128BitConfig extends Config(
@ -127,48 +112,30 @@ class TinyConfig extends Config(
new WithSmallCores ++ new WithRV32 ++ new WithSmallCores ++ new WithRV32 ++
new WithStatelessBridge ++ new BaseConfig) new WithStatelessBridge ++ new BaseConfig)
class WithJtagDTM extends Config ( class WithJtagDTM extends Config ((site, here, up) => {
(pname, site, here) => pname match {
case IncludeJtagDTM => true case IncludeJtagDTM => true
case _ => throw new CDEMatchError })
}
) class WithNoPeripheryArithAMO extends Config ((site, here, up) => {
case PeripheryBusArithmetic => false
class WithNoPeripheryArithAMO extends Config ( })
(pname, site, here) => pname match {
case PeripheryBusArithmetic => false class With64BitPeriphery extends Config ((site, here, up) => {
} case PeripheryBusConfig => TLBusConfig(beatBytes = 8)
) })
class With64BitPeriphery extends Config ( class WithoutTLMonitors extends Config ((site, here, up) => {
(pname, site, here) => pname match { case TLMonitorBuilder => (args: TLMonitorArgs) => None
case PeripheryBusConfig => TLBusConfig(beatBytes = 8) })
}
) class WithNExtTopInterrupts(nExtInts: Int) extends Config((site, here, up) => {
case NExtTopInterrupts => nExtInts
class WithoutTLMonitors extends Config ( })
(pname, site, here) => pname match {
case TLMonitorBuilder => (args: TLMonitorArgs) => None class WithNBreakpoints(hwbp: Int) extends Config ((site, here, up) => {
case _ => throw new CDEMatchError case NBreakpoints => hwbp
} })
)
class WithRTCPeriod(nCycles: Int) extends Config((site, here, up) => {
class WithNExtTopInterrupts(nExtInts: Int) extends Config( case RTCPeriod => nCycles
(pname, site, here) => pname match {
case NExtTopInterrupts => nExtInts
case _ => throw new CDEMatchError
}
)
class WithNBreakpoints(hwbp: Int) extends Config (
(pname,site,here) => pname match {
case NBreakpoints => hwbp
case _ => throw new CDEMatchError
}
)
class WithRTCPeriod(nCycles: Int) extends Config(
(pname, site, here) => pname match {
case RTCPeriod => nCycles
case _ => throw new CDEMatchError
}) })

View File

@ -7,8 +7,7 @@ import config._
import junctions._ import junctions._
import rocketchip.{BaseConfig, BasePlatformConfig} import rocketchip.{BaseConfig, BasePlatformConfig}
class WithJunctionsUnitTests extends Config( class WithJunctionsUnitTests extends Config((site, here, up) => {
(pname, site, here) => pname match {
case HastiId => "HastiTest" case HastiId => "HastiTest"
case HastiKey("HastiTest") => HastiParameters(addrBits = 32, dataBits = 64) case HastiKey("HastiTest") => HastiParameters(addrBits = 32, dataBits = 64)
case NastiKey => NastiParameters(addrBits = 32, dataBits = 64, idBits = 4) case NastiKey => NastiParameters(addrBits = 32, dataBits = 64, idBits = 4)
@ -17,13 +16,11 @@ class WithJunctionsUnitTests extends Config(
case UnitTests => (p: Parameters) => Seq( case UnitTests => (p: Parameters) => Seq(
Module(new junctions.MultiWidthFifoTest), Module(new junctions.MultiWidthFifoTest),
Module(new junctions.HastiTest()(p))) Module(new junctions.HastiTest()(p)))
case _ => throw new CDEMatchError
}) })
class JunctionsUnitTestConfig extends Config(new WithJunctionsUnitTests ++ new BasePlatformConfig) class JunctionsUnitTestConfig extends Config(new WithJunctionsUnitTests ++ new BasePlatformConfig)
class WithUncoreUnitTests extends Config( class WithUncoreUnitTests extends Config((site, here, up) => {
(pname, site, here) => pname match {
case uncore.tilelink.TLId => "L1toL2" case uncore.tilelink.TLId => "L1toL2"
case UnitTests => (q: Parameters) => { case UnitTests => (q: Parameters) => {
implicit val p = q implicit val p = q
@ -37,14 +34,11 @@ class WithUncoreUnitTests extends Config(
Module(new uncore.axi4.AXI4LiteFuzzRAMTest), Module(new uncore.axi4.AXI4LiteFuzzRAMTest),
Module(new uncore.axi4.AXI4FullFuzzRAMTest), Module(new uncore.axi4.AXI4FullFuzzRAMTest),
Module(new uncore.axi4.AXI4BridgeTest)) } Module(new uncore.axi4.AXI4BridgeTest)) }
case _ => throw new CDEMatchError })
}
)
class UncoreUnitTestConfig extends Config(new WithUncoreUnitTests ++ new BaseConfig) class UncoreUnitTestConfig extends Config(new WithUncoreUnitTests ++ new BaseConfig)
class WithTLSimpleUnitTests extends Config( class WithTLSimpleUnitTests extends Config((site, here, up) => {
(pname, site, here) => pname match {
case UnitTests => (q: Parameters) => { case UnitTests => (q: Parameters) => {
implicit val p = q implicit val p = q
Seq( Seq(
@ -54,10 +48,9 @@ class WithTLSimpleUnitTests extends Config(
Module(new uncore.tilelink2.TLRR0Test), Module(new uncore.tilelink2.TLRR0Test),
Module(new uncore.tilelink2.TLRR1Test), Module(new uncore.tilelink2.TLRR1Test),
Module(new uncore.tilelink2.TLRAMCrossingTest) ) } Module(new uncore.tilelink2.TLRAMCrossingTest) ) }
case _ => throw new CDEMatchError }) })
class WithTLWidthUnitTests extends Config( class WithTLWidthUnitTests extends Config((site, here, up) => {
(pname, site, here) => pname match {
case UnitTests => (q: Parameters) => { case UnitTests => (q: Parameters) => {
implicit val p = q implicit val p = q
Seq( Seq(
@ -67,10 +60,9 @@ class WithTLWidthUnitTests extends Config(
Module(new uncore.tilelink2.TLRAMWidthWidgetTest( 1, 1)), Module(new uncore.tilelink2.TLRAMWidthWidgetTest( 1, 1)),
Module(new uncore.tilelink2.TLRAMWidthWidgetTest( 4, 64)), Module(new uncore.tilelink2.TLRAMWidthWidgetTest( 4, 64)),
Module(new uncore.tilelink2.TLRAMWidthWidgetTest(64, 4)) ) } Module(new uncore.tilelink2.TLRAMWidthWidgetTest(64, 4)) ) }
case _ => throw new CDEMatchError }) })
class WithTLXbarUnitTests extends Config( class WithTLXbarUnitTests extends Config((site, here, up) => {
(pname, site, here) => pname match {
case UnitTests => (q: Parameters) => { case UnitTests => (q: Parameters) => {
implicit val p = q implicit val p = q
Seq( Seq(
@ -79,7 +71,7 @@ class WithTLXbarUnitTests extends Config(
Module(new uncore.tilelink2.TLRAMXbarTest(8)), Module(new uncore.tilelink2.TLRAMXbarTest(8)),
//Module(new uncore.tilelink2.TLMulticlientXbarTest(4,4)), //Module(new uncore.tilelink2.TLMulticlientXbarTest(4,4)),
Module(new uncore.tilelink2.TLMulticlientXbarTest(1,4)) ) } Module(new uncore.tilelink2.TLMulticlientXbarTest(1,4)) ) }
case _ => throw new CDEMatchError }) })
class TLSimpleUnitTestConfig extends Config(new WithTLSimpleUnitTests ++ new BasePlatformConfig) class TLSimpleUnitTestConfig extends Config(new WithTLSimpleUnitTests ++ new BasePlatformConfig)
class TLWidthUnitTestConfig extends Config(new WithTLWidthUnitTests ++ new BasePlatformConfig) class TLWidthUnitTestConfig extends Config(new WithTLWidthUnitTests ++ new BasePlatformConfig)