153 lines
5.2 KiB
Scala
153 lines
5.2 KiB
Scala
package chipyard.config
|
|
|
|
import chisel3._
|
|
import chisel3.util.{log2Up}
|
|
|
|
import freechips.rocketchip.config.{Field, Parameters, Config, View}
|
|
import freechips.rocketchip.subsystem.{SystemBusKey, RocketTilesKey, WithRoccExample, WithNMemoryChannels, WithNBigCores, WithRV32, CacheBlockBytes}
|
|
import freechips.rocketchip.diplomacy.{LazyModule, ValName}
|
|
import freechips.rocketchip.devices.tilelink.BootROMParams
|
|
import freechips.rocketchip.devices.debug.{Debug}
|
|
import freechips.rocketchip.tile.{XLen, BuildRoCC, TileKey, LazyRoCC, RocketTileParams, MaxHartIdBits}
|
|
import freechips.rocketchip.rocket.{RocketCoreParams, MulDivParams, DCacheParams, ICacheParams}
|
|
import freechips.rocketchip.util.{AsyncResetReg}
|
|
|
|
import boom.common.{BoomTilesKey}
|
|
import ariane.ArianeTilesKey
|
|
import testchipip._
|
|
|
|
import hwacha.{Hwacha}
|
|
|
|
import sifive.blocks.devices.gpio._
|
|
import sifive.blocks.devices.uart._
|
|
import sifive.blocks.devices.spi._
|
|
|
|
import chipyard.{BuildTop, BuildSystem}
|
|
import chipyard.TilesKey
|
|
import chipyard.TileSeq._
|
|
|
|
/**
|
|
* TODO: Why do we need this?
|
|
*/
|
|
object ConfigValName {
|
|
implicit val valName = ValName("TestHarness")
|
|
}
|
|
import ConfigValName._
|
|
|
|
// -----------------------
|
|
// Common Config Fragments
|
|
// -----------------------
|
|
|
|
class WithBootROM extends Config((site, here, up) => {
|
|
case BootROMParams => BootROMParams(
|
|
contentFileName = s"./bootrom/bootrom.rv${site(XLen)}.img")
|
|
})
|
|
|
|
// DOC include start: gpio config fragment
|
|
class WithGPIO extends Config((site, here, up) => {
|
|
case PeripheryGPIOKey => Seq(
|
|
GPIOParams(address = 0x10012000, width = 4, includeIOF = false))
|
|
})
|
|
// DOC include end: gpio config fragment
|
|
|
|
class WithUART extends Config((site, here, up) => {
|
|
case PeripheryUARTKey => Seq(
|
|
UARTParams(address = 0x54000000L, nTxEntries = 256, nRxEntries = 256))
|
|
})
|
|
|
|
class WithSPIFlash(size: BigInt = 0x10000000) extends Config((site, here, up) => {
|
|
// Note: the default size matches freedom with the addresses below
|
|
case PeripherySPIFlashKey => Seq(
|
|
SPIFlashParams(rAddress = 0x10040000, fAddress = 0x20000000, fSize = size))
|
|
})
|
|
|
|
class WithL2TLBs(entries: Int) extends Config((site, here, up) => {
|
|
case TilesKey(tilesKey) => up(tilesKey) tileMap (tile => tile.copy(
|
|
core = tile.core.copy(nL2TLBEntries = entries)
|
|
))
|
|
})
|
|
|
|
class WithTracegenSystem extends Config((site, here, up) => {
|
|
case BuildSystem => (p: Parameters) => LazyModule(new tracegen.TraceGenSystem()(p))
|
|
})
|
|
|
|
class WithRenumberHarts(rocketFirst: Boolean = false) extends Config((site, here, up) => {
|
|
case RocketTilesKey => up(RocketTilesKey, site).zipWithIndex map { case (r, i) =>
|
|
r.copy(hartId = i + (if(rocketFirst) 0 else up(BoomTilesKey, site).length))
|
|
}
|
|
case BoomTilesKey => up(BoomTilesKey, site).zipWithIndex map { case (b, i) =>
|
|
b.copy(hartId = i + (if(rocketFirst) up(RocketTilesKey, site).length else 0))
|
|
}
|
|
case MaxHartIdBits => log2Up(up(BoomTilesKey, site).size + up(RocketTilesKey, site).size)
|
|
})
|
|
|
|
/**
|
|
* Map from a hartId to a particular RoCC accelerator
|
|
*/
|
|
case object MultiRoCCKey extends Field[Map[Int, Seq[Parameters => LazyRoCC]]](Map.empty[Int, Seq[Parameters => LazyRoCC]])
|
|
|
|
/**
|
|
* Config fragment to enable different RoCCs based on the hartId
|
|
*/
|
|
class WithMultiRoCC extends Config((site, here, up) => {
|
|
case BuildRoCC => site(MultiRoCCKey).getOrElse(site(TileKey).hartId, Nil)
|
|
})
|
|
|
|
/**
|
|
* Config fragment to add Hwachas to cores based on hart
|
|
*
|
|
* For ex:
|
|
* Core 0, 1, 2, 3 have been defined earlier
|
|
* with hartIds of 0, 1, 2, 3 respectively
|
|
* And you call WithMultiRoCCHwacha(0,1)
|
|
* Then Core 0 and 1 will get a Hwacha
|
|
*
|
|
* @param harts harts to specify which will get a Hwacha
|
|
*/
|
|
class WithMultiRoCCHwacha(harts: Int*) extends Config((site, here, up) => {
|
|
case MultiRoCCKey => {
|
|
require(harts.max <= ((up(RocketTilesKey, site).length + up(BoomTilesKey, site).length) - 1))
|
|
up(MultiRoCCKey, site) ++ harts.distinct.map{ i =>
|
|
(i -> Seq((p: Parameters) => {
|
|
LazyModule(new Hwacha()(p)).suggestName("hwacha")
|
|
}))
|
|
}
|
|
}
|
|
})
|
|
|
|
|
|
/**
|
|
* Config fragment to add a small Rocket core to the system as a "control" core.
|
|
* Used as an example of a PMU core.
|
|
*/
|
|
class WithControlCore extends Config((site, here, up) => {
|
|
case RocketTilesKey => up(RocketTilesKey, site) :+
|
|
RocketTileParams(
|
|
core = RocketCoreParams(
|
|
useVM = false,
|
|
fpu = None,
|
|
mulDiv = Some(MulDivParams(mulUnroll = 8))),
|
|
btb = None,
|
|
dcache = Some(DCacheParams(
|
|
rowBits = site(SystemBusKey).beatBits,
|
|
nSets = 64,
|
|
nWays = 1,
|
|
nTLBEntries = 4,
|
|
nMSHRs = 0,
|
|
blockBytes = site(CacheBlockBytes))),
|
|
icache = Some(ICacheParams(
|
|
rowBits = site(SystemBusKey).beatBits,
|
|
nSets = 64,
|
|
nWays = 1,
|
|
nTLBEntries = 4,
|
|
blockBytes = site(CacheBlockBytes))),
|
|
hartId = up(RocketTilesKey, site).size + up(BoomTilesKey, site).size
|
|
)
|
|
case MaxHartIdBits => log2Up(up(RocketTilesKey, site).size + up(BoomTilesKey, site).size + 1)
|
|
})
|
|
|
|
class WithTraceIO extends Config((site, here, up) => {
|
|
case BoomTilesKey => up(BoomTilesKey) map (tile => tile.copy(trace = true))
|
|
case ArianeTilesKey => up(ArianeTilesKey) map (tile => tile.copy(trace = true))
|
|
case TracePortKey => Some(TracePortParams())
|
|
}) |