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

@ -19,25 +19,23 @@ import scala.collection.immutable.HashMap
import DefaultTestSuites._
import config._
class BasePlatformConfig extends Config(
(pname,site,here) => pname match {
// TileLink connection parameters
case TLMonitorBuilder => (args: TLMonitorArgs) => Some(LazyModule(new TLMonitor(args)))
case TLFuzzReadyValid => false
case TLCombinationalCheck => false
//Memory Parameters
case NExtTopInterrupts => 2
case SOCBusConfig => site(L1toL2Config)
case PeripheryBusConfig => TLBusConfig(beatBytes = 4)
case PeripheryBusArithmetic => true
// Note that PLIC asserts that this is > 0.
case IncludeJtagDTM => false
case ExtMem => MasterConfig(base=0x80000000L, size=0x10000000L, 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 RTCPeriod => 100 // gives 10 MHz RTC assuming 1 GHz uncore clock
case _ => throw new CDEMatchError
})
class BasePlatformConfig extends Config((site, here, up) => {
// TileLink connection parameters
case TLMonitorBuilder => (args: TLMonitorArgs) => Some(LazyModule(new TLMonitor(args)))
case TLFuzzReadyValid => false
case TLCombinationalCheck => false
//Memory Parameters
case NExtTopInterrupts => 2
case SOCBusConfig => site(L1toL2Config)
case PeripheryBusConfig => TLBusConfig(beatBytes = 4)
case PeripheryBusArithmetic => true
// Note that PLIC asserts that this is > 0.
case IncludeJtagDTM => false
case ExtMem => MasterConfig(base=0x80000000L, size=0x10000000L, 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 RTCPeriod => 100 // gives 10 MHz RTC assuming 1 GHz uncore clock
})
class BaseConfig extends Config(new BaseCoreplexConfig ++ new BasePlatformConfig)
class DefaultConfig extends Config(new WithBlockingL1 ++ new BaseConfig)
@ -46,32 +44,21 @@ class DefaultL2Config extends Config(new WithL2Cache ++ new BaseConfig)
class DefaultBufferlessConfig extends Config(
new WithBufferlessBroadcastHub ++ new BaseConfig)
class FPGAConfig extends Config (
(pname,site,here) => pname match {
case NAcquireTransactors => 4
case _ => throw new CDEMatchError
}
)
class FPGAConfig extends Config ((site, here, up) => {
case NAcquireTransactors => 4
})
class DefaultFPGAConfig extends Config(new FPGAConfig ++ new BaseConfig)
class DefaultL2FPGAConfig extends Config(
new WithL2Capacity(64) ++ new WithL2Cache ++ new DefaultFPGAConfig)
class PLRUL2Config extends Config(new WithPLRU ++ new DefaultL2Config)
class WithNMemoryChannels(n: Int) extends Config((site, here, up) => {
case BankedL2Config => up(BankedL2Config, site).copy(nMemoryChannels = n)
})
class WithNMemoryChannels(n: Int) extends Config(
(pname,site,here,up) => pname match {
case BankedL2Config => up(BankedL2Config, site).copy(nMemoryChannels = n)
case _ => throw new CDEMatchError
}
)
class WithExtMemSize(n: Long) extends Config(
(pname,site,here,up) => pname match {
case ExtMem => up(ExtMem, site).copy(size = n)
case _ => throw new CDEMatchError
}
)
class WithExtMemSize(n: Long) extends Config((site, here, up) => {
case ExtMem => up(ExtMem, site).copy(size = n)
})
class WithScratchpads extends Config(new WithNMemoryChannels(0) ++ new WithDataScratchpad(16384))
@ -97,11 +84,9 @@ class DualChannelDualBankL2Config extends Config(
class RoccExampleConfig extends Config(new WithRoccExample ++ new BaseConfig)
class WithEdgeDataBits(dataBits: Int) extends Config(
(pname, site, here, up) => pname match {
case ExtMem => up(ExtMem, site).copy(beatBytes = dataBits/8)
case _ => throw new CDEMatchError
})
class WithEdgeDataBits(dataBits: Int) extends Config((site, here, up) => {
case ExtMem => up(ExtMem, site).copy(beatBytes = dataBits/8)
})
class Edge128BitConfig extends Config(
new WithEdgeDataBits(128) ++ new BaseConfig)
@ -127,48 +112,30 @@ class TinyConfig extends Config(
new WithSmallCores ++ new WithRV32 ++
new WithStatelessBridge ++ new BaseConfig)
class WithJtagDTM extends Config (
(pname, site, here) => pname match {
case IncludeJtagDTM => true
case _ => throw new CDEMatchError
}
)
class WithJtagDTM extends Config ((site, here, up) => {
case IncludeJtagDTM => true
})
class WithNoPeripheryArithAMO extends Config (
(pname, site, here) => pname match {
case PeripheryBusArithmetic => false
}
)
class WithNoPeripheryArithAMO extends Config ((site, here, up) => {
case PeripheryBusArithmetic => false
})
class With64BitPeriphery extends Config (
(pname, site, here) => pname match {
case PeripheryBusConfig => TLBusConfig(beatBytes = 8)
}
)
class With64BitPeriphery extends Config ((site, here, up) => {
case PeripheryBusConfig => TLBusConfig(beatBytes = 8)
})
class WithoutTLMonitors extends Config (
(pname, site, here) => pname match {
case TLMonitorBuilder => (args: TLMonitorArgs) => None
case _ => throw new CDEMatchError
}
)
class WithoutTLMonitors extends Config ((site, here, up) => {
case TLMonitorBuilder => (args: TLMonitorArgs) => None
})
class WithNExtTopInterrupts(nExtInts: Int) extends Config(
(pname, site, here) => pname match {
case NExtTopInterrupts => nExtInts
case _ => throw new CDEMatchError
}
)
class WithNExtTopInterrupts(nExtInts: Int) extends Config((site, here, up) => {
case NExtTopInterrupts => nExtInts
})
class WithNBreakpoints(hwbp: Int) extends Config (
(pname,site,here) => pname match {
case NBreakpoints => hwbp
case _ => throw new CDEMatchError
}
)
class WithNBreakpoints(hwbp: Int) extends Config ((site, here, up) => {
case NBreakpoints => hwbp
})
class WithRTCPeriod(nCycles: Int) extends Config(
(pname, site, here) => pname match {
case RTCPeriod => nCycles
case _ => throw new CDEMatchError
})
class WithRTCPeriod(nCycles: Int) extends Config((site, here, up) => {
case RTCPeriod => nCycles
})