X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmain%2Fscala%2Fdevices%2Fspi%2FSPIPeriphery.scala;h=f2b3b4198fc1e7ce96b02d612581c38f5d5dca2e;hb=ef4f2ed888cd614858c6b2647c1eb6f988ff3973;hp=daa0a9f9ed5cc3c02e5af41a0dde991d6aa09d58;hpb=27b00e177c2b4cd29234e556b3b6a0260d151431;p=sifive-blocks.git diff --git a/src/main/scala/devices/spi/SPIPeriphery.scala b/src/main/scala/devices/spi/SPIPeriphery.scala index daa0a9f..f2b3b41 100644 --- a/src/main/scala/devices/spi/SPIPeriphery.scala +++ b/src/main/scala/devices/spi/SPIPeriphery.scala @@ -2,19 +2,15 @@ package sifive.blocks.devices.spi import Chisel._ -import config.Field -import diplomacy.LazyModule -import rocketchip.{ - HasTopLevelNetworks, - HasTopLevelNetworksBundle, - HasTopLevelNetworksModule -} -import uncore.tilelink2.{TLFragmenter, TLWidthWidget} -import util.HeterogeneousBag +import freechips.rocketchip.config.Field +import freechips.rocketchip.diplomacy.{LazyModule,LazyMultiIOModuleImp} +import freechips.rocketchip.chip.HasSystemNetworks +import freechips.rocketchip.tilelink.{TLFragmenter,TLWidthWidget} +import freechips.rocketchip.util.HeterogeneousBag case object PeripherySPIKey extends Field[Seq[SPIParams]] -trait HasPeripherySPI extends HasTopLevelNetworks { +trait HasPeripherySPI extends HasSystemNetworks { val spiParams = p(PeripherySPIKey) val spis = spiParams map { params => val spi = LazyModule(new TLSPI(peripheryBusBytes, params)) @@ -24,24 +20,25 @@ trait HasPeripherySPI extends HasTopLevelNetworks { } } -trait HasPeripherySPIBundle extends HasTopLevelNetworksBundle { - val outer: HasPeripherySPI - val spis = HeterogeneousBag(outer.spiParams.map(new SPIPortIO(_))) +trait HasPeripherySPIBundle { + val spi: HeterogeneousBag[SPIPortIO] + } -trait HasPeripherySPIModule extends HasTopLevelNetworksModule { +trait HasPeripherySPIModuleImp extends LazyMultiIOModuleImp with HasPeripherySPIBundle { val outer: HasPeripherySPI - val io: HasPeripherySPIBundle - (io.spis zip outer.spis).foreach { case (io, device) => + val spi = IO(HeterogeneousBag(outer.spiParams.map(new SPIPortIO(_)))) + + (spi zip outer.spis).foreach { case (io, device) => io <> device.module.io.port } } case object PeripherySPIFlashKey extends Field[Seq[SPIFlashParams]] -trait HasPeripherySPIFlash extends HasTopLevelNetworks { +trait HasPeripherySPIFlash extends HasSystemNetworks { val spiFlashParams = p(PeripherySPIFlashKey) - val qspi = spiFlashParams map { params => + val qspis = spiFlashParams map { params => val qspi = LazyModule(new TLSPIFlash(peripheryBusBytes, params)) qspi.rnode := TLFragmenter(peripheryBusBytes, cacheBlockBytes)(peripheryBus.node) qspi.fnode := TLFragmenter(1, cacheBlockBytes)(TLWidthWidget(peripheryBusBytes)(peripheryBus.node)) @@ -50,16 +47,16 @@ trait HasPeripherySPIFlash extends HasTopLevelNetworks { } } -trait HasPeripherySPIFlashBundle extends HasTopLevelNetworksBundle { - val outer: HasPeripherySPIFlash - val qspi = HeterogeneousBag(outer.spiFlashParams.map(new SPIPortIO(_))) +trait HasPeripherySPIFlashBundle { + val qspi: HeterogeneousBag[SPIPortIO] + } -trait HasPeripherySPIFlashModule extends HasTopLevelNetworksModule { +trait HasPeripherySPIFlashModuleImp extends LazyMultiIOModuleImp with HasPeripherySPIFlashBundle { val outer: HasPeripherySPIFlash - val io: HasPeripherySPIFlashBundle + val qspi = IO(HeterogeneousBag(outer.spiFlashParams.map(new SPIPortIO(_)))) - (io.qspi zip outer.qspi) foreach { case (io, device) => + (qspi zip outer.qspis) foreach { case (io, device) => io <> device.module.io.port } }