-trait PeripheryUART {
- this: TopNetwork {
- val uartConfigs: Seq[UARTConfig]
- } =>
- val uartDevices = uartConfigs.zipWithIndex.map { case (c, i) =>
- val uart = LazyModule(new UART(c) { override lazy val valName = Some(s"uart$i") } )
- uart.node := TLFragmenter(peripheryBusConfig.beatBytes, cacheBlockBytes)(peripheryBus.node)
- intBus.intnode := uart.intnode
+case object PeripheryUARTKey extends Field[Seq[UARTParams]]
+
+trait HasPeripheryUART extends HasPeripheryBus with HasInterruptBus {
+ 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))
+ uart.node := pbus.toVariableWidthSlaves
+ ibus.fromSync := uart.intnode