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:
committed by
Henry Cook
parent
b448387899
commit
52bb6cd9d9
@ -7,79 +7,71 @@ import config._
|
||||
import junctions._
|
||||
import rocketchip.{BaseConfig, BasePlatformConfig}
|
||||
|
||||
class WithJunctionsUnitTests extends Config(
|
||||
(pname, site, here) => pname match {
|
||||
case HastiId => "HastiTest"
|
||||
case HastiKey("HastiTest") => HastiParameters(addrBits = 32, dataBits = 64)
|
||||
case NastiKey => NastiParameters(addrBits = 32, dataBits = 64, idBits = 4)
|
||||
case junctions.PAddrBits => 32
|
||||
case rocket.XLen => 64
|
||||
case UnitTests => (p: Parameters) => Seq(
|
||||
Module(new junctions.MultiWidthFifoTest),
|
||||
Module(new junctions.HastiTest()(p)))
|
||||
case _ => throw new CDEMatchError
|
||||
})
|
||||
class WithJunctionsUnitTests extends Config((site, here, up) => {
|
||||
case HastiId => "HastiTest"
|
||||
case HastiKey("HastiTest") => HastiParameters(addrBits = 32, dataBits = 64)
|
||||
case NastiKey => NastiParameters(addrBits = 32, dataBits = 64, idBits = 4)
|
||||
case junctions.PAddrBits => 32
|
||||
case rocket.XLen => 64
|
||||
case UnitTests => (p: Parameters) => Seq(
|
||||
Module(new junctions.MultiWidthFifoTest),
|
||||
Module(new junctions.HastiTest()(p)))
|
||||
})
|
||||
|
||||
class JunctionsUnitTestConfig extends Config(new WithJunctionsUnitTests ++ new BasePlatformConfig)
|
||||
|
||||
class WithUncoreUnitTests extends Config(
|
||||
(pname, site, here) => pname match {
|
||||
case uncore.tilelink.TLId => "L1toL2"
|
||||
case UnitTests => (q: Parameters) => {
|
||||
implicit val p = q
|
||||
Seq(
|
||||
Module(new uncore.devices.ROMSlaveTest()),
|
||||
Module(new uncore.devices.TileLinkRAMTest()),
|
||||
Module(new uncore.converters.TileLinkWidthAdapterTest()),
|
||||
Module(new uncore.tilelink2.TLFuzzRAMTest),
|
||||
Module(new uncore.ahb.AHBBridgeTest),
|
||||
Module(new uncore.apb.APBBridgeTest),
|
||||
Module(new uncore.axi4.AXI4LiteFuzzRAMTest),
|
||||
Module(new uncore.axi4.AXI4FullFuzzRAMTest),
|
||||
Module(new uncore.axi4.AXI4BridgeTest)) }
|
||||
case _ => throw new CDEMatchError
|
||||
}
|
||||
)
|
||||
class WithUncoreUnitTests extends Config((site, here, up) => {
|
||||
case uncore.tilelink.TLId => "L1toL2"
|
||||
case UnitTests => (q: Parameters) => {
|
||||
implicit val p = q
|
||||
Seq(
|
||||
Module(new uncore.devices.ROMSlaveTest()),
|
||||
Module(new uncore.devices.TileLinkRAMTest()),
|
||||
Module(new uncore.converters.TileLinkWidthAdapterTest()),
|
||||
Module(new uncore.tilelink2.TLFuzzRAMTest),
|
||||
Module(new uncore.ahb.AHBBridgeTest),
|
||||
Module(new uncore.apb.APBBridgeTest),
|
||||
Module(new uncore.axi4.AXI4LiteFuzzRAMTest),
|
||||
Module(new uncore.axi4.AXI4FullFuzzRAMTest),
|
||||
Module(new uncore.axi4.AXI4BridgeTest)) }
|
||||
})
|
||||
|
||||
class UncoreUnitTestConfig extends Config(new WithUncoreUnitTests ++ new BaseConfig)
|
||||
|
||||
class WithTLSimpleUnitTests extends Config(
|
||||
(pname, site, here) => pname match {
|
||||
case UnitTests => (q: Parameters) => {
|
||||
implicit val p = q
|
||||
Seq(
|
||||
Module(new uncore.tilelink2.TLRAMSimpleTest(1)),
|
||||
Module(new uncore.tilelink2.TLRAMSimpleTest(4)),
|
||||
Module(new uncore.tilelink2.TLRAMSimpleTest(16)),
|
||||
Module(new uncore.tilelink2.TLRR0Test),
|
||||
Module(new uncore.tilelink2.TLRR1Test),
|
||||
Module(new uncore.tilelink2.TLRAMCrossingTest) ) }
|
||||
case _ => throw new CDEMatchError })
|
||||
class WithTLSimpleUnitTests extends Config((site, here, up) => {
|
||||
case UnitTests => (q: Parameters) => {
|
||||
implicit val p = q
|
||||
Seq(
|
||||
Module(new uncore.tilelink2.TLRAMSimpleTest(1)),
|
||||
Module(new uncore.tilelink2.TLRAMSimpleTest(4)),
|
||||
Module(new uncore.tilelink2.TLRAMSimpleTest(16)),
|
||||
Module(new uncore.tilelink2.TLRR0Test),
|
||||
Module(new uncore.tilelink2.TLRR1Test),
|
||||
Module(new uncore.tilelink2.TLRAMCrossingTest) ) }
|
||||
})
|
||||
|
||||
class WithTLWidthUnitTests extends Config(
|
||||
(pname, site, here) => pname match {
|
||||
case UnitTests => (q: Parameters) => {
|
||||
implicit val p = q
|
||||
Seq(
|
||||
Module(new uncore.tilelink2.TLRAMFragmenterTest( 4, 256)),
|
||||
Module(new uncore.tilelink2.TLRAMFragmenterTest(16, 64)),
|
||||
Module(new uncore.tilelink2.TLRAMFragmenterTest( 4, 16)),
|
||||
Module(new uncore.tilelink2.TLRAMWidthWidgetTest( 1, 1)),
|
||||
Module(new uncore.tilelink2.TLRAMWidthWidgetTest( 4, 64)),
|
||||
Module(new uncore.tilelink2.TLRAMWidthWidgetTest(64, 4)) ) }
|
||||
case _ => throw new CDEMatchError })
|
||||
class WithTLWidthUnitTests extends Config((site, here, up) => {
|
||||
case UnitTests => (q: Parameters) => {
|
||||
implicit val p = q
|
||||
Seq(
|
||||
Module(new uncore.tilelink2.TLRAMFragmenterTest( 4, 256)),
|
||||
Module(new uncore.tilelink2.TLRAMFragmenterTest(16, 64)),
|
||||
Module(new uncore.tilelink2.TLRAMFragmenterTest( 4, 16)),
|
||||
Module(new uncore.tilelink2.TLRAMWidthWidgetTest( 1, 1)),
|
||||
Module(new uncore.tilelink2.TLRAMWidthWidgetTest( 4, 64)),
|
||||
Module(new uncore.tilelink2.TLRAMWidthWidgetTest(64, 4)) ) }
|
||||
})
|
||||
|
||||
class WithTLXbarUnitTests extends Config(
|
||||
(pname, site, here) => pname match {
|
||||
case UnitTests => (q: Parameters) => {
|
||||
implicit val p = q
|
||||
Seq(
|
||||
Module(new uncore.tilelink2.TLRAMXbarTest(1)),
|
||||
Module(new uncore.tilelink2.TLRAMXbarTest(2)),
|
||||
Module(new uncore.tilelink2.TLRAMXbarTest(8)),
|
||||
//Module(new uncore.tilelink2.TLMulticlientXbarTest(4,4)),
|
||||
Module(new uncore.tilelink2.TLMulticlientXbarTest(1,4)) ) }
|
||||
case _ => throw new CDEMatchError })
|
||||
class WithTLXbarUnitTests extends Config((site, here, up) => {
|
||||
case UnitTests => (q: Parameters) => {
|
||||
implicit val p = q
|
||||
Seq(
|
||||
Module(new uncore.tilelink2.TLRAMXbarTest(1)),
|
||||
Module(new uncore.tilelink2.TLRAMXbarTest(2)),
|
||||
Module(new uncore.tilelink2.TLRAMXbarTest(8)),
|
||||
//Module(new uncore.tilelink2.TLMulticlientXbarTest(4,4)),
|
||||
Module(new uncore.tilelink2.TLMulticlientXbarTest(1,4)) ) }
|
||||
})
|
||||
|
||||
class TLSimpleUnitTestConfig extends Config(new WithTLSimpleUnitTests ++ new BasePlatformConfig)
|
||||
class TLWidthUnitTestConfig extends Config(new WithTLWidthUnitTests ++ new BasePlatformConfig)
|
||||
|
Reference in New Issue
Block a user