XSCore.scala 16.6 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.{DCache, InstrUncache, DCacheParameters, ICache, ICacheParameters, L1plusCache, L1plusCacheParameters, PTW, PTWRepeater, Uncache, MemoryOpConstants, MissReq}
14
import xiangshan.cache.prefetch._
L
linjiawei 已提交
15
import chipsalliance.rocketchip.config
L
LinJiawei 已提交
16 17 18
import freechips.rocketchip.diplomacy.{AddressSet, LazyModule, LazyModuleImp}
import freechips.rocketchip.tilelink.{TLBuffer, TLBundleParameters, TLCacheCork, TLClientNode, TLFilter, TLIdentityNode, TLToAXI4, TLWidthWidget, TLXbar}
import freechips.rocketchip.devices.tilelink.{DevNullParams, TLError}
L
LinJiawei 已提交
19
import sifive.blocks.inclusivecache.{CacheParameters, InclusiveCache, InclusiveCacheMicroParameters}
L
LinJiawei 已提交
20 21
import freechips.rocketchip.amba.axi4.{AXI4Deinterleaver, AXI4Fragmenter, AXI4IdIndexer, AXI4IdentityNode, AXI4ToTL, AXI4UserYanker}
import freechips.rocketchip.tile.HasFPUParameters
22
import sifive.blocks.inclusivecache.PrefetcherIO
L
LinJiawei 已提交
23
import utils._
L
LinJiawei 已提交
24

25 26
object hartIdCore extends (() => Int) {
  var x = 0
27

28 29
  def apply(): Int = {
    x = x + 1
30
    x - 1
31 32 33
  }
}

L
LinJiawei 已提交
34 35 36 37 38 39 40 41 42 43 44
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,
45
  PAddrBits: Int = 40,
L
LinJiawei 已提交
46
  HasFPU: Boolean = true,
W
wangkaifan 已提交
47
  FetchWidth: Int = 8,
L
LinJiawei 已提交
48
  EnableBPU: Boolean = true,
L
Lingrui98 已提交
49
  EnableBPD: Boolean = true,
G
GouLingrui 已提交
50
  EnableRAS: Boolean = true,
L
Lingrui98 已提交
51
  EnableLB: Boolean = false,
52
  EnableLoop: Boolean = true,
L
Lingrui98 已提交
53
  EnableSC: Boolean = false,
Z
ZhangZifei 已提交
54
  EnbaleTlbDebug: Boolean = false,
J
jinyue110 已提交
55 56
  EnableJal: Boolean = false,
  EnableUBTB: Boolean = true,
L
LinJiawei 已提交
57
  HistoryLength: Int = 64,
58
  BtbSize: Int = 2048,
L
LinJiawei 已提交
59 60 61 62 63 64
  JbtacSize: Int = 1024,
  JbtacBanks: Int = 8,
  RasSize: Int = 16,
  CacheLineSize: Int = 512,
  UBtbWays: Int = 16,
  BtbWays: Int = 2,
S
Steve Gou 已提交
65

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

trait HasXSParameter {
L
LinJiawei 已提交
118 119 120 121

  val core = Parameters.get.coreParameters
  val env = Parameters.get.envParameters

L
LinJiawei 已提交
122 123 124
  val XLEN = 64
  val minFLen = 32
  val fLen = 64
125

L
LinJiawei 已提交
126
  def xLen = 64
127

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

L
LinJiawei 已提交
200 201 202
  val instBytes = if (HasCExtension) 2 else 4
  val instOffsetBits = log2Ceil(instBytes)

203
  val icacheParameters = ICacheParameters(
204 205
    tagECC = Some("parity"),
    dataECC = Some("parity"),
J
jinyue110 已提交
206
    replacer = Some("setlru"),
J
jinyue110 已提交
207
    nMissEntries = 2
208 209
  )

A
Allen 已提交
210 211 212 213
  val l1plusCacheParameters = L1plusCacheParameters(
    tagECC = Some("secded"),
    dataECC = Some("secded"),
    nMissEntries = 8
214 215 216
  )

  val dcacheParameters = DCacheParameters(
A
allen 已提交
217 218
    tagECC = Some("none"),
    dataECC = Some("none"),
219
    nMissEntries = 16,
A
Allen 已提交
220 221 222
    nProbeEntries = 16,
    nReleaseEntries = 16,
    nStoreReplayEntries = 16
223
  )
A
Allen 已提交
224 225

  val LRSCCycles = 100
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247


  // 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
248 249 250

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

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

287 288
trait HasXSLog {
  this: RawModule =>
289
  implicit val moduleName: String = this.name
L
LinJiawei 已提交
290 291
}

L
LinJiawei 已提交
292
abstract class XSModule extends MultiIOModule
L
LinJiawei 已提交
293 294
  with HasXSParameter
  with HasExceptionNO
L
LinJiawei 已提交
295
  with HasXSLog
296
  with HasFPUParameters {
L
LinJiawei 已提交
297 298
  def io: Record
}
L
LinJiawei 已提交
299

300
//remove this trait after impl module logic
301 302
trait NeedImpl {
  this: RawModule =>
303
  override protected def IO[T <: Data](iodef: T): T = {
L
LinJiawei 已提交
304
    println(s"[Warn]: (${this.name}) please reomve 'NeedImpl' after implement this module")
305 306 307 308 309 310
    val io = chisel3.experimental.IO(iodef)
    io <> DontCare
    io
  }
}

L
LinJiawei 已提交
311 312 313
abstract class XSBundle extends Bundle
  with HasXSParameter

L
LinJiawei 已提交
314
case class EnviromentParameters
L
LinJiawei 已提交
315 316
(
  FPGAPlatform: Boolean = true,
Y
Yinan Xu 已提交
317
  EnableDebug: Boolean = false,
Z
zoujr 已提交
318
  EnablePerfDebug: Boolean = true,
319
  DualCore: Boolean = false
L
LinJiawei 已提交
320 321
)

W
William Wang 已提交
322 323 324 325 326 327 328
// object AddressSpace extends HasXSParameter {
//   // (start, size)
//   // address out of MMIO will be considered as DRAM
//   def mmio = List(
//     (0x00000000L, 0x40000000L),  // internal devices, such as CLINT and PLIC
//     (0x40000000L, 0x40000000L)   // external devices
//   )
L
LinJiawei 已提交
329

W
William Wang 已提交
330 331 332 333 334 335
//   def isMMIO(addr: UInt): Bool = mmio.map(range => {
//     require(isPow2(range._2))
//     val bits = log2Up(range._2)
//     (addr ^ range._1.U)(PAddrBits-1, bits) === 0.U
//   }).reduce(_ || _)
// }
L
LinJiawei 已提交
336 337


338 339
class XSCore()(implicit p: config.Parameters) extends LazyModule
  with HasXSParameter
340
  with HasExeBlockHelper {
Y
Yinan Xu 已提交
341
  // outer facing nodes
J
jinyue110 已提交
342
  val frontend = LazyModule(new Frontend())
J
jinyue110 已提交
343
  val l1pluscache = LazyModule(new L1plusCache())
L
linjiawei 已提交
344
  val ptw = LazyModule(new PTW())
345
  val memBlock = LazyModule(new MemBlock(
346 347
    fastWakeUpIn = intExuConfigs.filter(_.hasCertainLatency),
    slowWakeUpIn = intExuConfigs.filter(_.hasUncertainlatency) ++ fpExuConfigs,
348
    fastWakeUpOut = Seq(),
349 350
    slowWakeUpOut = loadExuConfigs,
    numIntWakeUpFp = intExuConfigs.count(_.writeFpRf)
351
  ))
352

L
linjiawei 已提交
353 354 355
  lazy val module = new XSCoreImp(this)
}

356 357
class XSCoreImp(outer: XSCore) extends LazyModuleImp(outer)
  with HasXSParameter
358
  with HasExeBlockHelper {
Y
Yinan Xu 已提交
359
  val io = IO(new Bundle {
360
    val hartId = Input(UInt(64.W))
Y
Yinan Xu 已提交
361
    val externalInterrupt = new ExternalInterruptIO
362
    val l2_pf_enable = Output(Bool())
Y
Yinan Xu 已提交
363
  })
364

365 366
  val difftestIO = IO(new DifftestBundle())
  difftestIO <> DontCare
367

368 369
  val trapIO = IO(new TrapIO())
  trapIO <> DontCare
370

Z
ZhangZifei 已提交
371
  println(s"FPGAPlatform:${env.FPGAPlatform} EnableDebug:${env.EnableDebug}")
W
William Wang 已提交
372
  AddressSpace.checkMemmap()
373
  AddressSpace.printMemmap()
Z
ZhangZifei 已提交
374

L
LinJiawei 已提交
375
  // to fast wake up fp, mem rs
376 377
  val intBlockFastWakeUp = intExuConfigs.filter(_.hasCertainLatency)
  val intBlockSlowWakeUp = intExuConfigs.filter(_.hasUncertainlatency)
L
LinJiawei 已提交
378

379
  val ctrlBlock = Module(new CtrlBlock)
L
LinJiawei 已提交
380
  val integerBlock = Module(new IntegerBlock(
381
    fastWakeUpIn = Seq(),
382 383 384
    slowWakeUpIn = fpExuConfigs.filter(_.writeIntRf) ++ loadExuConfigs,
    fastWakeUpOut = intBlockFastWakeUp,
    slowWakeUpOut = intBlockSlowWakeUp
L
LinJiawei 已提交
385 386
  ))
  val floatBlock = Module(new FloatBlock(
387 388
    intSlowWakeUpIn = intExuConfigs.filter(_.writeFpRf),
    memSlowWakeUpIn = loadExuConfigs,
389 390
    fastWakeUpOut = Seq(),
    slowWakeUpOut = fpExuConfigs
L
LinJiawei 已提交
391
  ))
L
linjiawei 已提交
392

J
jinyue110 已提交
393
  val frontend = outer.frontend.module
394
  val memBlock = outer.memBlock.module
J
jinyue110 已提交
395
  val l1pluscache = outer.l1pluscache.module
L
linjiawei 已提交
396
  val ptw = outer.ptw.module
L
linjiawei 已提交
397

398
  frontend.io.backend <> ctrlBlock.io.frontend
Y
Yinan Xu 已提交
399 400
  frontend.io.sfence <> integerBlock.io.fenceio.sfence
  frontend.io.tlbCsr <> integerBlock.io.csrio.tlb
401
  frontend.io.csrCtrl <> integerBlock.io.csrio.customCtrl
J
jinyue110 已提交
402

L
Lingrui98 已提交
403 404 405 406
  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
407 408 409 410 411 412 413

  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
414
  ctrlBlock.io.csrCtrl <> integerBlock.io.csrio.customCtrl
415

416 417 418 419
  val memBlockWakeUpInt = memBlock.io.wakeUpOutInt.slow.map(x => intOutValid(x))
  val memBlockWakeUpFp = memBlock.io.wakeUpOutFp.slow.map(x => fpOutValid(x))
  memBlock.io.wakeUpOutInt.slow.foreach(_.ready := true.B)
  memBlock.io.wakeUpOutFp.slow.foreach(_.ready := true.B)
L
LinJiawei 已提交
420

421
  fpExuConfigs.zip(floatBlock.io.wakeUpOut.slow).filterNot(_._1.writeIntRf).map(_._2.ready := true.B)
422 423 424
  val fpBlockWakeUpInt = fpExuConfigs
    .zip(floatBlock.io.wakeUpOut.slow)
    .filter(_._1.writeIntRf)
425
    .map(_._2).map(x => intOutValid(x, connectReady = true))
L
LinJiawei 已提交
426

427
  intExuConfigs.zip(integerBlock.io.wakeUpOut.slow).filterNot(_._1.writeFpRf).map(_._2.ready := true.B)
428 429 430
  val intBlockWakeUpFp = intExuConfigs.filter(_.hasUncertainlatency)
    .zip(integerBlock.io.wakeUpOut.slow)
    .filter(_._1.writeFpRf)
431
    .map(_._2)
L
LinJiawei 已提交
432

433 434
  integerBlock.io.wakeUpIn.slow <> fpBlockWakeUpInt ++ memBlockWakeUpInt
  integerBlock.io.toMemBlock <> memBlock.io.fromIntBlock
L
LinJiawei 已提交
435

436 437
  floatBlock.io.intWakeUpFp <> intBlockWakeUpFp
  floatBlock.io.memWakeUpFp <> memBlockWakeUpFp
438
  floatBlock.io.toMemBlock <> memBlock.io.fromFpBlock
L
LinJiawei 已提交
439 440

  val wakeUpMem = Seq(
441 442
    integerBlock.io.wakeUpOut,
    floatBlock.io.wakeUpOut,
L
LinJiawei 已提交
443 444
  )
  memBlock.io.wakeUpIn.fastUops <> wakeUpMem.flatMap(_.fastUops)
445
  memBlock.io.wakeUpIn.fast <> wakeUpMem.flatMap(_.fast)
446 447 448
  // 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)))
449
  memBlock.io.intWakeUpFp <> floatBlock.io.intWakeUpOut
L
LinJiawei 已提交
450

451
  integerBlock.io.csrio.hartId <> io.hartId
452 453 454 455 456 457
  integerBlock.io.csrio.perf <> DontCare
  integerBlock.io.csrio.perf.retiredInstr <> ctrlBlock.io.roqio.toCSR.perfinfo.retiredInstr
  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 已提交
458
  integerBlock.io.csrio.exception <> ctrlBlock.io.roqio.exception
L
LinJiawei 已提交
459
  integerBlock.io.csrio.isXRet <> ctrlBlock.io.roqio.toCSR.isXRet
460
  integerBlock.io.csrio.trapTarget <> ctrlBlock.io.roqio.toCSR.trapTarget
Y
Yinan Xu 已提交
461
  integerBlock.io.csrio.interrupt <> ctrlBlock.io.roqio.toCSR.intrBitSet
Y
Yinan Xu 已提交
462 463
  integerBlock.io.csrio.memExceptionVAddr <> memBlock.io.lsqio.exceptionAddr.vaddr
  integerBlock.io.csrio.externalInterrupt <> io.externalInterrupt
464

Y
Yinan Xu 已提交
465 466 467
  integerBlock.io.fenceio.sfence <> memBlock.io.sfence
  integerBlock.io.fenceio.sbuffer <> memBlock.io.fenceToSbuffer

468
  memBlock.io.tlbCsr <> RegNext(integerBlock.io.csrio.tlb)
469
  memBlock.io.lsqio.roq <> ctrlBlock.io.roqio.lsq
470 471 472
  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)
473

474 475 476 477 478 479 480 481
  val itlbRepester = Module(new PTWRepeater())
  val dtlbRepester = Module(new PTWRepeater())
  itlbRepester.io.tlb <> frontend.io.ptw
  dtlbRepester.io.tlb <> memBlock.io.ptw
  itlbRepester.io.sfence <> integerBlock.io.fenceio.sfence
  dtlbRepester.io.sfence <> integerBlock.io.fenceio.sfence
  ptw.io.tlb(0) <> dtlbRepester.io.ptw
  ptw.io.tlb(1) <> itlbRepester.io.ptw
Y
Yinan Xu 已提交
482
  ptw.io.sfence <> integerBlock.io.fenceio.sfence
483
  ptw.io.csr <> integerBlock.io.csrio.tlb
484

485 486 487
  // if l2 prefetcher use stream prefetch, it should be placed in XSCore
  assert(l2PrefetcherParameters._type == "bop")
  io.l2_pf_enable := RegNext(integerBlock.io.csrio.customCtrl.l2_pf_enable)
488

L
LinJiawei 已提交
489
  if (!env.FPGAPlatform) {
490 491 492 493 494
    val id = hartIdCore()
    difftestIO.fromSbuffer <> memBlock.difftestIO.fromSbuffer
    difftestIO.fromSQ <> memBlock.difftestIO.fromSQ
    difftestIO.fromCSR <> integerBlock.difftestIO.fromCSR
    difftestIO.fromRoq <> ctrlBlock.difftestIO.fromRoq
495
    difftestIO.fromAtomic <> memBlock.difftestIO.fromAtomic
496
    difftestIO.fromPtw <> ptw.difftestIO
497
    trapIO <> ctrlBlock.trapIO
498 499 500 501 502 503 504 505

    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
  }

L
LinJiawei 已提交
506
}