1
0

rocketchip: use self-type constraints

This commit is contained in:
Wesley W. Terpstra 2016-10-28 22:30:13 -07:00
parent d51b0b5c02
commit 5bca13ebdb
2 changed files with 93 additions and 78 deletions

View File

@ -37,7 +37,7 @@ abstract class BareTopModule[+B <: BareTopBundle[BareTop[BaseCoreplex]]](val io:
} }
/** Base Top with no Periphery */ /** Base Top with no Periphery */
trait TopNetwork { trait TopNetwork extends HasPeripheryParameters {
this: BareTop[BaseCoreplex] => this: BareTop[BaseCoreplex] =>
implicit val p = q implicit val p = q
TLImp.emitMonitors = p(TLEmitMonitors) TLImp.emitMonitors = p(TLEmitMonitors)
@ -53,13 +53,13 @@ trait TopNetwork {
socBus.node)) socBus.node))
} }
trait TopNetworkBundle { trait TopNetworkBundle extends HasPeripheryParameters {
this: BareTopBundle[BareTop[BaseCoreplex]] => this: BareTopBundle[BareTop[BaseCoreplex]] =>
implicit val p = outer.q implicit val p = outer.q
val success = Bool(OUTPUT) val success = Bool(OUTPUT)
} }
trait TopNetworkModule { trait TopNetworkModule extends HasPeripheryParameters {
this: { this: {
val outer: BareTop[BaseCoreplex] with TopNetwork val outer: BareTop[BaseCoreplex] with TopNetwork
val io: TopNetworkBundle val io: TopNetworkBundle

View File

@ -83,10 +83,8 @@ trait HasPeripheryParameters {
lazy val nMemAXIChannels = if (tMemChannels == BusType.AXI) nMemChannels else 0 lazy val nMemAXIChannels = if (tMemChannels == BusType.AXI) nMemChannels else 0
lazy val nMemAHBChannels = if (tMemChannels == BusType.AHB) nMemChannels else 0 lazy val nMemAHBChannels = if (tMemChannels == BusType.AHB) nMemChannels else 0
lazy val nMemTLChannels = if (tMemChannels == BusType.TL) nMemChannels else 0 lazy val nMemTLChannels = if (tMemChannels == BusType.TL) nMemChannels else 0
lazy val outerMMIOParams = p.alterPartial({ case TLId => "L2toMMIO" })
lazy val edgeSlaveParams = p.alterPartial({ case TLId => "EdgetoSlave" }) lazy val edgeSlaveParams = p.alterPartial({ case TLId => "EdgetoSlave" })
lazy val edgeMemParams = p.alterPartial({ case TLId => "MCtoEdge" }) lazy val edgeMemParams = p.alterPartial({ case TLId => "MCtoEdge" })
lazy val edgeMMIOParams = p.alterPartial({ case TLId => "MMIOtoEdge" })
lazy val peripheryBusConfig = p(PeripheryBusKey) lazy val peripheryBusConfig = p(PeripheryBusKey)
lazy val socBusConfig = p(SOCBusKey) lazy val socBusConfig = p(SOCBusKey)
lazy val cacheBlockBytes = p(CacheBlockBytes) lazy val cacheBlockBytes = p(CacheBlockBytes)
@ -94,12 +92,14 @@ trait HasPeripheryParameters {
///// /////
trait PeripheryDebug extends LazyModule { trait PeripheryDebug {
implicit val p: Parameters this: TopNetwork =>
} }
trait PeripheryDebugBundle { trait PeripheryDebugBundle {
implicit val p: Parameters this: TopNetworkBundle {
val outer: PeripheryDebug
} =>
val debug_clk = (p(AsyncDebugBus) && !p(IncludeJtagDTM)).option(Clock(INPUT)) val debug_clk = (p(AsyncDebugBus) && !p(IncludeJtagDTM)).option(Clock(INPUT))
val debug_rst = (p(AsyncDebugBus) && !p(IncludeJtagDTM)).option(Bool(INPUT)) val debug_rst = (p(AsyncDebugBus) && !p(IncludeJtagDTM)).option(Bool(INPUT))
val debug = (!p(IncludeJtagDTM)).option(new DebugBusIO()(p).flip) val debug = (!p(IncludeJtagDTM)).option(new DebugBusIO()(p).flip)
@ -107,10 +107,10 @@ trait PeripheryDebugBundle {
} }
trait PeripheryDebugModule { trait PeripheryDebugModule {
implicit val p: Parameters this: TopNetworkModule {
val outer: PeripheryDebug val outer: PeripheryDebug
val io: PeripheryDebugBundle val io: PeripheryDebugBundle
val coreplexDebug: DebugBusIO } =>
if (p(IncludeJtagDTM)) { if (p(IncludeJtagDTM)) {
// JtagDTMWithSync is a wrapper which // JtagDTMWithSync is a wrapper which
@ -127,9 +127,8 @@ trait PeripheryDebugModule {
///// /////
trait PeripheryExtInterrupts extends LazyModule { trait PeripheryExtInterrupts {
implicit val p: Parameters this: TopNetwork =>
val intBus: IntXbar
val extInterrupts = IntBlindInputNode(p(NExtTopInterrupts)) val extInterrupts = IntBlindInputNode(p(NExtTopInterrupts))
val extInterruptXing = LazyModule(new IntXing) val extInterruptXing = LazyModule(new IntXing)
@ -139,21 +138,29 @@ trait PeripheryExtInterrupts extends LazyModule {
} }
trait PeripheryExtInterruptsBundle { trait PeripheryExtInterruptsBundle {
val outer: PeripheryExtInterrupts this: TopNetworkBundle {
val outer: PeripheryExtInterrupts
} =>
val interrupts = outer.extInterrupts.bundleIn val interrupts = outer.extInterrupts.bundleIn
} }
trait PeripheryExtInterruptsModule { trait PeripheryExtInterruptsModule {
this: TopNetworkModule {
val outer: PeripheryExtInterrupts
val io: PeripheryExtInterruptsBundle
} =>
} }
///// /////
trait PeripheryMasterMem extends LazyModule { trait PeripheryMasterMem {
implicit val p: Parameters this: TopNetwork =>
} }
trait PeripheryMasterMemBundle extends HasPeripheryParameters { trait PeripheryMasterMemBundle {
implicit val p: Parameters this: TopNetworkBundle {
val outer: PeripheryMasterMem
} =>
val mem_clk = p(AsyncMemChannels).option(Vec(nMemChannels, Clock(INPUT))) val mem_clk = p(AsyncMemChannels).option(Vec(nMemChannels, Clock(INPUT)))
val mem_rst = p(AsyncMemChannels).option(Vec(nMemChannels, Bool (INPUT))) val mem_rst = p(AsyncMemChannels).option(Vec(nMemChannels, Bool (INPUT)))
val mem_axi = Vec(nMemAXIChannels, new NastiIO) val mem_axi = Vec(nMemAXIChannels, new NastiIO)
@ -161,11 +168,11 @@ trait PeripheryMasterMemBundle extends HasPeripheryParameters {
val mem_tl = Vec(nMemTLChannels, new ClientUncachedTileLinkIO()(edgeMemParams)) val mem_tl = Vec(nMemTLChannels, new ClientUncachedTileLinkIO()(edgeMemParams))
} }
trait PeripheryMasterMemModule extends HasPeripheryParameters { trait PeripheryMasterMemModule {
implicit val p: Parameters this: TopNetworkModule {
val outer: PeripheryMasterMem val outer: PeripheryMasterMem
val io: PeripheryMasterMemBundle val io: PeripheryMasterMemBundle
val coreplexMem: Vec[ClientUncachedTileLinkIO] } =>
val edgeMem = coreplexMem.map(TileLinkWidthAdapter(_, edgeMemParams)) val edgeMem = coreplexMem.map(TileLinkWidthAdapter(_, edgeMemParams))
@ -192,9 +199,8 @@ trait PeripheryMasterMemModule extends HasPeripheryParameters {
///// /////
// PeripheryMasterAXI4MMIO is an example, make your own cake pattern like this one. // PeripheryMasterAXI4MMIO is an example, make your own cake pattern like this one.
trait PeripheryMasterAXI4MMIO extends HasPeripheryParameters { trait PeripheryMasterAXI4MMIO {
implicit val p: Parameters this: TopNetwork =>
val socBus: TLXbar
val mmio_axi4 = AXI4BlindOutputNode(AXI4SlavePortParameters( val mmio_axi4 = AXI4BlindOutputNode(AXI4SlavePortParameters(
slaves = Seq(AXI4SlaveParameters( slaves = Seq(AXI4SlaveParameters(
@ -212,40 +218,45 @@ trait PeripheryMasterAXI4MMIO extends HasPeripheryParameters {
socBus.node)) socBus.node))
} }
trait PeripheryMasterAXI4MMIOBundle extends HasPeripheryParameters { trait PeripheryMasterAXI4MMIOBundle {
val outer: PeripheryMasterAXI4MMIO this: TopNetworkBundle {
val outer: PeripheryMasterAXI4MMIO
} =>
val mmio_axi = outer.mmio_axi4.bundleOut val mmio_axi = outer.mmio_axi4.bundleOut
} }
trait PeripheryMasterAXI4MMIOModule extends HasPeripheryParameters { trait PeripheryMasterAXI4MMIOModule {
implicit val p: Parameters this: TopNetworkModule {
val outer: PeripheryMasterAXI4MMIO val outer: PeripheryMasterAXI4MMIO
val io: PeripheryMasterAXI4MMIOBundle val io: PeripheryMasterAXI4MMIOBundle
} =>
// nothing to do // nothing to do
} }
///// /////
trait PeripherySlave extends LazyModule { trait PeripherySlave {
implicit val p: Parameters this: TopNetwork {
val pBusMasters: RangeManager val pBusMasters: RangeManager
} =>
if (p(NExtBusAXIChannels) > 0) pBusMasters.add("ext", 1) // NExtBusAXIChannels are arbitrated into one TL port if (p(NExtBusAXIChannels) > 0) pBusMasters.add("ext", 1) // NExtBusAXIChannels are arbitrated into one TL port
} }
trait PeripherySlaveBundle extends HasPeripheryParameters { trait PeripherySlaveBundle {
implicit val p: Parameters this: TopNetworkBundle {
val outer: PeripherySlave
} =>
val bus_clk = p(AsyncBusChannels).option(Vec(p(NExtBusAXIChannels), Clock(INPUT))) val bus_clk = p(AsyncBusChannels).option(Vec(p(NExtBusAXIChannels), Clock(INPUT)))
val bus_rst = p(AsyncBusChannels).option(Vec(p(NExtBusAXIChannels), Bool (INPUT))) val bus_rst = p(AsyncBusChannels).option(Vec(p(NExtBusAXIChannels), Bool (INPUT)))
val bus_axi = Vec(p(NExtBusAXIChannels), new NastiIO).flip val bus_axi = Vec(p(NExtBusAXIChannels), new NastiIO).flip
} }
trait PeripherySlaveModule extends HasPeripheryParameters { trait PeripherySlaveModule {
implicit val p: Parameters this: TopNetworkModule {
val outer: PeripherySlave val outer: PeripherySlave { val pBusMasters: RangeManager }
val io: PeripherySlaveBundle val io: PeripherySlaveBundle
val coreplexSlave: Vec[ClientUncachedTileLinkIO] } =>
if (p(NExtBusAXIChannels) > 0) { if (p(NExtBusAXIChannels) > 0) {
val arb = Module(new NastiArbiter(p(NExtBusAXIChannels))) val arb = Module(new NastiArbiter(p(NExtBusAXIChannels)))
@ -266,72 +277,76 @@ trait PeripherySlaveModule extends HasPeripheryParameters {
///// /////
trait PeripheryBootROM extends LazyModule with HasPeripheryParameters { trait PeripheryBootROM {
implicit val p: Parameters this: TopNetwork =>
val peripheryBus: TLXbar
val address = 0x1000 val bootrom_address = 0x1000
val size = 0x1000 val bootrom_size = 0x1000
val bootrom = LazyModule(new TLROM(address, size, GenerateBootROM(p, address), true, peripheryBusConfig.beatBytes)) val bootrom = LazyModule(new TLROM(bootrom_address, bootrom_size, GenerateBootROM(p, bootrom_address), true, peripheryBusConfig.beatBytes))
bootrom.node := TLFragmenter(peripheryBusConfig.beatBytes, cacheBlockBytes)(peripheryBus.node) bootrom.node := TLFragmenter(peripheryBusConfig.beatBytes, cacheBlockBytes)(peripheryBus.node)
} }
trait PeripheryBootROMBundle { trait PeripheryBootROMBundle {
implicit val p: Parameters this: TopNetworkBundle {
val outer: PeripheryBootROM
} =>
} }
trait PeripheryBootROMModule extends HasPeripheryParameters { trait PeripheryBootROMModule {
implicit val p: Parameters this: TopNetworkModule {
val outer: PeripheryBootROM val outer: PeripheryBootROM
val io: PeripheryBootROMBundle val io: PeripheryBootROMBundle
} =>
} }
///// /////
trait PeripheryTestRAM extends LazyModule with HasPeripheryParameters { trait PeripheryTestRAM {
implicit val p: Parameters this: TopNetwork =>
val peripheryBus: TLXbar
val ramBase = 0x52000000 val testram = LazyModule(new TLRAM(AddressSet(0x52000000, 0xfff), true, peripheryBusConfig.beatBytes))
val ramSize = 0x1000 testram.node := TLFragmenter(peripheryBusConfig.beatBytes, cacheBlockBytes)(peripheryBus.node)
val sram = LazyModule(new TLRAM(AddressSet(ramBase, ramSize-1), true, peripheryBusConfig.beatBytes)
{ override def name = "testram" })
sram.node := TLFragmenter(peripheryBusConfig.beatBytes, cacheBlockBytes)(peripheryBus.node)
} }
trait PeripheryTestRAMBundle { trait PeripheryTestRAMBundle {
implicit val p: Parameters this: TopNetworkBundle {
val outer: PeripheryTestRAM
} =>
} }
trait PeripheryTestRAMModule extends HasPeripheryParameters { trait PeripheryTestRAMModule {
implicit val p: Parameters this: TopNetworkModule {
val outer: PeripheryTestRAM val outer: PeripheryTestRAM
val io: PeripheryTestRAMBundle
} =>
} }
///// /////
trait PeripheryTestBusMaster extends LazyModule { trait PeripheryTestBusMaster {
implicit val p: Parameters this: TopNetwork =>
val peripheryBus: TLXbar
val fuzzer = LazyModule(new TLFuzzer(5000)) val fuzzer = LazyModule(new TLFuzzer(5000))
peripheryBus.node := fuzzer.node peripheryBus.node := fuzzer.node
} }
trait PeripheryTestBusMasterBundle { trait PeripheryTestBusMasterBundle {
implicit val p: Parameters this: TopNetworkBundle {
val outer: PeripheryTestBusMaster
} =>
} }
trait PeripheryTestBusMasterModule { trait PeripheryTestBusMasterModule {
implicit val p: Parameters this: TopNetworkModule {
val outer: PeripheryTestBusMaster val outer: PeripheryTestBusMaster
val io: PeripheryTestBusMasterBundle
} =>
} }
///// /////
trait HardwiredResetVector { trait HardwiredResetVector {
val outer: BaseTop[BaseCoreplex] this: TopNetworkModule {
val outer: BaseTop[BaseCoreplex]
} =>
outer.coreplex.module.io.resetVector := UInt(0x1000) // boot ROM outer.coreplex.module.io.resetVector := UInt(0x1000) // boot ROM
} }