2015-11-19 09:15:36 +01:00
|
|
|
package groundtest
|
|
|
|
|
|
|
|
import Chisel._
|
|
|
|
import uncore._
|
|
|
|
import cde.{Parameters, Field}
|
|
|
|
|
2015-11-19 05:53:36 +01:00
|
|
|
class CacheFillTest(implicit p: Parameters) extends GroundTest()(p)
|
2015-11-19 09:15:36 +01:00
|
|
|
with HasTileLinkParameters {
|
|
|
|
val capacityKb: Int = p("L2_CAPACITY_IN_KB")
|
|
|
|
val nblocks = capacityKb * 1024 / p(CacheBlockBytes)
|
|
|
|
val s_start :: s_prefetch :: s_retrieve :: s_finished :: Nil = Enum(Bits(), 4)
|
|
|
|
val state = Reg(init = s_start)
|
|
|
|
|
|
|
|
val active = state === s_prefetch || state === s_retrieve
|
|
|
|
|
2016-06-09 04:53:42 +02:00
|
|
|
val xact_pending = Reg(init = UInt(0, tlMaxClientXacts))
|
|
|
|
val xact_id = PriorityEncoder(~xact_pending)
|
|
|
|
|
2016-06-14 01:17:11 +02:00
|
|
|
val (req_block, round_done) = Counter(io.mem.head.acquire.fire(), nblocks)
|
2015-11-19 05:53:36 +01:00
|
|
|
|
2016-06-14 01:17:11 +02:00
|
|
|
io.mem.head.acquire.valid := active && !xact_pending.andR
|
|
|
|
io.mem.head.acquire.bits := Mux(state === s_prefetch,
|
2016-05-03 03:25:02 +02:00
|
|
|
GetPrefetch(xact_id, UInt(memStartBlock) + req_block),
|
|
|
|
GetBlock(xact_id, UInt(memStartBlock) + req_block))
|
2016-06-14 01:17:11 +02:00
|
|
|
io.mem.head.grant.ready := xact_pending.orR
|
2015-11-19 09:15:36 +01:00
|
|
|
|
2016-06-09 04:53:42 +02:00
|
|
|
def add_pending(acq: DecoupledIO[Acquire]): UInt =
|
|
|
|
Mux(acq.fire(), UIntToOH(acq.bits.client_xact_id), UInt(0))
|
2015-11-19 09:15:36 +01:00
|
|
|
|
2016-06-09 04:53:42 +02:00
|
|
|
def remove_pending(gnt: DecoupledIO[Grant]): UInt = {
|
|
|
|
val last_grant = !gnt.bits.hasMultibeatData() ||
|
|
|
|
gnt.bits.addr_beat === UInt(tlDataBeats - 1)
|
|
|
|
~Mux(gnt.fire() && last_grant, UIntToOH(gnt.bits.client_xact_id), UInt(0))
|
2015-11-19 09:15:36 +01:00
|
|
|
}
|
|
|
|
|
2016-06-09 04:53:42 +02:00
|
|
|
xact_pending := (xact_pending |
|
2016-06-14 01:17:11 +02:00
|
|
|
add_pending(io.mem.head.acquire)) &
|
|
|
|
remove_pending(io.mem.head.grant)
|
2016-06-09 04:53:42 +02:00
|
|
|
|
2015-11-19 09:15:36 +01:00
|
|
|
when (state === s_start) { state := s_prefetch }
|
|
|
|
when (state === s_prefetch && round_done) { state := s_retrieve }
|
|
|
|
when (state === s_retrieve && round_done) { state := s_finished }
|
|
|
|
|
|
|
|
io.finished := (state === s_finished)
|
|
|
|
}
|