2016-11-28 01:16:37 +01:00
|
|
|
// See LICENSE.SiFive for license details.
|
|
|
|
|
2017-07-07 19:48:16 +02:00
|
|
|
package freechips.rocketchip.groundtest
|
2016-09-15 22:04:01 +02:00
|
|
|
|
|
|
|
import Chisel._
|
2017-07-07 19:48:16 +02:00
|
|
|
|
|
|
|
import freechips.rocketchip.config.{Field, Parameters}
|
|
|
|
import freechips.rocketchip.diplomacy._
|
2017-12-02 03:28:24 +01:00
|
|
|
import freechips.rocketchip.interrupts._
|
2018-01-12 21:29:27 +01:00
|
|
|
import freechips.rocketchip.subsystem._
|
2017-07-07 19:48:16 +02:00
|
|
|
import freechips.rocketchip.tilelink._
|
|
|
|
import freechips.rocketchip.tile._
|
|
|
|
|
2017-01-17 03:24:08 +01:00
|
|
|
import scala.math.max
|
2016-09-15 22:04:01 +02:00
|
|
|
|
2016-11-22 19:53:44 +01:00
|
|
|
case object TileId extends Field[Int]
|
|
|
|
|
2018-01-12 21:29:27 +01:00
|
|
|
class GroundTestSubsystem(implicit p: Parameters) extends BaseSubsystem
|
2017-07-23 17:31:04 +02:00
|
|
|
with HasMasterAXI4MemPort
|
2018-02-21 02:10:16 +01:00
|
|
|
with HasPeripheryTestRAMSlave {
|
2017-07-07 19:48:16 +02:00
|
|
|
val tileParams = p(GroundTestTilesKey)
|
|
|
|
val tiles = tileParams.zipWithIndex.map { case(c, i) => LazyModule(
|
|
|
|
c.build(i, p.alterPartial {
|
|
|
|
case TileKey => c
|
2017-07-25 06:41:17 +02:00
|
|
|
case SharedMemoryTLEdge => sbus.busView
|
2017-07-07 19:48:16 +02:00
|
|
|
})
|
|
|
|
)}
|
2017-01-17 03:24:08 +01:00
|
|
|
|
2017-10-23 18:39:01 +02:00
|
|
|
tiles.flatMap(_.dcacheOpt).foreach { dc =>
|
2018-02-15 23:01:49 +01:00
|
|
|
sbus.fromTile(None, buffers = 1){ dc.node }
|
2017-10-11 00:02:50 +02:00
|
|
|
}
|
2016-11-17 02:05:53 +01:00
|
|
|
|
2017-12-02 03:28:24 +01:00
|
|
|
// No PLIC in ground test; so just sink the interrupts to nowhere
|
|
|
|
IntSinkNode(IntSinkPortSimple()) := ibus.toPLIC
|
|
|
|
|
2018-02-21 21:51:16 +01:00
|
|
|
override lazy val module = new GroundTestSubsystemModuleImp(this)
|
2016-09-22 01:54:35 +02:00
|
|
|
}
|
|
|
|
|
2018-02-21 21:51:16 +01:00
|
|
|
class GroundTestSubsystemModuleImp[+L <: GroundTestSubsystem](_outer: L) extends BaseSubsystemModuleImp(_outer)
|
2017-07-23 17:31:04 +02:00
|
|
|
with HasMasterAXI4MemPortModuleImp {
|
|
|
|
val success = IO(Bool(OUTPUT))
|
2017-07-07 19:48:16 +02:00
|
|
|
|
2018-01-03 00:37:31 +01:00
|
|
|
outer.tiles.zipWithIndex.map { case(t, i) => t.module.constants.hartid := UInt(i) }
|
2017-07-07 19:48:16 +02:00
|
|
|
|
2018-01-03 00:37:31 +01:00
|
|
|
val status = DebugCombiner(outer.tiles.map(_.module.status))
|
2017-07-23 17:31:04 +02:00
|
|
|
success := status.finished
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Adds a SRAM to the system for testing purposes. */
|
2018-02-21 02:10:16 +01:00
|
|
|
trait HasPeripheryTestRAMSlave { this: BaseSubsystem =>
|
2017-10-12 03:22:52 +02:00
|
|
|
val testram = LazyModule(new TLRAM(AddressSet(0x52000000, 0xfff), true, true, pbus.beatBytes))
|
2018-02-15 23:01:49 +01:00
|
|
|
pbus.toVariableWidthSlave(Some("TestRAM")) { testram.node }
|
2017-07-23 17:31:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Adds a fuzzing master to the system for testing purposes. */
|
2018-02-21 02:10:16 +01:00
|
|
|
trait HasPeripheryTestFuzzMaster { this: BaseSubsystem =>
|
2017-07-23 17:31:04 +02:00
|
|
|
val fuzzer = LazyModule(new TLFuzzer(5000))
|
2018-02-15 23:01:49 +01:00
|
|
|
pbus.fromOtherMaster(Some("Fuzzer")) { fuzzer.node }
|
2016-09-15 22:04:01 +02:00
|
|
|
}
|