periphery: bus api update (#50)
authorHenry Cook <henry@sifive.com>
Thu, 1 Mar 2018 09:15:02 +0000 (01:15 -0800)
committerGitHub <noreply@github.com>
Thu, 1 Mar 2018 09:15:02 +0000 (01:15 -0800)
src/main/scala/devices/gpio/GPIOPeriphery.scala
src/main/scala/devices/i2c/I2CPeriphery.scala
src/main/scala/devices/mockaon/MockAONPeriphery.scala
src/main/scala/devices/pwm/PWMPeriphery.scala
src/main/scala/devices/pwm/PWMPins.scala
src/main/scala/devices/spi/SPIPeriphery.scala
src/main/scala/devices/uart/UARTPeriphery.scala
src/main/scala/devices/uart/UARTPins.scala

index 149f7074d03ed09bd9d54622c335b5fe022066f1..21fb6804b552f5be2167466b72cad3d29a08dc99 100644 (file)
@@ -3,17 +3,18 @@ package sifive.blocks.devices.gpio
 
 import Chisel._
 import freechips.rocketchip.config.Field
-import freechips.rocketchip.coreplex.{HasPeripheryBus, HasInterruptBus}
+import freechips.rocketchip.subsystem.BaseSubsystem
 import freechips.rocketchip.diplomacy.{LazyModule,LazyModuleImp}
 import freechips.rocketchip.util.HeterogeneousBag
 
 case object PeripheryGPIOKey extends Field[Seq[GPIOParams]]
 
-trait HasPeripheryGPIO extends HasPeripheryBus with HasInterruptBus {
+trait HasPeripheryGPIO { this: BaseSubsystem =>
   val gpioParams = p(PeripheryGPIOKey)
-  val gpios = gpioParams map { params =>
-    val gpio = LazyModule(new TLGPIO(pbus.beatBytes, params))
-    gpio.node := pbus.toVariableWidthSlaves
+  val gpios = gpioParams.zipWithIndex.map { case(params, i) =>
+    val name = Some(s"gpio_$i")
+    val gpio = LazyModule(new TLGPIO(pbus.beatBytes, params)).suggestName(name)
+    pbus.toVariableWidthSlave(name) { gpio.node }
     ibus.fromSync := gpio.intnode
     gpio
   }
index d4ad9fe1ebaf1ab3d2507de2cb649c79ca1ad3df..a5fbd5438c6a32206fb13225b6c6c34d933ce326 100644 (file)
@@ -3,16 +3,17 @@ package sifive.blocks.devices.i2c
 
 import Chisel._
 import freechips.rocketchip.config.Field
-import freechips.rocketchip.coreplex.{HasPeripheryBus, HasInterruptBus}
+import freechips.rocketchip.subsystem.BaseSubsystem
 import freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp}
 
 case object PeripheryI2CKey extends Field[Seq[I2CParams]]
 
-trait HasPeripheryI2C extends HasPeripheryBus {
+trait HasPeripheryI2C { this: BaseSubsystem =>
   val i2cParams = p(PeripheryI2CKey)
-  val i2c = i2cParams map { params =>
-    val i2c = LazyModule(new TLI2C(pbus.beatBytes, params))
-    i2c.node := pbus.toVariableWidthSlaves
+  val i2c = i2cParams.zipWithIndex.map { case(params, i) =>
+    val name = Some(s"i2c_$i")
+    val i2c = LazyModule(new TLI2C(pbus.beatBytes, params)).suggestName(name)
+    pbus.toVariableWidthSlave(name) { i2c.node }
     ibus.fromSync := i2c.intnode
     i2c
   }
index f7f563bc77e9d8fea1f5188fff3782c22abf10a5..0aa4aa781aff1b70ca713ce980e2bb0b6b6172b4 100644 (file)
@@ -3,26 +3,22 @@ package sifive.blocks.devices.mockaon
 
 import Chisel._
 import freechips.rocketchip.config.Field
-import freechips.rocketchip.util.SynchronizerShiftReg
-import freechips.rocketchip.coreplex.{HasPeripheryBus, HasInterruptBus}
 import freechips.rocketchip.devices.debug.HasPeripheryDebug
-import freechips.rocketchip.devices.tilelink.HasPeripheryClint
+import freechips.rocketchip.devices.tilelink.HasPeripheryCLINT
 import freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp}
-import freechips.rocketchip.tilelink.{TLAsyncCrossingSource}
 import freechips.rocketchip.interrupts._
-import freechips.rocketchip.util.ResetCatchAndSync
+import freechips.rocketchip.subsystem.BaseSubsystem
+import freechips.rocketchip.tilelink.{TLAsyncCrossingSource}
+import freechips.rocketchip.util.{ResetCatchAndSync, SynchronizerShiftReg}
 
 case object PeripheryMockAONKey extends Field[MockAONParams]
 
-trait HasPeripheryMockAON extends HasPeripheryBus
-    with HasInterruptBus
-    with HasPeripheryClint
-    with HasPeripheryDebug {
+trait HasPeripheryMockAON extends HasPeripheryCLINT with HasPeripheryDebug { this: BaseSubsystem =>
   // We override the clock & Reset here so that all synchronizers, etc
   // are in the proper clock domain.
   val mockAONParams= p(PeripheryMockAONKey)
   val aon = LazyModule(new MockAONWrapper(pbus.beatBytes, mockAONParams))
-  aon.node := TLAsyncCrossingSource() := pbus.toVariableWidthSlaves
+  pbus.toVariableWidthSlave(Some("aon")) { aon.node := TLAsyncCrossingSource() }
   ibus.fromSync := IntSyncCrossingSink() := aon.intnode
 }
 
index 00043ab97abd245c014fa5cc5127e23b7de2f99f..e098258c353ca682a4d2099c6521eac9f57c13e2 100644 (file)
@@ -3,7 +3,7 @@ package sifive.blocks.devices.pwm
 
 import Chisel._
 import freechips.rocketchip.config.Field
-import freechips.rocketchip.coreplex.{HasPeripheryBus, HasInterruptBus}
+import freechips.rocketchip.subsystem.BaseSubsystem
 import freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp}
 import freechips.rocketchip.util.HeterogeneousBag
 import sifive.blocks.devices.pinctrl.{Pin}
@@ -16,11 +16,12 @@ class PWMPortIO(val c: PWMParams) extends Bundle {
 
 case object PeripheryPWMKey extends Field[Seq[PWMParams]]
 
-trait HasPeripheryPWM extends HasPeripheryBus with HasInterruptBus {
+trait HasPeripheryPWM { this: BaseSubsystem =>
   val pwmParams = p(PeripheryPWMKey)
-  val pwms = pwmParams map { params =>
-    val pwm = LazyModule(new TLPWM(pbus.beatBytes, params))
-    pwm.node := pbus.toVariableWidthSlaves
+  val pwms = pwmParams.zipWithIndex.map { case(params, i) =>
+    val name = Some(s"pwm_$i")
+    val pwm = LazyModule(new TLPWM(pbus.beatBytes, params)).suggestName(name)
+    pbus.toVariableWidthSlave(name) { pwm.node }
     ibus.fromSync := pwm.intnode
     pwm
   }
index 03acc902dad5bb77c5c872395c28f3f59695f095..aa7e032694d4aaf76ddf100a6264fbe86a2f8a30 100644 (file)
@@ -2,10 +2,6 @@
 package sifive.blocks.devices.pwm
 
 import Chisel._
-import freechips.rocketchip.config.Field
-import freechips.rocketchip.coreplex.{HasPeripheryBus, HasInterruptBus}
-import freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp}
-import freechips.rocketchip.util.HeterogeneousBag
 import sifive.blocks.devices.pinctrl.{Pin}
 
 class PWMSignals[T <: Data] (pingen: ()=> T, val c: PWMParams) extends Bundle {
index dd76d15db4df1ca8149bef39a53c55f0b8cb2478..37fe3d9081beff59aa9106bc287b09c6acc952c9 100644 (file)
@@ -3,18 +3,19 @@ package sifive.blocks.devices.spi
 
 import Chisel._
 import freechips.rocketchip.config.Field
-import freechips.rocketchip.coreplex.{HasPeripheryBus, HasInterruptBus}
+import freechips.rocketchip.subsystem.BaseSubsystem
 import freechips.rocketchip.diplomacy.{LazyModule,LazyModuleImp,BufferParams}
 import freechips.rocketchip.tilelink.{TLFragmenter,TLBuffer}
 import freechips.rocketchip.util.HeterogeneousBag
 
 case object PeripherySPIKey extends Field[Seq[SPIParams]]
 
-trait HasPeripherySPI extends HasPeripheryBus with HasInterruptBus {
+trait HasPeripherySPI { this: BaseSubsystem =>
   val spiParams = p(PeripherySPIKey)  
-  val spis = spiParams map { params =>
-    val spi = LazyModule(new TLSPI(pbus.beatBytes, params))
-    spi.rnode := pbus.toVariableWidthSlaves
+  val spis = spiParams.zipWithIndex.map { case(params, i) =>
+    val name = Some(s"spi_$i")
+    val spi = LazyModule(new TLSPI(pbus.beatBytes, params)).suggestName(name)
+    pbus.toVariableWidthSlave(name) { spi.rnode }
     ibus.fromSync := spi.intnode
     spi
   }
@@ -36,15 +37,16 @@ trait HasPeripherySPIModuleImp extends LazyModuleImp with HasPeripherySPIBundle
 
 case object PeripherySPIFlashKey extends Field[Seq[SPIFlashParams]]
 
-trait HasPeripherySPIFlash extends HasPeripheryBus with HasInterruptBus {
+trait HasPeripherySPIFlash { this: BaseSubsystem =>
   val spiFlashParams = p(PeripherySPIFlashKey)  
-  val qspis = spiFlashParams map { params =>
+  val qspis = spiFlashParams.zipWithIndex.map { case(params, i) =>
+    val name = Some(s"qspi_$i")
     val qspi = LazyModule(new TLSPIFlash(pbus.beatBytes, params))
-    qspi.rnode := pbus.toVariableWidthSlaves
-    (qspi.fnode
-      := TLFragmenter(1, pbus.blockBytes)
-      := TLBuffer(BufferParams(params.fBufferDepth), BufferParams.none)
-      := pbus.toFixedWidthSlaves)
+    pbus.toVariableWidthSlave(name) { qspi.rnode }
+    qspi.fnode := pbus.toFixedWidthSlave(name) {
+      TLFragmenter(1, pbus.blockBytes) :=
+        TLBuffer(BufferParams(params.fBufferDepth), BufferParams.none)
+    }
     ibus.fromSync := qspi.intnode
     qspi
   }
index d1db77b9d4ab222b10f84dc012b14e09dc52a9db..6ccc9e76562ae0db77ffa624528524b449003b4f 100644 (file)
@@ -4,17 +4,18 @@ package sifive.blocks.devices.uart
 import Chisel._
 import chisel3.experimental.{withClockAndReset}
 import freechips.rocketchip.config.Field
-import freechips.rocketchip.coreplex.{HasPeripheryBus, PeripheryBusKey, HasInterruptBus}
 import freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp}
+import freechips.rocketchip.subsystem.{BaseSubsystem, PeripheryBusKey}
 
 case object PeripheryUARTKey extends Field[Seq[UARTParams]]
 
-trait HasPeripheryUART extends HasPeripheryBus with HasInterruptBus {
+trait HasPeripheryUART { this: BaseSubsystem =>
   private val divinit = (p(PeripheryBusKey).frequency / 115200).toInt
   val uartParams = p(PeripheryUARTKey).map(_.copy(divisorInit = divinit))
-  val uarts = uartParams map { params =>
-    val uart = LazyModule(new TLUART(pbus.beatBytes, params))
-    uart.node := pbus.toVariableWidthSlaves
+  val uarts = uartParams.zipWithIndex.map { case(params, i) =>
+    val name = Some(s"uart_$i")
+    val uart = LazyModule(new TLUART(pbus.beatBytes, params)).suggestName(name)
+    pbus.toVariableWidthSlave(name) { uart.node }
     ibus.fromSync := uart.intnode
     uart
   }
index 4201f90d7b164ec2442224452116041b7920d8b0..aeb3632cbf73acad9e1b49acb6a6884627113b6c 100644 (file)
@@ -3,10 +3,7 @@ package sifive.blocks.devices.uart
 
 import Chisel._
 import chisel3.experimental.{withClockAndReset}
-import freechips.rocketchip.config.Field
 import freechips.rocketchip.util.SyncResetSynchronizerShiftReg
-import freechips.rocketchip.coreplex.{HasPeripheryBus, PeripheryBusKey, HasInterruptBus}
-import freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp}
 import sifive.blocks.devices.pinctrl.{Pin}
 
 class UARTSignals[T <: Data] (pingen: () => T) extends Bundle {