|
|
|
@@ -29,15 +29,17 @@ class CoreEntry[TileParamsT <: TileParams with Product: TypeTag, TileT <: BaseTi
|
|
|
|
tk: Field[Seq[TileParamsT]],
|
|
|
|
tk: Field[Seq[TileParamsT]],
|
|
|
|
ck: Field[Seq[RocketCrossingParams]]
|
|
|
|
ck: Field[Seq[RocketCrossingParams]]
|
|
|
|
) extends CoreEntryBase {
|
|
|
|
) extends CoreEntryBase {
|
|
|
|
|
|
|
|
// Use reflection to get the parameter's constructor
|
|
|
|
private val mirror = runtimeMirror(getClass.getClassLoader)
|
|
|
|
private val mirror = runtimeMirror(getClass.getClassLoader)
|
|
|
|
private val paramClass = mirror.runtimeClass(typeOf[TileParamsT].typeSymbol.asClass)
|
|
|
|
private val paramClass = mirror.runtimeClass(typeOf[TileParamsT].typeSymbol.asClass)
|
|
|
|
private val paramNames = (paramClass.getDeclaredFields map (f => f.getName)).zipWithIndex.toMap
|
|
|
|
private val paramNames = (paramClass.getDeclaredFields map (f => f.getName)).zipWithIndex.toMap
|
|
|
|
private val paramCtr = paramClass.getConstructors.head
|
|
|
|
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 tileClass = mirror.runtimeClass(typeOf[TileT].typeSymbol.asClass)
|
|
|
|
private val tileCtr = tileClass.getConstructors.filter(ctr => ctr.getParameterTypes()(4) == classOf[Parameters]).head
|
|
|
|
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]) = {
|
|
|
|
def copyTileParam(tileParam: TileParamsT, properties: Map[String, Any]) = {
|
|
|
|
val values = tileParam.productIterator.toList
|
|
|
|
val values = tileParam.productIterator.toList
|
|
|
|
val indexedProperties = properties map { case (key, value) => (paramNames(key), value) }
|
|
|
|
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:_*)
|
|
|
|
paramCtr.newInstance(newValues:_*)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Tile parameter lookup using correct type
|
|
|
|
def tileParamsLookup(implicit p: Parameters) = p(tk)
|
|
|
|
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] = {
|
|
|
|
def updateWithFilter(view: View, p: Any => Boolean): PartialFunction[Any, Map[String, Any] => Any] = {
|
|
|
|
case key if (key == tk && p(tk)) => properties => view(tk) map
|
|
|
|
case key if (key == tk && p(tk)) => properties => view(tk) map
|
|
|
|
(tile => copyTileParam(tile, properties))
|
|
|
|
(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)
|
|
|
|
def instantiateTile(crossingLookup: (Seq[RocketCrossingParams], Int) => Seq[RocketCrossingParams], logicalTreeNode: LogicalTreeNode)
|
|
|
|
(implicit p: Parameters, valName: ValName) = {
|
|
|
|
(implicit p: Parameters, valName: ValName) = {
|
|
|
|
val tileParams = p(tk)
|
|
|
|
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 {
|
|
|
|
object GenericConfig {
|
|
|
|
def apply(properties: Map[String, Any], filterFunc: Any => Boolean = (_ => true)) =
|
|
|
|
def apply(properties: Map[String, Any], filterFunc: Any => Boolean = (_ => true)) =
|
|
|
|
new GenericConfig(properties, filterFunc).configFunc
|
|
|
|
new GenericConfig(properties, filterFunc).configFunc
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// A list of all cores.
|
|
|
|
object CoreManager {
|
|
|
|
object CoreManager {
|
|
|
|
val cores: List[CoreEntryBase] = List(
|
|
|
|
val cores: List[CoreEntryBase] = List(
|
|
|
|
// ADD YOUR CORE DEFINITION HERE
|
|
|
|
// TODO ADD YOUR CORE DEFINITION HERE
|
|
|
|
new CoreEntry[RocketTileParams, RocketTile](RocketTilesKey, RocketCrossingKey),
|
|
|
|
new CoreEntry[RocketTileParams, RocketTile](RocketTilesKey, RocketCrossingKey),
|
|
|
|
new CoreEntry[BoomTileParams, BoomTile](BoomTilesKey, BoomCrossingKey),
|
|
|
|
new CoreEntry[BoomTileParams, BoomTile](BoomTilesKey, BoomCrossingKey),
|
|
|
|
new CoreEntry[ArianeTileParams, ArianeTile](ArianeTilesKey, ArianeCrossingKey)
|
|
|
|
new CoreEntry[ArianeTileParams, ArianeTile](ArianeTilesKey, ArianeCrossingKey)
|
|
|
|
|