2016-11-28 01:16:37 +01:00
|
|
|
// See LICENSE.SiFive for license details.
|
|
|
|
// See LICENSE.Berkeley for license details.
|
|
|
|
|
2015-11-19 09:15:36 +01:00
|
|
|
package groundtest
|
|
|
|
|
|
|
|
import Chisel._
|
2017-02-09 22:59:09 +01:00
|
|
|
import coreplex.CacheBlockBytes
|
2016-06-28 22:15:56 +02:00
|
|
|
import uncore.tilelink._
|
|
|
|
import uncore.constants._
|
2016-11-22 20:50:41 +01:00
|
|
|
import uncore.util._
|
2016-09-28 06:27:07 +02:00
|
|
|
import util._
|
2016-11-18 23:05:14 +01:00
|
|
|
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 {
|
2017-02-09 22:59:09 +01:00
|
|
|
//val l2Config = p(CacheName("L2"))
|
|
|
|
//val capacityKb = l2Config.nSets * l2Config.nWays * l2Config.rowBits / (1024*8)
|
|
|
|
val capacityKb = 1024 // TODO
|
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
|
|
|
|
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 }
|
|
|
|
|
2016-07-12 01:41:55 +02:00
|
|
|
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
|
|
|
}
|