Add comments
This commit is contained in:
@@ -29,15 +29,17 @@ class CoreEntry[TileParamsT <: TileParams with Product: TypeTag, TileT <: BaseTi
|
||||
tk: Field[Seq[TileParamsT]],
|
||||
ck: Field[Seq[RocketCrossingParams]]
|
||||
) extends CoreEntryBase {
|
||||
// Use reflection to get the parameter's constructor
|
||||
private val mirror = runtimeMirror(getClass.getClassLoader)
|
||||
private val paramClass = mirror.runtimeClass(typeOf[TileParamsT].typeSymbol.asClass)
|
||||
private val paramNames = (paramClass.getDeclaredFields map (f => f.getName)).zipWithIndex.toMap
|
||||
private val paramCtr = paramClass.getConstructors.head
|
||||
|
||||
// Use reflection to get the tile's constructor
|
||||
private val tileClass = mirror.runtimeClass(typeOf[TileT].typeSymbol.asClass)
|
||||
private val tileCtr = tileClass.getConstructors.filter(ctr => ctr.getParameterTypes()(4) == classOf[Parameters]).head
|
||||
|
||||
// Reflective version of copy()
|
||||
// Version of case class' copy() using reflection, where fields to be updated are passed by a map
|
||||
def copyTileParam(tileParam: TileParamsT, properties: Map[String, Any]) = {
|
||||
val values = tileParam.productIterator.toList
|
||||
val indexedProperties = properties map { case (key, value) => (paramNames(key), value) }
|
||||
@@ -46,13 +48,16 @@ class CoreEntry[TileParamsT <: TileParams with Product: TypeTag, TileT <: BaseTi
|
||||
paramCtr.newInstance(newValues:_*)
|
||||
}
|
||||
|
||||
// Tile parameter lookup using correct type
|
||||
def tileParamsLookup(implicit p: Parameters) = p(tk)
|
||||
|
||||
// If this core meet the requirement given by p, update parameter fields in the map
|
||||
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))
|
||||
}
|
||||
|
||||
// Instantiate a tile and zip it with its parameter info, used by subsystem
|
||||
def instantiateTile(crossingLookup: (Seq[RocketCrossingParams], Int) => Seq[RocketCrossingParams], logicalTreeNode: LogicalTreeNode)
|
||||
(implicit p: Parameters, valName: ValName) = {
|
||||
val tileParams = p(tk)
|
||||
@@ -75,14 +80,16 @@ class GenericConfig(properties: Map[String, Any], filterFunc: Any => Boolean) {
|
||||
})
|
||||
}
|
||||
|
||||
// Wrapper object of the class above
|
||||
object GenericConfig {
|
||||
def apply(properties: Map[String, Any], filterFunc: Any => Boolean = (_ => true)) =
|
||||
new GenericConfig(properties, filterFunc).configFunc
|
||||
}
|
||||
|
||||
// A list of all cores.
|
||||
object CoreManager {
|
||||
val cores: List[CoreEntryBase] = List(
|
||||
// ADD YOUR CORE DEFINITION HERE
|
||||
// TODO ADD YOUR CORE DEFINITION HERE
|
||||
new CoreEntry[RocketTileParams, RocketTile](RocketTilesKey, RocketCrossingKey),
|
||||
new CoreEntry[BoomTileParams, BoomTile](BoomTilesKey, BoomCrossingKey),
|
||||
new CoreEntry[ArianeTileParams, ArianeTile](ArianeTilesKey, ArianeCrossingKey)
|
||||
|
||||
@@ -33,7 +33,8 @@ trait HasChipyardTiles extends HasTiles
|
||||
|
||||
val module: HasChipyardTilesModuleImp
|
||||
|
||||
val allTilesInfo: Seq[(TileParams, RocketCrossingParams, BaseTile)] =
|
||||
// Generate tiles info from the list of cores in CoreManager
|
||||
val allTilesInfo: Seq[(TileParams, RocketCrossingParams, BaseTile)] =
|
||||
(CoreManager.cores flatMap (core => core.instantiateTile(perTileOrGlobalSetting _, logicalTreeNode)))
|
||||
|
||||
// Make a tile and wire its nodes into the system,
|
||||
|
||||
@@ -63,9 +63,9 @@ class TestSuiteHelper
|
||||
def addSuites(s: Seq[RocketTestSuite]) { s.foreach(addSuite) }
|
||||
|
||||
/**
|
||||
* Add third-party core (including Ariane) tests (asm, bmark, regression)
|
||||
* Add generic tests (asm, bmark, regression) for all cores.
|
||||
*/
|
||||
def addThirdPartyTestSuites(tiles: Seq[TileParams])(implicit p: Parameters) = {
|
||||
def addGenericTestSuites(tiles: Seq[TileParams])(implicit p: Parameters) = {
|
||||
val xlen = p(XLen)
|
||||
tiles.find(_.hartId == 0).map { tileParams =>
|
||||
val coreParams = tileParams.core
|
||||
|
||||
@@ -22,7 +22,7 @@ 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
|
||||
// because the RocketTestSuiteAnnotation is not serializable (but is not marked as such).
|
||||
// because the RocketTestSuiteAnnotation is not serializable (but is not marked as such).
|
||||
override val prerequisites = Seq(
|
||||
Dependency[freechips.rocketchip.stage.phases.GenerateFirrtlAnnos],
|
||||
Dependency[freechips.rocketchip.stage.phases.AddDefaultTests])
|
||||
@@ -34,7 +34,7 @@ class AddDefaultTests extends Phase with PreservesAll[Phase] with HasRocketChipS
|
||||
// Use Xlen as a proxy for detecting if we are a processor-like target
|
||||
// The underlying test suites expect this field to be defined
|
||||
if (p.lift(XLen).nonEmpty)
|
||||
CoreManager.cores map (core => suiteHelper.addThirdPartyTestSuites(core.tileParamsLookup))
|
||||
CoreManager.cores map (core => suiteHelper.addGenericTestSuites(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