Config Done
This commit is contained in:
@@ -148,20 +148,8 @@ class WithControlCore extends Config((site, here, up) => {
|
|||||||
case MaxHartIdBits => log2Up(up(RocketTilesKey, site).size + up(BoomTilesKey, site).size + 1)
|
case MaxHartIdBits => log2Up(up(RocketTilesKey, site).size + up(BoomTilesKey, site).size + 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
class WithTraceIOHMap extends ConfigHMap {
|
class WithTraceIO extends Config((site, here, up) =>
|
||||||
override def apply[I](v: I) = (site, here, up) => {
|
GenericConfig(Map("trace" -> true)) (site, here, up) orElse {
|
||||||
|
case BoomTilesKey => up(BoomTilesKey) map (tile => tile.copy(trace = true))
|
||||||
}
|
case TracePortKey => Some(TracePortParams())
|
||||||
}
|
})
|
||||||
|
|
||||||
class WithTraceIO extends Config((site, here, up) => {
|
|
||||||
val coreMatch: List[CoreRegisterEntryBase] => PartialFunction[Any,Any] =
|
|
||||||
coreList => coreList match {
|
|
||||||
case coreEntry :: tail => coreEntry.enableTileTrace(site, here, up) orElse coreMatch(tail)
|
|
||||||
case Nil => {
|
|
||||||
case BoomTilesKey => up(BoomTilesKey) map (tile => tile.copy(trace = true))
|
|
||||||
case TracePortKey => Some(TracePortParams())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
coreMatch(CoreRegistrar.cores)
|
|
||||||
})
|
|
||||||
|
|||||||
76
generators/chipyard/src/main/scala/CoreManager.scala
Normal file
76
generators/chipyard/src/main/scala/CoreManager.scala
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
package chipyard
|
||||||
|
|
||||||
|
import scala.reflect.ClassTag
|
||||||
|
import scala.reflect.runtime.universe._
|
||||||
|
|
||||||
|
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.diplomaticobjectmodel.logicaltree.LogicalTreeNode
|
||||||
|
import freechips.rocketchip.rocket._
|
||||||
|
import freechips.rocketchip.tile._
|
||||||
|
|
||||||
|
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(param: TileParams, crossing: RocketCrossingParams,
|
||||||
|
logicalTreeNode: LogicalTreeNode, p: Parameters): Option[BaseTile]
|
||||||
|
}
|
||||||
|
|
||||||
|
class CoreEntry[TileParamsT <: CoreParams, TileT <: BaseTile](
|
||||||
|
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 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)))
|
||||||
|
val newValues = (0 until values.size) map
|
||||||
|
(i => if (indexedProperties contains i) indexedProperties(i) else values(i))
|
||||||
|
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 instantiateTile(param: TileParams, crossing: RocketCrossingParams,
|
||||||
|
logicalTreeNode: LogicalTreeNode, p: Parameters): Option[BaseTile] = param match {
|
||||||
|
case a: TileParams => Some(tileCtr.newInstance(a, crossing, PriorityMuxHartIdFromSeq(p(tilesKey)), logicalTreeNode, p))
|
||||||
|
case _ => None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object CoreManager {
|
||||||
|
val cores: List[CoreEntryBase] = List(
|
||||||
|
// ADD YOUR CORE DEFINITION HERE
|
||||||
|
new CoreEntry[ArianeTileParams, ArianeTile](ArianeTilesKey, ArianeCrossingKey)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
}
|
||||||
|
|
||||||
|
object GenericConfig {
|
||||||
|
def apply(properties: Map[String, Any], filterFunc: Any => Bool = (_ => true)) =
|
||||||
|
new GenericConfig(properties, filterFunc).configFunc
|
||||||
|
}
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
package chipyard
|
|
||||||
|
|
||||||
import scala.reflect.ClassTag
|
|
||||||
import scala.reflect.runtime.universe._
|
|
||||||
|
|
||||||
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.diplomaticobjectmodel.logicaltree.LogicalTreeNode
|
|
||||||
import freechips.rocketchip.rocket._
|
|
||||||
import freechips.rocketchip.tile._
|
|
||||||
|
|
||||||
import ariane.{ArianeTile, ArianeTilesKey, ArianeCrossingKey, ArianeTileParams}
|
|
||||||
|
|
||||||
// Third-party core entries
|
|
||||||
sealed trait CoreRegisterEntryBase {
|
|
||||||
type TileParams <: CoreParams
|
|
||||||
def tilesKey: Field[Seq[TileParams]]
|
|
||||||
def crossingKey: Field[Seq[RocketCrossingParams]]
|
|
||||||
|
|
||||||
def findTilesWithFilter(view: View, p: Any => View): PartialFunction[Any, Seq[AnyRef]]
|
|
||||||
|
|
||||||
def enableTileTrace(site: View, here: View, up: View): PartialFunction[Any, Any]
|
|
||||||
def instantiateTile(param: TileParams, crossing: RocketCrossingParams,
|
|
||||||
logicalTreeNode: LogicalTreeNode, p: Parameters): Option[BaseTile]
|
|
||||||
}
|
|
||||||
|
|
||||||
class CoreRegisterEntry[TileParamsT <: CoreParams, TileT <: BaseTile](
|
|
||||||
tk: Field[Seq[TileParamsT]],
|
|
||||||
ck: Field[Seq[RocketCrossingParams]],
|
|
||||||
tileInstantiator: (TileParamsT, RocketCrossingParams, LookupByHartIdImpl, LogicalTreeNode, Parameters) => TileT
|
|
||||||
) extends CoreRegisterEntryBase {
|
|
||||||
type TileParams = TileParamsT
|
|
||||||
def tilesKey = tk
|
|
||||||
def crossingKey = ck
|
|
||||||
|
|
||||||
def findTilesWithFilter(view: View, p: Any => View) = {
|
|
||||||
case key if (key == tk && p(tk)) => view(tk)
|
|
||||||
}
|
|
||||||
|
|
||||||
def enableTileTrace(site: View, here: View, up: View): PartialFunction[Any, Any] = {
|
|
||||||
case in if in == tilesKey => up(this.tilesKey) map (tile => tile.copy(trace = true))
|
|
||||||
}
|
|
||||||
def instantiateTile(param: TileParams, crossing: RocketCrossingParams,
|
|
||||||
logicalTreeNode: LogicalTreeNode, p: Parameters): Option[BaseTile] = param match {
|
|
||||||
case a: TileParams => Some(tileInstantiator(a, crossing, PriorityMuxHartIdFromSeq(p(tilesKey)), logicalTreeNode, p))
|
|
||||||
case _ => None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
object CoreRegistrar {
|
|
||||||
val cores: List[CoreRegisterEntryBase] = List(
|
|
||||||
// ADD YOUR CORE DEFINITION HERE
|
|
||||||
new CoreRegisterEntry[ArianeTileParams, ArianeTile](ArianeTilesKey, ArianeCrossingKey, ((a, b, c, d, p) => {new ArianeTile(a, b, c, d)}))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Core Generic Config - change properties in the given map
|
|
||||||
class GenericConfig(properties: Map[String, Any], filterFunc: Any => Bool = (_ => true)) {
|
|
||||||
val configFunc: (View, View, View) => PartialFunction[Any, Any] = ((site, here, up) => key => {
|
|
||||||
val tiles = CoreRegistrar.cores flatMap _.findTilesWithFilter(up, filterFunc).lift(key)
|
|
||||||
if (tiles.size == 0) None else Some(tiles map (tile => {
|
|
||||||
val method = ClassTag(tile.getClass).member(TermName(methodName)).asMethod
|
|
||||||
})).unlift
|
|
||||||
}).unlift
|
|
||||||
}
|
|
||||||
@@ -147,7 +147,7 @@ class TestSuiteHelper
|
|||||||
*/
|
*/
|
||||||
def addThirdPartyTestSuites[TileParams <: CoreParams](tilesKey: Field[Seq[TileParams]])(implicit p: Parameters) = {
|
def addThirdPartyTestSuites[TileParams <: CoreParams](tilesKey: Field[Seq[TileParams]])(implicit p: Parameters) = {
|
||||||
val xlen = p(XLen)
|
val xlen = p(XLen)
|
||||||
p(tilesKey).find(_.hartId == 0).map { tileParams =>
|
p(tilesKey).asInstanceOf[Seq[CoreParams]].find(_.hartId == 0).map { tileParams =>
|
||||||
val coreParams = tileParams.core
|
val coreParams = tileParams.core
|
||||||
val vm = coreParams.useVM
|
val vm = coreParams.useVM
|
||||||
val env = if (vm) List("p","v") else List("p")
|
val env = if (vm) List("p","v") else List("p")
|
||||||
|
|||||||
Reference in New Issue
Block a user