Pass Scala Compilation
This commit is contained in:
@@ -22,8 +22,7 @@ import sifive.blocks.devices.uart._
|
||||
import sifive.blocks.devices.spi._
|
||||
|
||||
import chipyard.{BuildTop, BuildSystem}
|
||||
import chipyard.{CoreRegistrar, CoreRegisterEntryBase}
|
||||
import chipyard.hlist
|
||||
import chipyard.GenericConfig
|
||||
|
||||
/**
|
||||
* TODO: Why do we need this?
|
||||
|
||||
@@ -7,7 +7,7 @@ import chisel3._
|
||||
|
||||
import freechips.rocketchip.config.{Parameters, Config, Field, View}
|
||||
import freechips.rocketchip.subsystem.{SystemBusKey, RocketTilesKey, RocketCrossingParams}
|
||||
import freechips.rocketchip.diplomacy.LazyModule
|
||||
import freechips.rocketchip.diplomacy.{LazyModule, ClockCrossingType, ValName}
|
||||
import freechips.rocketchip.diplomaticobjectmodel.logicaltree.LogicalTreeNode
|
||||
import freechips.rocketchip.rocket._
|
||||
import freechips.rocketchip.tile._
|
||||
@@ -16,59 +16,64 @@ import ariane.{ArianeTile, ArianeTilesKey, ArianeCrossingKey, ArianeTileParams}
|
||||
|
||||
// Third-party core entries
|
||||
sealed trait CoreEntryBase {
|
||||
def updateWithFilter(view: View, p: Any => View): (Map[String, Any] => PartialFunction[Any, Seq[AnyRef]])
|
||||
def instantiateTile(crossingLookup: (Seq[RocketCrossingParams], Int) => ClockCrossingType)
|
||||
(implicit logicalTreeNode: LogicalTreeNode, p: Parameters): (CoreParams, ClockCrossingType, BaseTile)
|
||||
def tileParamsLookup(implicit p: Parameters): Seq[TileParams]
|
||||
def updateWithFilter(view: View, p: Any => Boolean): PartialFunction[Any, Map[String, Any] => Any]
|
||||
def instantiateTile(crossingLookup: (Seq[RocketCrossingParams], Int) => Seq[RocketCrossingParams], logicalTreeNode: LogicalTreeNode)
|
||||
(implicit p: Parameters, valName: ValName): Seq[(TileParams, RocketCrossingParams, BaseTile)]
|
||||
}
|
||||
|
||||
class CoreEntry[TileParamsT <: CoreParams, TileT <: BaseTile](
|
||||
class CoreEntry[TileParamsT <: TileParams with Product: TypeTag, TileT <: BaseTile : TypeTag](
|
||||
tk: Field[Seq[TileParamsT]],
|
||||
ck: Field[Seq[RocketCrossingParams]]
|
||||
) extends CoreEntryBase {
|
||||
private val mirror = runtimeMirror(getClass.getClassLoader)
|
||||
private val paramClass = mirror.runtimeClass(typeOf[TileParamsT].typeSymbol.asClass)
|
||||
private val paramNames = Map((paramClass.getDeclaredFields map _.getName).zipWithIndex)
|
||||
private val paramNames = (paramClass.getDeclaredFields map (f => f.getName)).zipWithIndex.toMap
|
||||
private val paramCtr = paramClass.getConstructors.head
|
||||
|
||||
private val tileClass = mirror.runtimeClass(typeOf[TileT].typeSymbol.asClass)
|
||||
private val tileCtr = paramClass.getConstructors.head
|
||||
|
||||
// copy() function in
|
||||
def copyTileParam(tileParam: AnyRef, properties: Map[String, Any]) = {
|
||||
val values = foo.productIterator.toList
|
||||
val indexedProperties = properties map (key => (paramNames(key), properties(key)))
|
||||
def copyTileParam(tileParam: TileParamsT, properties: Map[String, Any]) = {
|
||||
val values = tileParam.productIterator.toList
|
||||
val indexedProperties = properties map { case (key, value) => (paramNames(key), value) }
|
||||
val newValues = (0 until values.size) map
|
||||
(i => if (indexedProperties contains i) indexedProperties(i) else values(i))
|
||||
(i => (if (indexedProperties contains i) indexedProperties(i) else values(i)).asInstanceOf[AnyRef])
|
||||
paramCtr.newInstance(newValues:_*)
|
||||
}
|
||||
|
||||
def updateWithFilter(view: View, p: Any => View) = {
|
||||
case key if (key == tk && p(tk)) => view(tk) map
|
||||
(tile => properties => copyTileParam(tile, properties))
|
||||
def tileParamsLookup(implicit p: Parameters) = p(tk)
|
||||
|
||||
def updateWithFilter(view: View, p: Any => Boolean): PartialFunction[Any, Map[String, Any] => Any] = {
|
||||
case key if (key == tk && p(tk)) => properties => view(tk) map
|
||||
(tile => copyTileParam(tile, properties))
|
||||
}
|
||||
|
||||
def instantiateTile(crossingLookup: (Seq[RocketCrossingParams], Int) => ClockCrossingType)
|
||||
(implicit logicalTreeNode: LogicalTreeNode, p: Parameters) = {
|
||||
def instantiateTile(crossingLookup: (Seq[RocketCrossingParams], Int) => Seq[RocketCrossingParams], logicalTreeNode: LogicalTreeNode)
|
||||
(implicit p: Parameters, valName: ValName) = {
|
||||
val tileParams = p(tk)
|
||||
val crossings = crossingLookup(p(ck), tileParams.size)
|
||||
(tileParams zip crossings) map ((param, crossing) => (
|
||||
param,
|
||||
crossing,
|
||||
LazyModule(tileCtr(param, crossing, PriorityMuxHartIdFromSeq(tileParams), logicalTreeNode))
|
||||
))
|
||||
(tileParams zip crossings) map {
|
||||
case (param, crossing) => (
|
||||
param,
|
||||
crossing,
|
||||
LazyModule(tileCtr.newInstance(param, crossing, PriorityMuxHartIdFromSeq(tileParams), logicalTreeNode).asInstanceOf[TileT])
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Core Generic Config - change properties in the given map
|
||||
class GenericConfig(properties: Map[String, Any], filterFunc: Any => Bool) {
|
||||
val configFunc: (View, View, View) => PartialFunction[Any, Any] = ((site, here, up) => key => {
|
||||
val tiles = CoreManager.cores flatMap _.updateWithFilter(up, filterFunc).lift(key)
|
||||
if (tiles.size == 0) None else Some(tiles map _(properties))
|
||||
}).unlift
|
||||
class GenericConfig(properties: Map[String, Any], filterFunc: Any => Boolean) {
|
||||
val configFunc: (View, View, View) => PartialFunction[Any, Any] = (site, here, up) => scala.Function.unlift((key: Any) => {
|
||||
val tiles = CoreManager.cores flatMap (core => core.updateWithFilter(up, filterFunc).lift(key))
|
||||
if (tiles.size == 0) None else Some(tiles map (tile => tile(properties)))
|
||||
})
|
||||
}
|
||||
|
||||
object GenericConfig {
|
||||
def apply(properties: Map[String, Any], filterFunc: Any => Bool = (_ => true)) =
|
||||
def apply(properties: Map[String, Any], filterFunc: Any => Boolean = (_ => true)) =
|
||||
new GenericConfig(properties, filterFunc).configFunc
|
||||
}
|
||||
|
||||
|
||||
@@ -40,20 +40,23 @@ trait HasChipyardTiles extends HasTiles
|
||||
private val rocketCrossings = perTileOrGlobalSetting(p(RocketCrossingKey), rocketTileParams.size)
|
||||
private val boomCrossings = perTileOrGlobalSetting(p(BoomCrossingKey), boomTileParams.size)
|
||||
|
||||
private val rocketTilesInfo = (rocketTileParams zip rocketCrossings) map ((param, crossing) => (
|
||||
param,
|
||||
crossing,
|
||||
LazyModule(new RocketTile(param, crossing, PriorityMuxHartIdFromSeq(rocketTileParams), logicalTreeNode))
|
||||
))
|
||||
private val boomTilesInfo = (boomTileParams zip boomCrossings) map ((param, crossing) => (
|
||||
param,
|
||||
crossing,
|
||||
LazyModule(new RocketTile(param, crossing, PriorityMuxHartIdFromSeq(boomCrossings), logicalTreeNode))
|
||||
))
|
||||
private val rocketTilesInfo = (rocketTileParams zip rocketCrossings) map {
|
||||
case (param, crossing) => (
|
||||
param,
|
||||
crossing,
|
||||
LazyModule(new RocketTile(param, crossing, PriorityMuxHartIdFromSeq(rocketTileParams), logicalTreeNode))
|
||||
)
|
||||
}
|
||||
private val boomTilesInfo = (boomTileParams zip boomCrossings) map {
|
||||
case (param, crossing) => (
|
||||
param,
|
||||
crossing,
|
||||
LazyModule(new BoomTile(param, crossing, PriorityMuxHartIdFromSeq(boomTileParams), logicalTreeNode))
|
||||
)
|
||||
}
|
||||
|
||||
// TODO: XXX The "tiles" below scan for hartId but it is not in CoreParams. Should that be added in later
|
||||
// revision, or I have to use reflection to get that parameter?
|
||||
val allTilesInfo = rocketTilesInfo ++ boomTilesInfo ++ (CoreManager.cores map _.instantiateTile(perTileOrGlobalSetting _))
|
||||
val allTilesInfo = rocketTilesInfo ++ boomTilesInfo ++
|
||||
(CoreManager.cores flatMap (core => core.instantiateTile(perTileOrGlobalSetting _, logicalTreeNode)))
|
||||
|
||||
// Make a tile and wire its nodes into the system,
|
||||
// according to the specified type of clock crossing.
|
||||
|
||||
@@ -3,7 +3,7 @@ package chipyard
|
||||
import scala.collection.mutable.{LinkedHashSet}
|
||||
|
||||
import freechips.rocketchip.subsystem.{RocketTilesKey}
|
||||
import freechips.rocketchip.tile.{XLen, CoreParams}
|
||||
import freechips.rocketchip.tile.{XLen, TileParams}
|
||||
import freechips.rocketchip.config.{Parameters, Field}
|
||||
import freechips.rocketchip.system.{TestGeneration, RegressionTestSuite, RocketTestSuite}
|
||||
|
||||
@@ -145,9 +145,9 @@ class TestSuiteHelper
|
||||
/**
|
||||
* Add third-party core (including Ariane) tests (asm, bmark, regression)
|
||||
*/
|
||||
def addThirdPartyTestSuites[TileParams <: CoreParams](tilesKey: Field[Seq[TileParams]])(implicit p: Parameters) = {
|
||||
def addThirdPartyTestSuites(tiles: Seq[TileParams])(implicit p: Parameters) = {
|
||||
val xlen = p(XLen)
|
||||
p(tilesKey).asInstanceOf[Seq[CoreParams]].find(_.hartId == 0).map { tileParams =>
|
||||
tiles.find(_.hartId == 0).map { tileParams =>
|
||||
val coreParams = tileParams.core
|
||||
val vm = coreParams.useVM
|
||||
val env = if (vm) List("p","v") else List("p")
|
||||
|
||||
@@ -17,7 +17,7 @@ import freechips.rocketchip.stage.phases.{RocketTestSuiteAnnotation}
|
||||
import freechips.rocketchip.system.{RocketTestSuite, TestGeneration}
|
||||
import freechips.rocketchip.util.HasRocketChipStageUtils
|
||||
|
||||
import chipyard.{TestSuiteHelper, CoreRegistrar}
|
||||
import chipyard.{TestSuiteHelper, CoreManager}
|
||||
|
||||
class AddDefaultTests extends Phase with PreservesAll[Phase] with HasRocketChipStageUtils {
|
||||
// Make sure we run both after RocketChip's version of this phase, and Rocket Chip's annotation emission phase
|
||||
@@ -32,7 +32,7 @@ class AddDefaultTests extends Phase with PreservesAll[Phase] with HasRocketChipS
|
||||
val suiteHelper = new TestSuiteHelper
|
||||
suiteHelper.addRocketTestSuites
|
||||
suiteHelper.addBoomTestSuites
|
||||
CoreRegistrar.cores map suiteHelper.addThirdPartyTestSuites(_.tilesKey)
|
||||
CoreManager.cores map (core => suiteHelper.addThirdPartyTestSuites(core.tileParamsLookup))
|
||||
|
||||
// if hwacha parameter exists then generate its tests
|
||||
// TODO: find a more elegant way to do this. either through
|
||||
|
||||
Reference in New Issue
Block a user