1
0

diplomacy: update to new API (#40)

This commit is contained in:
Wesley W. Terpstra 2017-09-27 16:33:18 -07:00 committed by GitHub
parent fe65a87c5c
commit 4fcf349adb
16 changed files with 50 additions and 58 deletions

View File

@ -2,6 +2,7 @@
package sifive.blocks.devices.gpio package sifive.blocks.devices.gpio
import Chisel._ import Chisel._
import chisel3.experimental.MultiIOModule
import sifive.blocks.devices.pinctrl.{PinCtrl, Pin, BasePin, EnhancedPin, EnhancedPinCtrl} import sifive.blocks.devices.pinctrl.{PinCtrl, Pin, BasePin, EnhancedPin, EnhancedPinCtrl}
import freechips.rocketchip.config.Parameters import freechips.rocketchip.config.Parameters
import freechips.rocketchip.util.SynchronizerShiftReg import freechips.rocketchip.util.SynchronizerShiftReg
@ -87,7 +88,7 @@ trait HasGPIOBundleContents extends Bundle {
val port = new GPIOPortIO(params) val port = new GPIOPortIO(params)
} }
trait HasGPIOModuleContents extends Module with HasRegMap { trait HasGPIOModuleContents extends MultiIOModule with HasRegMap {
val io: HasGPIOBundleContents val io: HasGPIOBundleContents
val params: GPIOParams val params: GPIOParams
val c = params val c = params

View File

@ -4,7 +4,7 @@ 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.coreplex.{HasPeripheryBus, HasInterruptBus}
import freechips.rocketchip.diplomacy.{LazyModule,LazyMultiIOModuleImp} 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]]
@ -23,7 +23,7 @@ trait HasPeripheryGPIOBundle {
val gpio: HeterogeneousBag[GPIOPortIO] val gpio: HeterogeneousBag[GPIOPortIO]
} }
trait HasPeripheryGPIOModuleImp extends LazyMultiIOModuleImp with HasPeripheryGPIOBundle { trait HasPeripheryGPIOModuleImp extends LazyModuleImp with HasPeripheryGPIOBundle {
val outer: HasPeripheryGPIO val outer: HasPeripheryGPIO
val gpio = IO(HeterogeneousBag(outer.gpioParams.map(new GPIOPortIO(_)))) val gpio = IO(HeterogeneousBag(outer.gpioParams.map(new GPIOPortIO(_))))

View File

@ -42,6 +42,7 @@
package sifive.blocks.devices.i2c package sifive.blocks.devices.i2c
import Chisel._ import Chisel._
import chisel3.experimental.MultiIOModule
import freechips.rocketchip.config._ import freechips.rocketchip.config._
import freechips.rocketchip.regmapper._ import freechips.rocketchip.regmapper._
import freechips.rocketchip.tilelink._ import freechips.rocketchip.tilelink._
@ -64,7 +65,7 @@ trait HasI2CBundleContents extends Bundle {
val port = new I2CPort val port = new I2CPort
} }
trait HasI2CModuleContents extends Module with HasRegMap { trait HasI2CModuleContents extends MultiIOModule with HasRegMap {
val io: HasI2CBundleContents val io: HasI2CBundleContents
val params: I2CParams val params: I2CParams

View File

@ -4,7 +4,7 @@ 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.coreplex.{HasPeripheryBus, HasInterruptBus}
import freechips.rocketchip.diplomacy.{LazyModule, LazyMultiIOModuleImp} import freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp}
case object PeripheryI2CKey extends Field[Seq[I2CParams]] case object PeripheryI2CKey extends Field[Seq[I2CParams]]
@ -22,7 +22,7 @@ trait HasPeripheryI2CBundle {
val i2c: Vec[I2CPort] val i2c: Vec[I2CPort]
} }
trait HasPeripheryI2CModuleImp extends LazyMultiIOModuleImp with HasPeripheryI2CBundle { trait HasPeripheryI2CModuleImp extends LazyModuleImp with HasPeripheryI2CBundle {
val outer: HasPeripheryI2C val outer: HasPeripheryI2C
val i2c = IO(Vec(outer.i2cParams.size, new I2CPort)) val i2c = IO(Vec(outer.i2cParams.size, new I2CPort))

View File

@ -2,6 +2,7 @@
package sifive.blocks.devices.mockaon package sifive.blocks.devices.mockaon
import Chisel._ import Chisel._
import chisel3.experimental.MultiIOModule
import freechips.rocketchip.config.Parameters import freechips.rocketchip.config.Parameters
import freechips.rocketchip.regmapper._ import freechips.rocketchip.regmapper._
import freechips.rocketchip.tilelink._ import freechips.rocketchip.tilelink._
@ -49,7 +50,7 @@ trait HasMockAONBundleContents extends Bundle {
val resetCauses = new ResetCauses().asInput val resetCauses = new ResetCauses().asInput
} }
trait HasMockAONModuleContents extends Module with HasRegMap { trait HasMockAONModuleContents extends MultiIOModule with HasRegMap {
val io: HasMockAONBundleContents val io: HasMockAONBundleContents
val params: MockAONParams val params: MockAONParams
val c = params val c = params

View File

@ -7,7 +7,7 @@ import freechips.rocketchip.util.SynchronizerShiftReg
import freechips.rocketchip.coreplex.{HasPeripheryBus, HasInterruptBus} 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, LazyMultiIOModuleImp} import freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp}
import freechips.rocketchip.tilelink.{IntXing, TLAsyncCrossingSource} import freechips.rocketchip.tilelink.{IntXing, TLAsyncCrossingSource}
import freechips.rocketchip.util.ResetCatchAndSync import freechips.rocketchip.util.ResetCatchAndSync
@ -32,7 +32,7 @@ trait HasPeripheryMockAONBundle {
} }
} }
trait HasPeripheryMockAONModuleImp extends LazyMultiIOModuleImp with HasPeripheryMockAONBundle { trait HasPeripheryMockAONModuleImp extends LazyModuleImp with HasPeripheryMockAONBundle {
val outer: HasPeripheryMockAON val outer: HasPeripheryMockAON
val aon = IO(new MockAONWrapperBundle) val aon = IO(new MockAONWrapperBundle)

View File

@ -30,8 +30,6 @@ class MockAONWrapperBundle extends Bundle {
class MockAONWrapper(w: Int, c: MockAONParams)(implicit p: Parameters) extends LazyModule { class MockAONWrapper(w: Int, c: MockAONParams)(implicit p: Parameters) extends LazyModule {
val node = TLAsyncInputNode()
val intnode = IntOutputNode()
val aon = LazyModule(new TLMockAON(w, c)) val aon = LazyModule(new TLMockAON(w, c))
// We only need to isolate the signals // We only need to isolate the signals
@ -45,20 +43,18 @@ class MockAONWrapper(w: Int, c: MockAONParams)(implicit p: Parameters) extends L
val isolation = LazyModule(new TLIsolation(fOut = isoOut, fIn = isoIn)) val isolation = LazyModule(new TLIsolation(fOut = isoOut, fIn = isoIn))
val crossing = LazyModule(new TLAsyncCrossingSink(depth = 1)) val crossing = LazyModule(new TLAsyncCrossingSink(depth = 1))
isolation.node := node val node: TLAsyncInwardNode = isolation.node
crossing.node := isolation.node crossing.node := isolation.node
val crossing_monitor = (aon.node := crossing.node) aon.node := crossing.node
// crossing lives outside in Periphery // crossing lives outside in Periphery
intnode := aon.intnode val intnode: IntOutwardNode = aon.intnode
lazy val module = new LazyModuleImp(this) { lazy val module = new LazyModuleImp(this) {
val io = new MockAONWrapperBundle { val io = IO(new MockAONWrapperBundle {
val in = node.bundleIn
val ip = intnode.bundleOut
val rtc = Clock(OUTPUT) val rtc = Clock(OUTPUT)
val ndreset = Bool(INPUT) val ndreset = Bool(INPUT)
} })
val aon_io = aon.module.io val aon_io = aon.module.io
val pins = io.pins val pins = io.pins
@ -122,11 +118,6 @@ class MockAONWrapper(w: Int, c: MockAONParams)(implicit p: Parameters) extends L
crossing.module.clock := lfclk crossing.module.clock := lfclk
crossing.module.reset := crossing_slave_reset crossing.module.reset := crossing_slave_reset
crossing_monitor.foreach { lm =>
lm.module.clock := lfclk
lm.module.reset := crossing_slave_reset
}
// Note that aon.moff.corerst is synchronous // Note that aon.moff.corerst is synchronous
// to aon.module.clock, so this is safe. // to aon.module.clock, so this is safe.
isolation.module.io.iso_out := aon.module.io.moff.corerst isolation.module.io.iso_out := aon.module.io.moff.corerst

View File

@ -2,6 +2,7 @@
package sifive.blocks.devices.pwm package sifive.blocks.devices.pwm
import Chisel._ import Chisel._
import chisel3.experimental.MultiIOModule
import Chisel.ImplicitConversions._ import Chisel.ImplicitConversions._
import freechips.rocketchip.config.Parameters import freechips.rocketchip.config.Parameters
import freechips.rocketchip.regmapper._ import freechips.rocketchip.regmapper._
@ -48,7 +49,7 @@ trait HasPWMBundleContents extends Bundle {
val gpio = Vec(params.ncmp, Bool()).asOutput val gpio = Vec(params.ncmp, Bool()).asOutput
} }
trait HasPWMModuleContents extends Module with HasRegMap { trait HasPWMModuleContents extends MultiIOModule with HasRegMap {
val io: HasPWMBundleContents val io: HasPWMBundleContents
val params: PWMParams val params: PWMParams

View File

@ -4,7 +4,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.coreplex.{HasPeripheryBus, HasInterruptBus}
import freechips.rocketchip.diplomacy.{LazyModule, LazyMultiIOModuleImp} 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}
@ -31,7 +31,7 @@ trait HasPeripheryPWMBundle {
} }
trait HasPeripheryPWMModuleImp extends LazyMultiIOModuleImp with HasPeripheryPWMBundle { trait HasPeripheryPWMModuleImp extends LazyModuleImp with HasPeripheryPWMBundle {
val outer: HasPeripheryPWM val outer: HasPeripheryPWM
val pwm = IO(HeterogeneousBag(outer.pwmParams.map(new PWMPortIO(_)))) val pwm = IO(HeterogeneousBag(outer.pwmParams.map(new PWMPortIO(_))))

View File

@ -4,7 +4,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.coreplex.{HasPeripheryBus, HasInterruptBus}
import freechips.rocketchip.diplomacy.{LazyModule, LazyMultiIOModuleImp} 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}

View File

@ -4,7 +4,7 @@ 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.coreplex.{HasPeripheryBus, HasInterruptBus}
import freechips.rocketchip.diplomacy.{LazyModule,LazyMultiIOModuleImp,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
@ -25,7 +25,7 @@ trait HasPeripherySPIBundle {
} }
trait HasPeripherySPIModuleImp extends LazyMultiIOModuleImp with HasPeripherySPIBundle { trait HasPeripherySPIModuleImp extends LazyModuleImp with HasPeripherySPIBundle {
val outer: HasPeripherySPI val outer: HasPeripherySPI
val spi = IO(HeterogeneousBag(outer.spiParams.map(new SPIPortIO(_)))) val spi = IO(HeterogeneousBag(outer.spiParams.map(new SPIPortIO(_))))
@ -55,7 +55,7 @@ trait HasPeripherySPIFlashBundle {
} }
trait HasPeripherySPIFlashModuleImp extends LazyMultiIOModuleImp with HasPeripherySPIFlashBundle { trait HasPeripherySPIFlashModuleImp extends LazyModuleImp with HasPeripherySPIFlashBundle {
val outer: HasPeripherySPIFlash val outer: HasPeripherySPIFlash
val qspi = IO(HeterogeneousBag(outer.spiFlashParams.map(new SPIPortIO(_)))) val qspi = IO(HeterogeneousBag(outer.spiFlashParams.map(new SPIPortIO(_))))

View File

@ -47,15 +47,12 @@ case class SPIParams(
require(sampleDelay >= 0) require(sampleDelay >= 0)
} }
class SPITopBundle(val i: HeterogeneousBag[Vec[Bool]], val r: HeterogeneousBag[TLBundle]) extends Bundle class SPITopModule(c: SPIParamsBase, outer: TLSPIBase)
class SPITopModule[B <: SPITopBundle](c: SPIParamsBase, bundle: => B, outer: TLSPIBase)
extends LazyModuleImp(outer) { extends LazyModuleImp(outer) {
val io = new Bundle { val io = IO(new Bundle {
val port = new SPIPortIO(c) val port = new SPIPortIO(c)
val tl = bundle })
}
val ctrl = Reg(init = SPIControl.init(c)) val ctrl = Reg(init = SPIControl.init(c))
@ -72,7 +69,8 @@ class SPITopModule[B <: SPITopBundle](c: SPIParamsBase, bundle: => B, outer: TLS
val ie = Reg(init = new SPIInterrupts().fromBits(Bits(0))) val ie = Reg(init = new SPIInterrupts().fromBits(Bits(0)))
val ip = fifo.io.ip val ip = fifo.io.ip
io.tl.i(0)(0) := (ip.txwm && ie.txwm) || (ip.rxwm && ie.rxwm) val (io_int, _) = outer.intnode.out(0)
io_int(0) := (ip.txwm && ie.txwm) || (ip.rxwm && ie.rxwm)
protected val regmapBase = Seq( protected val regmapBase = Seq(
SPICRs.sckdiv -> Seq(RegField(c.divisorBits, ctrl.sck.div)), SPICRs.sckdiv -> Seq(RegField(c.divisorBits, ctrl.sck.div)),
@ -115,7 +113,7 @@ abstract class TLSPIBase(w: Int, c: SPIParamsBase)(implicit p: Parameters) exten
} }
class TLSPI(w: Int, c: SPIParams)(implicit p: Parameters) extends TLSPIBase(w,c)(p) { class TLSPI(w: Int, c: SPIParams)(implicit p: Parameters) extends TLSPIBase(w,c)(p) {
lazy val module = new SPITopModule(c, new SPITopBundle(intnode.bundleOut, rnode.bundleIn), this) { lazy val module = new SPITopModule(c, this) {
mac.io.link <> fifo.io.link mac.io.link <> fifo.io.link
rnode.regmap(regmapBase:_*) rnode.regmap(regmapBase:_*)
} }

View File

@ -41,16 +41,13 @@ case class SPIFlashParams(
require(sampleDelay >= 0) require(sampleDelay >= 0)
} }
class SPIFlashTopBundle(i: HeterogeneousBag[Vec[Bool]], r: HeterogeneousBag[TLBundle], val f: HeterogeneousBag[TLBundle]) extends SPITopBundle(i, r) class SPIFlashTopModule(c: SPIFlashParamsBase, outer: TLSPIFlashBase)
extends SPITopModule(c, outer) {
class SPIFlashTopModule[B <: SPIFlashTopBundle]
(c: SPIFlashParamsBase, bundle: => B, outer: TLSPIFlashBase)
extends SPITopModule(c, bundle, outer) {
val flash = Module(new SPIFlashMap(c)) val flash = Module(new SPIFlashMap(c))
val arb = Module(new SPIArbiter(c, 2)) val arb = Module(new SPIArbiter(c, 2))
private val f = io.tl.f.head private val (f, _) = outer.fnode.in(0)
// Tie unused channels // Tie unused channels
f.b.valid := Bool(false) f.b.valid := Bool(false)
f.c.ready := Bool(true) f.c.ready := Bool(true)
@ -68,7 +65,7 @@ class SPIFlashTopModule[B <: SPIFlashTopBundle]
flash.io.addr.valid := f.a.valid flash.io.addr.valid := f.a.valid
f.a.ready := flash.io.addr.ready f.a.ready := flash.io.addr.ready
f.d.bits := outer.fnode.edgesIn.head.AccessAck(a, flash.io.data.bits) f.d.bits := outer.fnode.edges.in.head.AccessAck(a, flash.io.data.bits)
f.d.valid := flash.io.data.valid f.d.valid := flash.io.data.valid
flash.io.data.ready := f.d.ready flash.io.data.ready := f.d.ready
@ -96,18 +93,19 @@ class SPIFlashTopModule[B <: SPIFlashTopBundle]
abstract class TLSPIFlashBase(w: Int, c: SPIFlashParamsBase)(implicit p: Parameters) extends TLSPIBase(w,c)(p) { abstract class TLSPIFlashBase(w: Int, c: SPIFlashParamsBase)(implicit p: Parameters) extends TLSPIBase(w,c)(p) {
require(isPow2(c.fSize)) require(isPow2(c.fSize))
val fnode = TLManagerNode(1, TLManagerParameters( val fnode = TLManagerNode(Seq(TLManagerPortParameters(
address = Seq(AddressSet(c.fAddress, c.fSize-1)), managers = Seq(TLManagerParameters(
resources = device.reg("mem"), address = Seq(AddressSet(c.fAddress, c.fSize-1)),
regionType = RegionType.UNCACHED, resources = device.reg("mem"),
executable = true, regionType = RegionType.UNCACHED,
supportsGet = TransferSizes(1, 1), executable = true,
fifoId = Some(0))) supportsGet = TransferSizes(1, 1),
fifoId = Some(0))),
beatBytes = 1)))
} }
class TLSPIFlash(w: Int, c: SPIFlashParams)(implicit p: Parameters) extends TLSPIFlashBase(w,c)(p) { class TLSPIFlash(w: Int, c: SPIFlashParams)(implicit p: Parameters) extends TLSPIFlashBase(w,c)(p) {
lazy val module = new SPIFlashTopModule(c, lazy val module = new SPIFlashTopModule(c, this) {
new SPIFlashTopBundle(intnode.bundleOut, rnode.bundleIn, fnode.bundleIn), this) {
arb.io.inner(0) <> flash.io.link arb.io.inner(0) <> flash.io.link
arb.io.inner(1) <> fifo.io.link arb.io.inner(1) <> fifo.io.link

View File

@ -2,6 +2,7 @@
package sifive.blocks.devices.uart package sifive.blocks.devices.uart
import Chisel._ import Chisel._
import chisel3.experimental.MultiIOModule
import freechips.rocketchip.config.Parameters import freechips.rocketchip.config.Parameters
import freechips.rocketchip.regmapper._ import freechips.rocketchip.regmapper._
import freechips.rocketchip.tilelink._ import freechips.rocketchip.tilelink._
@ -198,7 +199,7 @@ class UARTInterrupts extends Bundle {
val txwm = Bool() val txwm = Bool()
} }
trait HasUARTTopModuleContents extends Module with HasUARTParameters with HasRegMap { trait HasUARTTopModuleContents extends MultiIOModule with HasUARTParameters with HasRegMap {
val io: HasUARTTopBundleContents val io: HasUARTTopBundleContents
implicit val p: Parameters implicit val p: Parameters
def params: UARTParams def params: UARTParams

View File

@ -5,7 +5,7 @@ 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.coreplex.{HasPeripheryBus, PeripheryBusKey, HasInterruptBus}
import freechips.rocketchip.diplomacy.{LazyModule, LazyMultiIOModuleImp} import freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp}
case object PeripheryUARTKey extends Field[Seq[UARTParams]] case object PeripheryUARTKey extends Field[Seq[UARTParams]]
@ -29,7 +29,7 @@ trait HasPeripheryUARTBundle {
} }
trait HasPeripheryUARTModuleImp extends LazyMultiIOModuleImp with HasPeripheryUARTBundle { trait HasPeripheryUARTModuleImp extends LazyModuleImp with HasPeripheryUARTBundle {
val outer: HasPeripheryUART val outer: HasPeripheryUART
val uart = IO(Vec(outer.uartParams.size, new UARTPortIO)) val uart = IO(Vec(outer.uartParams.size, new UARTPortIO))

View File

@ -6,7 +6,7 @@ import chisel3.experimental.{withClockAndReset}
import freechips.rocketchip.config.Field 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.coreplex.{HasPeripheryBus, PeripheryBusKey, HasInterruptBus}
import freechips.rocketchip.diplomacy.{LazyModule, LazyMultiIOModuleImp} 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 {