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._
|
|
|
|
import freechips.rocketchip.rocket._
|
|
|
|
import freechips.rocketchip.util._
|
2017-02-09 22:59:09 +01:00
|
|
|
|
|
|
|
case object BuildCore extends Field[Parameters => CoreModule with HasCoreIO]
|
|
|
|
case object XLen extends Field[Int]
|
|
|
|
|
|
|
|
// These parameters can be varied per-core
|
|
|
|
trait CoreParams {
|
|
|
|
val useVM: Boolean
|
|
|
|
val useUser: Boolean
|
|
|
|
val useDebug: Boolean
|
|
|
|
val useAtomics: Boolean
|
|
|
|
val useCompressed: Boolean
|
|
|
|
val mulDiv: Option[MulDivParams]
|
|
|
|
val fpu: Option[FPUParams]
|
|
|
|
val fetchWidth: Int
|
|
|
|
val decodeWidth: Int
|
|
|
|
val retireWidth: Int
|
|
|
|
val instBits: Int
|
2017-03-24 22:49:12 +01:00
|
|
|
val nLocalInterrupts: Int
|
2017-09-20 23:04:13 +02:00
|
|
|
val nPMPs: Int
|
|
|
|
val nBreakpoints: Int
|
|
|
|
val nPerfCounters: Int
|
2017-09-21 04:15:36 +02:00
|
|
|
val haveBasicCounters: Boolean
|
2017-09-21 04:16:34 +02:00
|
|
|
val misaWritable: Boolean
|
2017-07-06 08:53:52 +02:00
|
|
|
val nL2TLBEntries: Int
|
2017-09-20 23:04:13 +02:00
|
|
|
val mtvecInit: Option[BigInt]
|
|
|
|
val mtvecWritable: Boolean
|
2017-07-26 00:18:32 +02:00
|
|
|
val jumpInFrontend: Boolean
|
2017-09-16 03:49:40 +02:00
|
|
|
val tileControlAddr: Option[BigInt]
|
2017-09-01 03:48:59 +02:00
|
|
|
|
|
|
|
def instBytes: Int = instBits / 8
|
|
|
|
def fetchBytes: Int = fetchWidth * instBytes
|
2017-02-09 22:59:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
trait HasCoreParameters extends HasTileParameters {
|
|
|
|
val coreParams: CoreParams = tileParams.core
|
|
|
|
|
|
|
|
val fLen = xLen // TODO relax this
|
|
|
|
|
|
|
|
val usingMulDiv = coreParams.mulDiv.nonEmpty
|
|
|
|
val usingFPU = coreParams.fpu.nonEmpty
|
|
|
|
val usingAtomics = coreParams.useAtomics
|
|
|
|
val usingCompressed = coreParams.useCompressed
|
|
|
|
|
|
|
|
val retireWidth = coreParams.retireWidth
|
|
|
|
val fetchWidth = coreParams.fetchWidth
|
|
|
|
val decodeWidth = coreParams.decodeWidth
|
|
|
|
|
2017-09-29 21:31:26 +02:00
|
|
|
val fetchBytes = coreParams.fetchBytes
|
2017-02-09 22:59:09 +01:00
|
|
|
val coreInstBits = coreParams.instBits
|
|
|
|
val coreInstBytes = coreInstBits/8
|
2017-03-15 09:18:39 +01:00
|
|
|
val coreDataBits = xLen max fLen
|
2017-02-09 22:59:09 +01:00
|
|
|
val coreDataBytes = coreDataBits/8
|
2017-09-02 02:50:54 +02:00
|
|
|
val coreMaxAddrBits = paddrBits max vaddrBitsExtended
|
2017-02-09 22:59:09 +01:00
|
|
|
|
2017-09-20 23:04:13 +02:00
|
|
|
val nBreakpoints = coreParams.nBreakpoints
|
|
|
|
val nPMPs = coreParams.nPMPs
|
|
|
|
val nPerfCounters = coreParams.nPerfCounters
|
|
|
|
val mtvecInit = coreParams.mtvecInit
|
|
|
|
val mtvecWritable = coreParams.mtvecWritable
|
|
|
|
|
2017-02-09 22:59:09 +01:00
|
|
|
val coreDCacheReqTagBits = 6
|
|
|
|
val dcacheReqTagBits = coreDCacheReqTagBits + log2Ceil(dcacheArbPorts)
|
|
|
|
|
|
|
|
// Print out log of committed instructions and their writeback values.
|
|
|
|
// Requires post-processing due to out-of-order writebacks.
|
|
|
|
val enableCommitLog = false
|
|
|
|
}
|
|
|
|
|
|
|
|
abstract class CoreModule(implicit val p: Parameters) extends Module
|
|
|
|
with HasCoreParameters
|
|
|
|
|
|
|
|
abstract class CoreBundle(implicit val p: Parameters) extends ParameterizedBundle()(p)
|
|
|
|
with HasCoreParameters
|
|
|
|
|
2017-04-27 05:11:43 +02:00
|
|
|
trait HasCoreIO extends HasTileParameters {
|
2017-02-09 22:59:09 +01:00
|
|
|
implicit val p: Parameters
|
2017-04-28 00:22:52 +02:00
|
|
|
val io = new CoreBundle()(p) with HasExternallyDrivenTileConstants {
|
2017-02-09 22:59:09 +01:00
|
|
|
val interrupts = new TileInterrupts().asInput
|
2017-04-28 00:22:52 +02:00
|
|
|
val imem = new FrontendIO
|
|
|
|
val dmem = new HellaCacheIO
|
2017-02-09 22:59:09 +01:00
|
|
|
val ptw = new DatapathPTWIO().flip
|
|
|
|
val fpu = new FPUCoreIO().flip
|
|
|
|
val rocc = new RoCCCoreIO().flip
|
2017-09-20 07:59:28 +02:00
|
|
|
val trace = Vec(coreParams.retireWidth, new TracedInstruction).asOutput
|
2017-02-09 22:59:09 +01:00
|
|
|
}
|
|
|
|
}
|