1
0
rocket-chip/src/main/scala/groundtest/CacheFillTest.scala

52 lines
1.8 KiB
Scala
Raw Normal View History

2015-11-19 09:15:36 +01:00
package groundtest
import Chisel._
import uncore.tilelink._
import uncore.constants._
import uncore.agents._
import util._
import config._
2015-11-19 09:15:36 +01:00
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 {
2016-11-18 21:02:33 +01:00
val l2Config = p(CacheName("L2"))
val capacityKb = l2Config.nSets * l2Config.nWays * l2Config.rowBits / (1024*8)
2015-11-19 09:15:36 +01:00
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)
2016-08-19 18:46:43 +02:00
val active = state.isOneOf(s_prefetch, s_retrieve)
2015-11-19 09:15:36 +01:00
val xact_pending = Reg(init = UInt(0, tlMaxClientXacts))
val xact_id = PriorityEncoder(~xact_pending)
val (req_block, round_done) = Counter(io.mem.head.acquire.fire(), nblocks)
2015-11-19 05:53:36 +01: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))
io.mem.head.grant.ready := xact_pending.orR
2015-11-19 09:15:36 +01: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
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
}
xact_pending := (xact_pending |
add_pending(io.mem.head.acquire)) &
remove_pending(io.mem.head.grant)
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.status.finished := (state === s_finished)
io.status.timeout.valid := Bool(false)
io.status.error.valid := Bool(false)
2015-11-19 09:15:36 +01:00
}