allow bundle content params to be specified via a def (#29)
authorHenry Cook <henry@sifive.com>
Wed, 2 Aug 2017 18:46:27 +0000 (11:46 -0700)
committerGitHub <noreply@github.com>
Wed, 2 Aug 2017 18:46:27 +0000 (11:46 -0700)
src/main/scala/devices/gpio/GPIO.scala
src/main/scala/devices/pwm/PWM.scala
src/main/scala/devices/uart/UARTPeriphery.scala

index e7a48299d132df91965224608386f61812b810f4..2bb04fe2a53a3760ebd047ef24495ef07956298d 100644 (file)
@@ -82,7 +82,7 @@ class GPIOPortIO(c: GPIOParams) extends GenericParameterizedBundle(c) {
 // It would be better if the IOF were here and
 // we could do the pinmux inside.
 trait HasGPIOBundleContents extends Bundle {
-  val params: GPIOParams
+  def params: GPIOParams
   val port = new GPIOPortIO(params)
 }
 
index 044d1bd589bd0c06d800c9e723bc2aa46561e0ed..3d35d81cf49fcbf5a8a64bc5a07e28a9204f2611 100644 (file)
@@ -44,7 +44,7 @@ case class PWMParams(
   cmpWidth: Int = 16)
 
 trait HasPWMBundleContents extends Bundle {
-  val params: PWMParams
+  def params: PWMParams
   val gpio = Vec(params.ncmp, Bool()).asOutput
 }
 
index cb79845e4879f811dceda48ae6f1a3112537c69a..00e5fdd856e5003fda3062050b8fe172a07d85f0 100644 (file)
@@ -12,10 +12,10 @@ import sifive.blocks.util.ShiftRegisterInit
 case object PeripheryUARTKey extends Field[Seq[UARTParams]]
 
 trait HasPeripheryUART extends HasPeripheryBus with HasInterruptBus {
-  val uartParams = p(PeripheryUARTKey)
-  val divinit = (p(PeripheryBusParams).frequency / 115200).toInt
+  private val divinit = (p(PeripheryBusParams).frequency / 115200).toInt
+  val uartParams = p(PeripheryUARTKey).map(_.copy(divisorInit = divinit))
   val uarts = uartParams map { params =>
-    val uart = LazyModule(new TLUART(pbus.beatBytes, params.copy(divisorInit = divinit)))
+    val uart = LazyModule(new TLUART(pbus.beatBytes, params))
     uart.node := pbus.toVariableWidthSlaves
     ibus.fromSync := uart.intnode
     uart