2017-02-09 22:59:09 +01:00
|
|
|
// See LICENSE.SiFive for license details.
|
|
|
|
|
2017-07-07 19:48:16 +02:00
|
|
|
package freechips.rocketchip.tile
|
2017-02-09 22:59:09 +01:00
|
|
|
|
|
|
|
import Chisel._
|
2017-07-07 19:48:16 +02:00
|
|
|
|
|
|
|
import freechips.rocketchip.config.{Parameters, Field}
|
2018-01-12 21:29:27 +01:00
|
|
|
import freechips.rocketchip.subsystem.CacheBlockBytes
|
2017-07-07 19:48:16 +02:00
|
|
|
import freechips.rocketchip.tilelink.ClientMetadata
|
|
|
|
import freechips.rocketchip.util._
|
2017-02-09 22:59:09 +01:00
|
|
|
|
|
|
|
trait L1CacheParams {
|
|
|
|
def nSets: Int
|
|
|
|
def nWays: Int
|
|
|
|
def rowBits: Int
|
|
|
|
def nTLBEntries: Int
|
2017-12-21 02:18:38 +01:00
|
|
|
def blockBytes: Int // TODO this is ignored in favor of p(CacheBlockBytes) in BaseTile
|
2017-02-09 22:59:09 +01:00
|
|
|
}
|
|
|
|
|
2017-12-21 02:18:38 +01:00
|
|
|
trait HasL1CacheParameters extends HasTileParameters {
|
2017-02-09 22:59:09 +01:00
|
|
|
val cacheParams: L1CacheParams
|
2017-07-23 17:31:04 +02:00
|
|
|
private val bundleParams = p(SharedMemoryTLEdge).bundle
|
2017-02-09 22:59:09 +01:00
|
|
|
|
|
|
|
def nSets = cacheParams.nSets
|
|
|
|
def blockOffBits = lgCacheBlockBytes
|
|
|
|
def idxBits = log2Up(cacheParams.nSets)
|
|
|
|
def untagBits = blockOffBits + idxBits
|
2017-07-23 17:31:04 +02:00
|
|
|
def tagBits = bundleParams.addressBits - untagBits
|
2017-02-09 22:59:09 +01:00
|
|
|
def nWays = cacheParams.nWays
|
|
|
|
def wayBits = log2Up(nWays)
|
|
|
|
def isDM = nWays == 1
|
|
|
|
def rowBits = cacheParams.rowBits
|
|
|
|
def rowBytes = rowBits/8
|
|
|
|
def rowOffBits = log2Up(rowBytes)
|
|
|
|
def nTLBEntries = cacheParams.nTLBEntries
|
|
|
|
|
2017-07-23 17:31:04 +02:00
|
|
|
def cacheDataBits = bundleParams.dataBits
|
2017-02-09 22:59:09 +01:00
|
|
|
def cacheDataBeats = (cacheBlockBytes * 8) / cacheDataBits
|
|
|
|
def refillCycles = cacheDataBeats
|
|
|
|
}
|
|
|
|
|
|
|
|
abstract class L1CacheModule(implicit val p: Parameters) extends Module
|
|
|
|
with HasL1CacheParameters
|
|
|
|
|
|
|
|
abstract class L1CacheBundle(implicit val p: Parameters) extends ParameterizedBundle()(p)
|
|
|
|
with HasL1CacheParameters
|