1
0

Use HomogenousBag to handle lists of peripherals

Previously we had to do weird things to make non-homogenous
lists of items (e.g. PWM Peripherals where ncmp were different from one to
the other) into a vector. But now Chisel supports a Record type,
and we use the HomogenousBag utility to do this more naturally.
This also deletes all the cruft which was introduced to get
around the limitation which doesn't exist anymore.
This commit is contained in:
Megan Wachs
2017-02-16 17:52:24 -08:00
parent 348bbb97f4
commit 03be9aba67
4 changed files with 7 additions and 27 deletions

View File

@ -5,6 +5,7 @@ import Chisel._
import diplomacy.LazyModule
import uncore.tilelink2._
import rocketchip.{TopNetwork,TopNetworkModule}
import util.HeterogeneousBag
trait PeripherySPI {
this: TopNetwork { val spiConfigs: Seq[SPIConfig] } =>
@ -18,8 +19,7 @@ trait PeripherySPI {
trait PeripherySPIBundle {
this: { val spiConfigs: Seq[SPIConfig] } =>
val spi_bc = spiConfigs.map(_.bc).reduce(_.union(_))
val spis = Vec(spiConfigs.size, new SPIPortIO(spi_bc.toSPIConfig))
val spis = HeterogeneousBag(spiConfigs.map(new SPIPortIO(_)))
}
trait PeripherySPIModule {

View File

@ -30,7 +30,6 @@ trait SPIConfigBase {
lazy val txDepthBits = log2Floor(txDepth) + 1
lazy val rxDepthBits = log2Floor(rxDepth) + 1
lazy val bc = new SPIBundleConfig(csWidth)
}
case class SPIConfig(
@ -49,15 +48,6 @@ case class SPIConfig(
require(sampleDelay >= 0)
}
case class SPIBundleConfig(csWidth: Int)
{
def union(that: SPIBundleConfig): SPIBundleConfig =
SPIBundleConfig(scala.math.max(csWidth, that.csWidth))
def toSPIConfig: SPIConfig = new SPIConfig(rAddress = -1,
csWidth = csWidth)
}
class SPITopBundle(val i: Vec[Vec[Bool]], val r: Vec[TLBundle]) extends Bundle
class SPITopModule[B <: SPITopBundle](c: SPIConfigBase, bundle: => B, outer: TLSPIBase)