XSCore.scala 17.2 KB
Newer Older
L
LinJiawei 已提交
1 2 3 4
package xiangshan

import chisel3._
import chisel3.util._
L
LinJiawei 已提交
5
import top.Parameters
L
LinJiawei 已提交
6
import xiangshan.backend._
7
import xiangshan.backend.dispatch.DispatchParameters
L
LinJiawei 已提交
8
import xiangshan.backend.exu.ExuParameters
L
LinJiawei 已提交
9
import xiangshan.backend.exu.Exu._
G
GouLingrui 已提交
10
import xiangshan.frontend._
11
import xiangshan.mem._
Y
Yinan Xu 已提交
12
import xiangshan.backend.fu.HasExceptionNO
13
import xiangshan.cache.{DCacheParameters, ICacheParameters, L1plusCache, L1plusCacheParameters, PTW, PTWRepeater}
14
import xiangshan.cache.prefetch._
L
linjiawei 已提交
15
import chipsalliance.rocketchip.config
16
import freechips.rocketchip.diplomacy.{LazyModule, LazyModuleImp}
L
LinJiawei 已提交
17
import freechips.rocketchip.tile.HasFPUParameters
L
LinJiawei 已提交
18
import system.L1CacheErrorInfo
L
LinJiawei 已提交
19
import utils._
L
LinJiawei 已提交
20

21 22
object hartIdCore extends (() => Int) {
  var x = 0
23

24 25
  def apply(): Int = {
    x = x + 1
26
    x - 1
27 28 29
  }
}

L
LinJiawei 已提交
30 31 32 33 34 35 36 37 38 39 40
case class XSCoreParameters
(
  XLEN: Int = 64,
  HasMExtension: Boolean = true,
  HasCExtension: Boolean = true,
  HasDiv: Boolean = true,
  HasICache: Boolean = true,
  HasDCache: Boolean = true,
  EnableStoreQueue: Boolean = true,
  AddrBits: Int = 64,
  VAddrBits: Int = 39,
41
  PAddrBits: Int = 40,
L
LinJiawei 已提交
42
  HasFPU: Boolean = true,
W
wangkaifan 已提交
43
  FetchWidth: Int = 8,
L
LinJiawei 已提交
44
  EnableBPU: Boolean = true,
L
Lingrui98 已提交
45
  EnableBPD: Boolean = true,
G
GouLingrui 已提交
46
  EnableRAS: Boolean = true,
L
Lingrui98 已提交
47
  EnableLB: Boolean = false,
48
  EnableLoop: Boolean = true,
S
Steve Gou 已提交
49
  EnableSC: Boolean = true,
Z
ZhangZifei 已提交
50
  EnbaleTlbDebug: Boolean = false,
J
jinyue110 已提交
51 52
  EnableJal: Boolean = false,
  EnableUBTB: Boolean = true,
L
LinJiawei 已提交
53
  HistoryLength: Int = 64,
54
  BtbSize: Int = 2048,
L
LinJiawei 已提交
55 56 57 58 59 60
  JbtacSize: Int = 1024,
  JbtacBanks: Int = 8,
  RasSize: Int = 16,
  CacheLineSize: Int = 512,
  UBtbWays: Int = 16,
  BtbWays: Int = 2,
S
Steve Gou 已提交
61

62
  EnableL1plusPrefetcher: Boolean = true,
63
  IBufSize: Int = 48,
L
LinJiawei 已提交
64 65 66
  DecodeWidth: Int = 6,
  RenameWidth: Int = 6,
  CommitWidth: Int = 6,
Y
Yinan Xu 已提交
67
  BrqSize: Int = 32,
68
  FtqSize: Int = 64,
69
  EnableLoadFastWakeUp: Boolean = true, // NOTE: not supported now, make it false
Y
Yinan Xu 已提交
70
  IssQueSize: Int = 16,
Y
Yinan Xu 已提交
71
  NRPhyRegs: Int = 160,
Z
zoujr 已提交
72
  NRIntReadPorts: Int = 14,
L
LinJiawei 已提交
73 74
  NRIntWritePorts: Int = 8,
  NRFpReadPorts: Int = 14,
Y
Yinan Xu 已提交
75
  NRFpWritePorts: Int = 8,
Y
Yinan Xu 已提交
76 77 78
  LoadQueueSize: Int = 64,
  StoreQueueSize: Int = 48,
  RoqSize: Int = 192,
L
LinJiawei 已提交
79
  dpParams: DispatchParameters = DispatchParameters(
80 81 82
    IntDqSize = 16,
    FpDqSize = 16,
    LsDqSize = 16,
L
LinJiawei 已提交
83 84
    IntDqDeqWidth = 4,
    FpDqDeqWidth = 4,
Y
Yinan Xu 已提交
85
    LsDqDeqWidth = 4
L
LinJiawei 已提交
86 87
  ),
  exuParameters: ExuParameters = ExuParameters(
L
LinJiawei 已提交
88
    JmpCnt = 1,
89
    AluCnt = 4,
L
LinJiawei 已提交
90 91
    MulCnt = 0,
    MduCnt = 2,
92 93
    FmacCnt = 4,
    FmiscCnt = 2,
94
    FmiscDivSqrtCnt = 0,
L
LinJiawei 已提交
95 96 97 98 99 100
    LduCnt = 2,
    StuCnt = 2
  ),
  LoadPipelineWidth: Int = 2,
  StorePipelineWidth: Int = 2,
  StoreBufferSize: Int = 16,
101 102
  RefillSize: Int = 512,
  TlbEntrySize: Int = 32,
103
  TlbSPEntrySize: Int = 4,
104
  PtwL3EntrySize: Int = 4096, //(256 * 16) or 512
105
  PtwSPEntrySize: Int = 16,
106
  PtwL1EntrySize: Int = 16,
107
  PtwL2EntrySize: Int = 2048, //(256 * 8)
W
wangkaifan 已提交
108
  NumPerfCounters: Int = 16,
109
  NrExtIntr: Int = 150
L
LinJiawei 已提交
110
)
L
LinJiawei 已提交
111 112

trait HasXSParameter {
L
LinJiawei 已提交
113

114
  val coreParams = Parameters.get.coreParameters
L
LinJiawei 已提交
115 116
  val env = Parameters.get.envParameters

L
LinJiawei 已提交
117 118 119
  val XLEN = 64
  val minFLen = 32
  val fLen = 64
120

L
LinJiawei 已提交
121
  def xLen = 64
122

123 124 125 126 127 128 129 130 131
  val HasMExtension = coreParams.HasMExtension
  val HasCExtension = coreParams.HasCExtension
  val HasDiv = coreParams.HasDiv
  val HasIcache = coreParams.HasICache
  val HasDcache = coreParams.HasDCache
  val EnableStoreQueue = coreParams.EnableStoreQueue
  val AddrBits = coreParams.AddrBits // AddrBits is used in some cases
  val VAddrBits = coreParams.VAddrBits // VAddrBits is Virtual Memory addr bits
  val PAddrBits = coreParams.PAddrBits // PAddrBits is Phyical Memory addr bits
L
LinJiawei 已提交
132 133 134
  val AddrBytes = AddrBits / 8 // unused
  val DataBits = XLEN
  val DataBytes = DataBits / 8
135 136
  val HasFPU = coreParams.HasFPU
  val FetchWidth = coreParams.FetchWidth
137
  val PredictWidth = FetchWidth * (if (HasCExtension) 2 else 1)
138 139 140 141 142 143 144 145 146
  val EnableBPU = coreParams.EnableBPU
  val EnableBPD = coreParams.EnableBPD // enable backing predictor(like Tage) in BPUStage3
  val EnableRAS = coreParams.EnableRAS
  val EnableLB = coreParams.EnableLB
  val EnableLoop = coreParams.EnableLoop
  val EnableSC = coreParams.EnableSC
  val EnbaleTlbDebug = coreParams.EnbaleTlbDebug
  val HistoryLength = coreParams.HistoryLength
  val BtbSize = coreParams.BtbSize
G
GouLingrui 已提交
147 148 149
  // val BtbWays = 4
  val BtbBanks = PredictWidth
  // val BtbSets = BtbSize / BtbWays
150 151 152 153
  val JbtacSize = coreParams.JbtacSize
  val JbtacBanks = coreParams.JbtacBanks
  val RasSize = coreParams.RasSize
  val CacheLineSize = coreParams.CacheLineSize
L
LinJiawei 已提交
154
  val CacheLineHalfWord = CacheLineSize / 16
G
GouLingrui 已提交
155
  val ExtHistoryLength = HistoryLength + 64
156 157 158 159 160 161 162 163 164 165
  val UBtbWays = coreParams.UBtbWays
  val BtbWays = coreParams.BtbWays
  val EnableL1plusPrefetcher = coreParams.EnableL1plusPrefetcher
  val IBufSize = coreParams.IBufSize
  val DecodeWidth = coreParams.DecodeWidth
  val RenameWidth = coreParams.RenameWidth
  val CommitWidth = coreParams.CommitWidth
  val BrqSize = coreParams.BrqSize
  val FtqSize = coreParams.FtqSize
  val IssQueSize = coreParams.IssQueSize
166
  val EnableLoadFastWakeUp = coreParams.EnableLoadFastWakeUp
167
  val BrTagWidth = log2Up(BrqSize)
168
  val NRPhyRegs = coreParams.NRPhyRegs
169
  val PhyRegIdxWidth = log2Up(NRPhyRegs)
170 171 172 173 174 175 176
  val RoqSize = coreParams.RoqSize
  val LoadQueueSize = coreParams.LoadQueueSize
  val StoreQueueSize = coreParams.StoreQueueSize
  val dpParams = coreParams.dpParams
  val exuParameters = coreParams.exuParameters
  val NRIntReadPorts = coreParams.NRIntReadPorts
  val NRIntWritePorts = coreParams.NRIntWritePorts
177
  val NRMemReadPorts = exuParameters.LduCnt + 2 * exuParameters.StuCnt
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
  val NRFpReadPorts = coreParams.NRFpReadPorts
  val NRFpWritePorts = coreParams.NRFpWritePorts
  val LoadPipelineWidth = coreParams.LoadPipelineWidth
  val StorePipelineWidth = coreParams.StorePipelineWidth
  val StoreBufferSize = coreParams.StoreBufferSize
  val RefillSize = coreParams.RefillSize
  val DTLBWidth = coreParams.LoadPipelineWidth + coreParams.StorePipelineWidth
  val TlbEntrySize = coreParams.TlbEntrySize
  val TlbSPEntrySize = coreParams.TlbSPEntrySize
  val PtwL3EntrySize = coreParams.PtwL3EntrySize
  val PtwSPEntrySize = coreParams.PtwSPEntrySize
  val PtwL1EntrySize = coreParams.PtwL1EntrySize
  val PtwL2EntrySize = coreParams.PtwL2EntrySize
  val NumPerfCounters = coreParams.NumPerfCounters
  val NrExtIntr = coreParams.NrExtIntr
193
  val NrPlicIntr = NrExtIntr + 1 // ExtIntr + ECC
194

L
LinJiawei 已提交
195 196 197
  val instBytes = if (HasCExtension) 2 else 4
  val instOffsetBits = log2Ceil(instBytes)

198
  val icacheParameters = ICacheParameters(
199 200
    tagECC = Some("parity"),
    dataECC = Some("parity"),
201
    replacer = Some("setplru"),
J
jinyue110 已提交
202
    nMissEntries = 2
203 204
  )

A
Allen 已提交
205 206 207
  val l1plusCacheParameters = L1plusCacheParameters(
    tagECC = Some("secded"),
    dataECC = Some("secded"),
208
    replacer = Some("setplru"),
A
Allen 已提交
209
    nMissEntries = 8
210 211 212
  )

  val dcacheParameters = DCacheParameters(
213 214 215
    tagECC = Some("secded"),
    dataECC = Some("secded"),
    replacer = Some("setplru"),
216
    nMissEntries = 16,
A
Allen 已提交
217 218 219
    nProbeEntries = 16,
    nReleaseEntries = 16,
    nStoreReplayEntries = 16
220
  )
A
Allen 已提交
221 222

  val LRSCCycles = 100
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244


  // cache hierarchy configurations
  val l1BusDataWidth = 256

  // L2 configurations
  val L1BusWidth = 256
  val L2Size = 512 * 1024 // 512KB
  val L2BlockSize = 64
  val L2NWays = 8
  val L2NSets = L2Size / L2BlockSize / L2NWays

  // L3 configurations
  val L2BusWidth = 256
  val L3Size = 4 * 1024 * 1024 // 4MB
  val L3BlockSize = 64
  val L3NBanks = 4
  val L3NWays = 8
  val L3NSets = L3Size / L3BlockSize / L3NBanks / L3NWays

  // on chip network configurations
  val L3BusWidth = 256
245 246 247

  // icache prefetcher
  val l1plusPrefetcherParameters = L1plusPrefetcherParameters(
248
    enable = true,
249 250
    _type = "stream",
    streamParams = StreamPrefetchParameters(
251
      streamCnt = 2,
252 253 254
      streamSize = 4,
      ageWidth = 4,
      blockBytes = l1plusCacheParameters.blockBytes,
255 256
      reallocStreamOnMissInstantly = true,
      cacheName = "icache"
257 258 259 260 261 262
    )
  )

  // dcache prefetcher
  val l2PrefetcherParameters = L2PrefetcherParameters(
    enable = true,
263
    _type = "bop", // "stream" or "bop"
264 265 266 267 268
    streamParams = StreamPrefetchParameters(
      streamCnt = 4,
      streamSize = 4,
      ageWidth = 4,
      blockBytes = L2BlockSize,
269 270
      reallocStreamOnMissInstantly = true,
      cacheName = "dcache"
271 272 273 274 275
    ),
    bopParams = BOPParameters(
      rrTableEntries = 256,
      rrTagBits = 12,
      scoreBits = 5,
276
      roundMax = 50,
277 278 279 280
      badScore = 1,
      blockBytes = L2BlockSize,
      nEntries = dcacheParameters.nMissEntries * 2 // TODO: this is too large
    ),
281
  )
L
LinJiawei 已提交
282 283
}

L
LinJiawei 已提交
284
abstract class XSModule extends MultiIOModule
L
LinJiawei 已提交
285 286
  with HasXSParameter
  with HasExceptionNO
287
  with HasFPUParameters {
L
LinJiawei 已提交
288 289
  def io: Record
}
L
LinJiawei 已提交
290

291
//remove this trait after impl module logic
292 293
trait NeedImpl {
  this: RawModule =>
294
  override protected def IO[T <: Data](iodef: T): T = {
L
LinJiawei 已提交
295
    println(s"[Warn]: (${this.name}) please reomve 'NeedImpl' after implement this module")
296 297 298 299 300 301
    val io = chisel3.experimental.IO(iodef)
    io <> DontCare
    io
  }
}

L
LinJiawei 已提交
302 303 304
abstract class XSBundle extends Bundle
  with HasXSParameter

L
LinJiawei 已提交
305
case class EnviromentParameters
L
LinJiawei 已提交
306 307
(
  FPGAPlatform: Boolean = true,
Y
Yinan Xu 已提交
308
  EnableDebug: Boolean = false,
Z
zoujr 已提交
309
  EnablePerfDebug: Boolean = true,
310
  DualCore: Boolean = false
L
LinJiawei 已提交
311 312
)

313 314
class XSCore()(implicit p: config.Parameters) extends LazyModule
  with HasXSParameter
315
  with HasExeBlockHelper {
Y
Yinan Xu 已提交
316
  // outer facing nodes
J
jinyue110 已提交
317
  val frontend = LazyModule(new Frontend())
J
jinyue110 已提交
318
  val l1pluscache = LazyModule(new L1plusCache())
L
linjiawei 已提交
319
  val ptw = LazyModule(new PTW())
320
  val memBlock = LazyModule(new MemBlock(
321 322
    fastWakeUpIn = intExuConfigs.filter(_.hasCertainLatency),
    slowWakeUpIn = intExuConfigs.filter(_.hasUncertainlatency) ++ fpExuConfigs,
323
    fastWakeUpOut = Seq(),
324 325
    slowWakeUpOut = loadExuConfigs,
    numIntWakeUpFp = intExuConfigs.count(_.writeFpRf)
326
  ))
327

L
linjiawei 已提交
328 329 330
  lazy val module = new XSCoreImp(this)
}

331 332
class XSCoreImp(outer: XSCore) extends LazyModuleImp(outer)
  with HasXSParameter
333
  with HasExeBlockHelper {
Y
Yinan Xu 已提交
334
  val io = IO(new Bundle {
335
    val hartId = Input(UInt(64.W))
Y
Yinan Xu 已提交
336
    val externalInterrupt = new ExternalInterruptIO
337
    val l2_pf_enable = Output(Bool())
L
ljw 已提交
338
    val l1plus_error, icache_error, dcache_error = Output(new L1CacheErrorInfo)
Y
Yinan Xu 已提交
339
  })
340

341 342
  val difftestIO = IO(new DifftestBundle())
  difftestIO <> DontCare
343

344 345
  val trapIO = IO(new TrapIO())
  trapIO <> DontCare
346

Z
ZhangZifei 已提交
347
  println(s"FPGAPlatform:${env.FPGAPlatform} EnableDebug:${env.EnableDebug}")
W
William Wang 已提交
348
  AddressSpace.checkMemmap()
349
  AddressSpace.printMemmap()
Z
ZhangZifei 已提交
350

L
LinJiawei 已提交
351
  // to fast wake up fp, mem rs
352 353
  val intBlockFastWakeUp = intExuConfigs.filter(_.hasCertainLatency)
  val intBlockSlowWakeUp = intExuConfigs.filter(_.hasUncertainlatency)
L
LinJiawei 已提交
354

355
  val ctrlBlock = Module(new CtrlBlock)
L
LinJiawei 已提交
356
  val integerBlock = Module(new IntegerBlock(
357
    fastWakeUpIn = Seq(),
358
    slowWakeUpIn = fpExuConfigs.filter(_.writeIntRf) ++ loadExuConfigs,
359
    memFastWakeUpIn  = loadExuConfigs,
360 361
    fastWakeUpOut = intBlockFastWakeUp,
    slowWakeUpOut = intBlockSlowWakeUp
L
LinJiawei 已提交
362 363
  ))
  val floatBlock = Module(new FloatBlock(
364 365
    intSlowWakeUpIn = intExuConfigs.filter(_.writeFpRf),
    memSlowWakeUpIn = loadExuConfigs,
366 367
    fastWakeUpOut = Seq(),
    slowWakeUpOut = fpExuConfigs
L
LinJiawei 已提交
368
  ))
L
linjiawei 已提交
369

J
jinyue110 已提交
370
  val frontend = outer.frontend.module
371
  val memBlock = outer.memBlock.module
J
jinyue110 已提交
372
  val l1pluscache = outer.l1pluscache.module
L
linjiawei 已提交
373
  val ptw = outer.ptw.module
L
linjiawei 已提交
374

L
ljw 已提交
375 376
  io.l1plus_error <> l1pluscache.io.error
  io.icache_error <> frontend.io.error
377 378
  io.dcache_error <> memBlock.io.error

379
  frontend.io.backend <> ctrlBlock.io.frontend
Y
Yinan Xu 已提交
380 381
  frontend.io.sfence <> integerBlock.io.fenceio.sfence
  frontend.io.tlbCsr <> integerBlock.io.csrio.tlb
382
  frontend.io.csrCtrl <> integerBlock.io.csrio.customCtrl
J
jinyue110 已提交
383

L
Lingrui98 已提交
384 385 386 387
  frontend.io.icacheMemAcq <> l1pluscache.io.req
  l1pluscache.io.resp <> frontend.io.icacheMemGrant
  l1pluscache.io.flush := frontend.io.l1plusFlush
  frontend.io.fencei := integerBlock.io.fenceio.fencei
388 389 390 391 392 393 394

  ctrlBlock.io.fromIntBlock <> integerBlock.io.toCtrlBlock
  ctrlBlock.io.fromFpBlock <> floatBlock.io.toCtrlBlock
  ctrlBlock.io.fromLsBlock <> memBlock.io.toCtrlBlock
  ctrlBlock.io.toIntBlock <> integerBlock.io.fromCtrlBlock
  ctrlBlock.io.toFpBlock <> floatBlock.io.fromCtrlBlock
  ctrlBlock.io.toLsBlock <> memBlock.io.fromCtrlBlock
395
  ctrlBlock.io.csrCtrl <> integerBlock.io.csrio.customCtrl
396

397 398
  val memBlockWakeUpInt = memBlock.io.wakeUpOutInt.slow.map(WireInit(_))
  val memBlockWakeUpFp = memBlock.io.wakeUpOutFp.slow.map(WireInit(_))
399 400
  memBlock.io.wakeUpOutInt.slow.foreach(_.ready := true.B)
  memBlock.io.wakeUpOutFp.slow.foreach(_.ready := true.B)
L
LinJiawei 已提交
401

402
  fpExuConfigs.zip(floatBlock.io.wakeUpOut.slow).filterNot(_._1.writeIntRf).map(_._2.ready := true.B)
403 404 405
  val fpBlockWakeUpInt = fpExuConfigs
    .zip(floatBlock.io.wakeUpOut.slow)
    .filter(_._1.writeIntRf)
406
    .map(_._2)
L
LinJiawei 已提交
407

408
  intExuConfigs.zip(integerBlock.io.wakeUpOut.slow).filterNot(_._1.writeFpRf).map(_._2.ready := true.B)
409 410 411
  val intBlockWakeUpFp = intExuConfigs.filter(_.hasUncertainlatency)
    .zip(integerBlock.io.wakeUpOut.slow)
    .filter(_._1.writeFpRf)
412
    .map(_._2)
L
LinJiawei 已提交
413

414 415
  integerBlock.io.wakeUpIn.slow <> fpBlockWakeUpInt ++ memBlockWakeUpInt
  integerBlock.io.toMemBlock <> memBlock.io.fromIntBlock
416
  integerBlock.io.memFastWakeUp <> memBlock.io.ldFastWakeUpInt
L
LinJiawei 已提交
417

418 419
  floatBlock.io.intWakeUpFp <> intBlockWakeUpFp
  floatBlock.io.memWakeUpFp <> memBlockWakeUpFp
420
  floatBlock.io.toMemBlock <> memBlock.io.fromFpBlock
L
LinJiawei 已提交
421 422

  val wakeUpMem = Seq(
423 424
    integerBlock.io.wakeUpOut,
    floatBlock.io.wakeUpOut,
L
LinJiawei 已提交
425 426
  )
  memBlock.io.wakeUpIn.fastUops <> wakeUpMem.flatMap(_.fastUops)
427
  memBlock.io.wakeUpIn.fast <> wakeUpMem.flatMap(_.fast)
428 429 430
  // Note: 'WireInit' is used to block 'ready's from memBlock,
  // we don't need 'ready's from memBlock
  memBlock.io.wakeUpIn.slow <> wakeUpMem.flatMap(_.slow.map(x => WireInit(x)))
431
  memBlock.io.intWakeUpFp <> floatBlock.io.intWakeUpOut
L
LinJiawei 已提交
432

433
  integerBlock.io.csrio.hartId <> io.hartId
434 435
  integerBlock.io.csrio.perf <> DontCare
  integerBlock.io.csrio.perf.retiredInstr <> ctrlBlock.io.roqio.toCSR.perfinfo.retiredInstr
436 437 438 439 440
  integerBlock.io.csrio.perf.bpuInfo <> ctrlBlock.io.perfInfo.bpuInfo
  integerBlock.io.csrio.perf.ctrlInfo <> ctrlBlock.io.perfInfo.ctrlInfo
  integerBlock.io.csrio.perf.memInfo <> memBlock.io.memInfo
  integerBlock.io.csrio.perf.frontendInfo <> frontend.io.frontendInfo

441 442 443 444
  integerBlock.io.csrio.fpu.fflags <> ctrlBlock.io.roqio.toCSR.fflags
  integerBlock.io.csrio.fpu.isIllegal := false.B
  integerBlock.io.csrio.fpu.dirty_fs <> ctrlBlock.io.roqio.toCSR.dirty_fs
  integerBlock.io.csrio.fpu.frm <> floatBlock.io.frm
Y
Yinan Xu 已提交
445
  integerBlock.io.csrio.exception <> ctrlBlock.io.roqio.exception
L
LinJiawei 已提交
446
  integerBlock.io.csrio.isXRet <> ctrlBlock.io.roqio.toCSR.isXRet
447
  integerBlock.io.csrio.trapTarget <> ctrlBlock.io.roqio.toCSR.trapTarget
Y
Yinan Xu 已提交
448
  integerBlock.io.csrio.interrupt <> ctrlBlock.io.roqio.toCSR.intrBitSet
Y
Yinan Xu 已提交
449 450
  integerBlock.io.csrio.memExceptionVAddr <> memBlock.io.lsqio.exceptionAddr.vaddr
  integerBlock.io.csrio.externalInterrupt <> io.externalInterrupt
451

Y
Yinan Xu 已提交
452 453 454
  integerBlock.io.fenceio.sfence <> memBlock.io.sfence
  integerBlock.io.fenceio.sbuffer <> memBlock.io.fenceToSbuffer

455
  memBlock.io.csrCtrl <> integerBlock.io.csrio.customCtrl
456
  memBlock.io.tlbCsr <> integerBlock.io.csrio.tlb
457
  memBlock.io.lsqio.roq <> ctrlBlock.io.roqio.lsq
458 459 460
  memBlock.io.lsqio.exceptionAddr.lsIdx.lqIdx := ctrlBlock.io.roqio.exception.bits.uop.lqIdx
  memBlock.io.lsqio.exceptionAddr.lsIdx.sqIdx := ctrlBlock.io.roqio.exception.bits.uop.sqIdx
  memBlock.io.lsqio.exceptionAddr.isStore := CommitType.lsInstIsStore(ctrlBlock.io.roqio.exception.bits.uop.ctrl.commitType)
461

462 463 464 465 466 467 468 469
  val itlbRepeater = Module(new PTWRepeater())
  val dtlbRepeater = Module(new PTWRepeater())
  itlbRepeater.io.tlb <> frontend.io.ptw
  dtlbRepeater.io.tlb <> memBlock.io.ptw
  itlbRepeater.io.sfence <> integerBlock.io.fenceio.sfence
  dtlbRepeater.io.sfence <> integerBlock.io.fenceio.sfence
  ptw.io.tlb(0) <> dtlbRepeater.io.ptw
  ptw.io.tlb(1) <> itlbRepeater.io.ptw
Y
Yinan Xu 已提交
470
  ptw.io.sfence <> integerBlock.io.fenceio.sfence
471
  ptw.io.csr <> integerBlock.io.csrio.tlb
472

473 474
  // if l2 prefetcher use stream prefetch, it should be placed in XSCore
  assert(l2PrefetcherParameters._type == "bop")
475
  io.l2_pf_enable := integerBlock.io.csrio.customCtrl.l2_pf_enable
476

L
LinJiawei 已提交
477
  if (!env.FPGAPlatform) {
478 479 480 481 482
    val id = hartIdCore()
    difftestIO.fromSbuffer <> memBlock.difftestIO.fromSbuffer
    difftestIO.fromSQ <> memBlock.difftestIO.fromSQ
    difftestIO.fromCSR <> integerBlock.difftestIO.fromCSR
    difftestIO.fromRoq <> ctrlBlock.difftestIO.fromRoq
483
    difftestIO.fromAtomic <> memBlock.difftestIO.fromAtomic
484
    difftestIO.fromPtw <> ptw.difftestIO
485
    trapIO <> ctrlBlock.trapIO
486 487 488 489 490 491 492 493

    val debugIntReg, debugFpReg = WireInit(VecInit(Seq.fill(32)(0.U(XLEN.W))))
    ExcitingUtils.addSink(debugIntReg, s"DEBUG_INT_ARCH_REG$id", ExcitingUtils.Debug)
    ExcitingUtils.addSink(debugFpReg, s"DEBUG_FP_ARCH_REG$id", ExcitingUtils.Debug)
    val debugArchReg = WireInit(VecInit(debugIntReg ++ debugFpReg))
    difftestIO.fromXSCore.r := debugArchReg
  }

494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515
  val l1plus_reset_gen = Module(new ResetGen(1))
  l1pluscache.reset := l1plus_reset_gen.io.out

  val ptw_reset_gen = Module(new ResetGen(2))
  ptw.reset := ptw_reset_gen.io.out
  itlbRepeater.reset := ptw_reset_gen.io.out
  dtlbRepeater.reset := ptw_reset_gen.io.out

  val memBlock_reset_gen = Module(new ResetGen(3))
  memBlock.reset := memBlock_reset_gen.io.out

  val intBlock_reset_gen = Module(new ResetGen(4))
  integerBlock.reset := intBlock_reset_gen.io.out

  val fpBlock_reset_gen = Module(new ResetGen(5))
  floatBlock.reset := fpBlock_reset_gen.io.out

  val ctrlBlock_reset_gen = Module(new ResetGen(6))
  ctrlBlock.reset := ctrlBlock_reset_gen.io.out

  val frontend_reset_gen = Module(new ResetGen(7))
  frontend.reset := frontend_reset_gen.io.out
L
LinJiawei 已提交
516
}