1
0

periphery: bus api update (#50)

This commit is contained in:
Henry Cook 2018-03-01 01:15:02 -08:00 committed by GitHub
parent 3dee152775
commit 00fbfb6dd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 44 additions and 49 deletions

View File

@ -3,17 +3,18 @@ package sifive.blocks.devices.gpio
import Chisel._ import Chisel._
import freechips.rocketchip.config.Field 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.diplomacy.{LazyModule,LazyModuleImp}
import freechips.rocketchip.util.HeterogeneousBag import freechips.rocketchip.util.HeterogeneousBag
case object PeripheryGPIOKey extends Field[Seq[GPIOParams]] case object PeripheryGPIOKey extends Field[Seq[GPIOParams]]
trait HasPeripheryGPIO extends HasPeripheryBus with HasInterruptBus { trait HasPeripheryGPIO { this: BaseSubsystem =>
val gpioParams = p(PeripheryGPIOKey) val gpioParams = p(PeripheryGPIOKey)
val gpios = gpioParams map { params => val gpios = gpioParams.zipWithIndex.map { case(params, i) =>
val gpio = LazyModule(new TLGPIO(pbus.beatBytes, params)) val name = Some(s"gpio_$i")
gpio.node := pbus.toVariableWidthSlaves val gpio = LazyModule(new TLGPIO(pbus.beatBytes, params)).suggestName(name)
pbus.toVariableWidthSlave(name) { gpio.node }
ibus.fromSync := gpio.intnode ibus.fromSync := gpio.intnode
gpio gpio
} }

View File

@ -3,16 +3,17 @@ package sifive.blocks.devices.i2c
import Chisel._ import Chisel._
import freechips.rocketchip.config.Field 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.diplomacy.{LazyModule, LazyModuleImp}
case object PeripheryI2CKey extends Field[Seq[I2CParams]] case object PeripheryI2CKey extends Field[Seq[I2CParams]]
trait HasPeripheryI2C extends HasPeripheryBus { trait HasPeripheryI2C { this: BaseSubsystem =>
val i2cParams = p(PeripheryI2CKey) val i2cParams = p(PeripheryI2CKey)
val i2c = i2cParams map { params => val i2c = i2cParams.zipWithIndex.map { case(params, i) =>
val i2c = LazyModule(new TLI2C(pbus.beatBytes, params)) val name = Some(s"i2c_$i")
i2c.node := pbus.toVariableWidthSlaves val i2c = LazyModule(new TLI2C(pbus.beatBytes, params)).suggestName(name)
pbus.toVariableWidthSlave(name) { i2c.node }
ibus.fromSync := i2c.intnode ibus.fromSync := i2c.intnode
i2c i2c
} }

View File

@ -3,26 +3,22 @@ package sifive.blocks.devices.mockaon
import Chisel._ import Chisel._
import freechips.rocketchip.config.Field 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.debug.HasPeripheryDebug
import freechips.rocketchip.devices.tilelink.HasPeripheryClint import freechips.rocketchip.devices.tilelink.HasPeripheryCLINT
import freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp} import freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp}
import freechips.rocketchip.tilelink.{TLAsyncCrossingSource}
import freechips.rocketchip.interrupts._ 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] case object PeripheryMockAONKey extends Field[MockAONParams]
trait HasPeripheryMockAON extends HasPeripheryBus trait HasPeripheryMockAON extends HasPeripheryCLINT with HasPeripheryDebug { this: BaseSubsystem =>
with HasInterruptBus
with HasPeripheryClint
with HasPeripheryDebug {
// We override the clock & Reset here so that all synchronizers, etc // We override the clock & Reset here so that all synchronizers, etc
// are in the proper clock domain. // are in the proper clock domain.
val mockAONParams= p(PeripheryMockAONKey) val mockAONParams= p(PeripheryMockAONKey)
val aon = LazyModule(new MockAONWrapper(pbus.beatBytes, mockAONParams)) 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 ibus.fromSync := IntSyncCrossingSink() := aon.intnode
} }

View File

@ -3,7 +3,7 @@ package sifive.blocks.devices.pwm
import Chisel._ import Chisel._
import freechips.rocketchip.config.Field 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.diplomacy.{LazyModule, LazyModuleImp}
import freechips.rocketchip.util.HeterogeneousBag import freechips.rocketchip.util.HeterogeneousBag
import sifive.blocks.devices.pinctrl.{Pin} import sifive.blocks.devices.pinctrl.{Pin}
@ -16,11 +16,12 @@ class PWMPortIO(val c: PWMParams) extends Bundle {
case object PeripheryPWMKey extends Field[Seq[PWMParams]] case object PeripheryPWMKey extends Field[Seq[PWMParams]]
trait HasPeripheryPWM extends HasPeripheryBus with HasInterruptBus { trait HasPeripheryPWM { this: BaseSubsystem =>
val pwmParams = p(PeripheryPWMKey) val pwmParams = p(PeripheryPWMKey)
val pwms = pwmParams map { params => val pwms = pwmParams.zipWithIndex.map { case(params, i) =>
val pwm = LazyModule(new TLPWM(pbus.beatBytes, params)) val name = Some(s"pwm_$i")
pwm.node := pbus.toVariableWidthSlaves val pwm = LazyModule(new TLPWM(pbus.beatBytes, params)).suggestName(name)
pbus.toVariableWidthSlave(name) { pwm.node }
ibus.fromSync := pwm.intnode ibus.fromSync := pwm.intnode
pwm pwm
} }

View File

@ -2,10 +2,6 @@
package sifive.blocks.devices.pwm package sifive.blocks.devices.pwm
import Chisel._ 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} import sifive.blocks.devices.pinctrl.{Pin}
class PWMSignals[T <: Data] (pingen: ()=> T, val c: PWMParams) extends Bundle { class PWMSignals[T <: Data] (pingen: ()=> T, val c: PWMParams) extends Bundle {

View File

@ -3,18 +3,19 @@ package sifive.blocks.devices.spi
import Chisel._ import Chisel._
import freechips.rocketchip.config.Field 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.diplomacy.{LazyModule,LazyModuleImp,BufferParams}
import freechips.rocketchip.tilelink.{TLFragmenter,TLBuffer} import freechips.rocketchip.tilelink.{TLFragmenter,TLBuffer}
import freechips.rocketchip.util.HeterogeneousBag import freechips.rocketchip.util.HeterogeneousBag
case object PeripherySPIKey extends Field[Seq[SPIParams]] case object PeripherySPIKey extends Field[Seq[SPIParams]]
trait HasPeripherySPI extends HasPeripheryBus with HasInterruptBus { trait HasPeripherySPI { this: BaseSubsystem =>
val spiParams = p(PeripherySPIKey) val spiParams = p(PeripherySPIKey)
val spis = spiParams map { params => val spis = spiParams.zipWithIndex.map { case(params, i) =>
val spi = LazyModule(new TLSPI(pbus.beatBytes, params)) val name = Some(s"spi_$i")
spi.rnode := pbus.toVariableWidthSlaves val spi = LazyModule(new TLSPI(pbus.beatBytes, params)).suggestName(name)
pbus.toVariableWidthSlave(name) { spi.rnode }
ibus.fromSync := spi.intnode ibus.fromSync := spi.intnode
spi spi
} }
@ -36,15 +37,16 @@ trait HasPeripherySPIModuleImp extends LazyModuleImp with HasPeripherySPIBundle
case object PeripherySPIFlashKey extends Field[Seq[SPIFlashParams]] case object PeripherySPIFlashKey extends Field[Seq[SPIFlashParams]]
trait HasPeripherySPIFlash extends HasPeripheryBus with HasInterruptBus { trait HasPeripherySPIFlash { this: BaseSubsystem =>
val spiFlashParams = p(PeripherySPIFlashKey) 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)) val qspi = LazyModule(new TLSPIFlash(pbus.beatBytes, params))
qspi.rnode := pbus.toVariableWidthSlaves pbus.toVariableWidthSlave(name) { qspi.rnode }
(qspi.fnode qspi.fnode := pbus.toFixedWidthSlave(name) {
:= TLFragmenter(1, pbus.blockBytes) TLFragmenter(1, pbus.blockBytes) :=
:= TLBuffer(BufferParams(params.fBufferDepth), BufferParams.none) TLBuffer(BufferParams(params.fBufferDepth), BufferParams.none)
:= pbus.toFixedWidthSlaves) }
ibus.fromSync := qspi.intnode ibus.fromSync := qspi.intnode
qspi qspi
} }

View File

@ -4,17 +4,18 @@ package sifive.blocks.devices.uart
import Chisel._ import Chisel._
import chisel3.experimental.{withClockAndReset} import chisel3.experimental.{withClockAndReset}
import freechips.rocketchip.config.Field import freechips.rocketchip.config.Field
import freechips.rocketchip.coreplex.{HasPeripheryBus, PeripheryBusKey, HasInterruptBus}
import freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp} import freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp}
import freechips.rocketchip.subsystem.{BaseSubsystem, PeripheryBusKey}
case object PeripheryUARTKey extends Field[Seq[UARTParams]] 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 private val divinit = (p(PeripheryBusKey).frequency / 115200).toInt
val uartParams = p(PeripheryUARTKey).map(_.copy(divisorInit = divinit)) val uartParams = p(PeripheryUARTKey).map(_.copy(divisorInit = divinit))
val uarts = uartParams map { params => val uarts = uartParams.zipWithIndex.map { case(params, i) =>
val uart = LazyModule(new TLUART(pbus.beatBytes, params)) val name = Some(s"uart_$i")
uart.node := pbus.toVariableWidthSlaves val uart = LazyModule(new TLUART(pbus.beatBytes, params)).suggestName(name)
pbus.toVariableWidthSlave(name) { uart.node }
ibus.fromSync := uart.intnode ibus.fromSync := uart.intnode
uart uart
} }

View File

@ -3,10 +3,7 @@ package sifive.blocks.devices.uart
import Chisel._ import Chisel._
import chisel3.experimental.{withClockAndReset} import chisel3.experimental.{withClockAndReset}
import freechips.rocketchip.config.Field
import freechips.rocketchip.util.SyncResetSynchronizerShiftReg import freechips.rocketchip.util.SyncResetSynchronizerShiftReg
import freechips.rocketchip.coreplex.{HasPeripheryBus, PeripheryBusKey, HasInterruptBus}
import freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp}
import sifive.blocks.devices.pinctrl.{Pin} import sifive.blocks.devices.pinctrl.{Pin}
class UARTSignals[T <: Data] (pingen: () => T) extends Bundle { class UARTSignals[T <: Data] (pingen: () => T) extends Bundle {