XSCore.scala 19.2 KB
Newer Older
L
Lemover 已提交
1 2
/***************************************************************************************
* Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences
Y
Yinan Xu 已提交
3
* Copyright (c) 2020-2021 Peng Cheng Laboratory
L
Lemover 已提交
4 5 6 7 8 9 10 11 12 13 14 15 16
*
* XiangShan is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*          http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
*
* See the Mulan PSL v2 for more details.
***************************************************************************************/

L
LinJiawei 已提交
17 18
package xiangshan

L
linjiawei 已提交
19
import chipsalliance.rocketchip.config
20
import chipsalliance.rocketchip.config.Parameters
21 22
import chisel3._
import chisel3.util._
23
import freechips.rocketchip.diplomacy.{BundleBridgeSource, LazyModule, LazyModuleImp}
J
Jiawei Lin 已提交
24
import freechips.rocketchip.interrupts.{IntSinkNode, IntSinkPortSimple}
L
LinJiawei 已提交
25
import freechips.rocketchip.tile.HasFPUParameters
J
Jiawei Lin 已提交
26
import freechips.rocketchip.tilelink.TLBuffer
J
Jiawei Lin 已提交
27
import system.HasSoCParameter
L
LinJiawei 已提交
28
import utils._
29 30 31 32 33 34
import xiangshan.backend._
import xiangshan.backend.exu.{ExuConfig, Wb2Ctrl, WbArbiterWrapper}
import xiangshan.cache.mmu._
import xiangshan.frontend._

import scala.collection.mutable.ListBuffer
L
LinJiawei 已提交
35

36
abstract class XSModule(implicit val p: Parameters) extends Module
L
LinJiawei 已提交
37
  with HasXSParameter
38
  with HasFPUParameters
L
LinJiawei 已提交
39

40
//remove this trait after impl module logic
41 42
trait NeedImpl {
  this: RawModule =>
43
  override protected def IO[T <: Data](iodef: T): T = {
L
LinJiawei 已提交
44
    println(s"[Warn]: (${this.name}) please reomve 'NeedImpl' after implement this module")
45 46 47 48 49 50
    val io = chisel3.experimental.IO(iodef)
    io <> DontCare
    io
  }
}

51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
class WritebackSourceParams(
  var exuConfigs: Seq[Seq[ExuConfig]] = Seq()
 ) {
  def length: Int = exuConfigs.length
  def ++(that: WritebackSourceParams): WritebackSourceParams = {
    new WritebackSourceParams(exuConfigs ++ that.exuConfigs)
  }
}

trait HasWritebackSource {
  val writebackSourceParams: Seq[WritebackSourceParams]
  final def writebackSource(sourceMod: HasWritebackSourceImp): Seq[Seq[Valid[ExuOutput]]] = {
    require(sourceMod.writebackSource.isDefined, "should not use Valid[ExuOutput]")
    val source = sourceMod.writebackSource.get
    require(source.length == writebackSourceParams.length, "length mismatch between sources")
    for ((s, p) <- source.zip(writebackSourceParams)) {
      require(s.length == p.length, "params do not match with the exuOutput")
    }
    source
  }
  final def writebackSource1(sourceMod: HasWritebackSourceImp): Seq[Seq[DecoupledIO[ExuOutput]]] = {
    require(sourceMod.writebackSource1.isDefined, "should not use DecoupledIO[ExuOutput]")
    val source = sourceMod.writebackSource1.get
    require(source.length == writebackSourceParams.length, "length mismatch between sources")
    for ((s, p) <- source.zip(writebackSourceParams)) {
      require(s.length == p.length, "params do not match with the exuOutput")
    }
    source
  }
  val writebackSourceImp: HasWritebackSourceImp
}

trait HasWritebackSourceImp {
  def writebackSource: Option[Seq[Seq[Valid[ExuOutput]]]] = None
  def writebackSource1: Option[Seq[Seq[DecoupledIO[ExuOutput]]]] = None
}

trait HasWritebackSink {
  // Caches all sources. The selected source will be the one with smallest length.
  var writebackSinks = ListBuffer.empty[(Seq[HasWritebackSource], Seq[Int])]
  def addWritebackSink(source: Seq[HasWritebackSource], index: Option[Seq[Int]] = None): HasWritebackSink = {
    val realIndex = if (index.isDefined) index.get else Seq.fill(source.length)(0)
    writebackSinks += ((source, realIndex))
    this
  }

  def writebackSinksParams: Seq[WritebackSourceParams] = {
    writebackSinks.map{ case (s, i) => s.zip(i).map(x => x._1.writebackSourceParams(x._2)).reduce(_ ++ _) }
  }
  final def writebackSinksMod(
     thisMod: Option[HasWritebackSource] = None,
     thisModImp: Option[HasWritebackSourceImp] = None
   ): Seq[Seq[HasWritebackSourceImp]] = {
    require(thisMod.isDefined == thisModImp.isDefined)
    writebackSinks.map(_._1.map(source =>
      if (thisMod.isDefined && source == thisMod.get) thisModImp.get else source.writebackSourceImp)
    )
  }
  final def writebackSinksImp(
    thisMod: Option[HasWritebackSource] = None,
    thisModImp: Option[HasWritebackSourceImp] = None
  ): Seq[Seq[ValidIO[ExuOutput]]] = {
    val sourceMod = writebackSinksMod(thisMod, thisModImp)
    writebackSinks.zip(sourceMod).map{ case ((s, i), m) =>
      s.zip(i).zip(m).flatMap(x => x._1._1.writebackSource(x._2)(x._1._2))
    }
  }
  def selWritebackSinks(func: WritebackSourceParams => Int): Int = {
    writebackSinksParams.zipWithIndex.minBy(params => func(params._1))._2
  }
  def generateWritebackIO(
    thisMod: Option[HasWritebackSource] = None,
    thisModImp: Option[HasWritebackSourceImp] = None
   ): Unit
}

127
abstract class XSBundle(implicit val p: Parameters) extends Bundle
L
LinJiawei 已提交
128 129
  with HasXSParameter

130
abstract class XSCoreBase()(implicit p: config.Parameters) extends LazyModule
131
  with HasXSParameter with HasExuWbHelper
132
{
J
Jiawei Lin 已提交
133 134 135
  // interrupt sinks
  val clint_int_sink = IntSinkNode(IntSinkPortSimple(1, 2))
  val debug_int_sink = IntSinkNode(IntSinkPortSimple(1, 1))
136
  val plic_int_sink = IntSinkNode(IntSinkPortSimple(2, 1))
Y
Yinan Xu 已提交
137
  // outer facing nodes
J
jinyue110 已提交
138
  val frontend = LazyModule(new Frontend())
139
  val ptw = LazyModule(new L2TLBWrapper())
J
Jiawei Lin 已提交
140
  val ptw_to_l2_buffer = LazyModule(new TLBuffer)
141
  val csrOut = BundleBridgeSource(Some(() => new DistributedCSRIO()))
142

J
Jiawei Lin 已提交
143 144
  ptw_to_l2_buffer.node := ptw.node

145 146 147
  val wbArbiter = LazyModule(new WbArbiterWrapper(exuConfigs, NRIntWritePorts, NRFpWritePorts))
  val intWbPorts = wbArbiter.intWbPorts
  val fpWbPorts = wbArbiter.fpWbPorts
148

149 150 151 152 153
  // TODO: better RS organization
  // generate rs according to number of function units
  require(exuParameters.JmpCnt == 1)
  require(exuParameters.MduCnt <= exuParameters.AluCnt && exuParameters.MduCnt > 0)
  require(exuParameters.FmiscCnt <= exuParameters.FmacCnt && exuParameters.FmiscCnt > 0)
154
  require(exuParameters.LduCnt == exuParameters.StuCnt) // TODO: remove this limitation
155

156 157 158
  // one RS every 2 MDUs
  val schedulePorts = Seq(
    // exuCfg, numDeq, intFastWakeupTarget, fpFastWakeupTarget
159
    Seq(
160
      (AluExeUnitCfg, exuParameters.AluCnt, Seq(AluExeUnitCfg, LdExeUnitCfg, StaExeUnitCfg), Seq()),
161
      (MulDivExeUnitCfg, exuParameters.MduCnt, Seq(AluExeUnitCfg, MulDivExeUnitCfg), Seq()),
162 163 164 165
      (JumpCSRExeUnitCfg, 1, Seq(), Seq()),
      (LdExeUnitCfg, exuParameters.LduCnt, Seq(AluExeUnitCfg, LdExeUnitCfg), Seq()),
      (StaExeUnitCfg, exuParameters.StuCnt, Seq(), Seq()),
      (StdExeUnitCfg, exuParameters.StuCnt, Seq(), Seq())
166 167 168 169 170
    ),
    Seq(
      (FmacExeUnitCfg, exuParameters.FmacCnt, Seq(), Seq(FmacExeUnitCfg, FmiscExeUnitCfg)),
      (FmiscExeUnitCfg, exuParameters.FmiscCnt, Seq(), Seq())
    )
171
  )
172 173 174 175 176 177 178 179 180 181 182 183 184 185

  // should do outer fast wakeup ports here
  val otherFastPorts = schedulePorts.zipWithIndex.map { case (sche, i) =>
    val otherCfg = schedulePorts.zipWithIndex.filter(_._2 != i).map(_._1).reduce(_ ++ _)
    val outerPorts = sche.map(cfg => {
      // exe units from this scheduler need fastUops from exeunits
      val outerWakeupInSche = sche.filter(_._1.wakeupFromExu)
      val intraIntScheOuter = outerWakeupInSche.filter(_._3.contains(cfg._1)).map(_._1)
      val intraFpScheOuter = outerWakeupInSche.filter(_._4.contains(cfg._1)).map(_._1)
      // exe units from other schedulers need fastUop from outside
      val otherIntSource = otherCfg.filter(_._3.contains(cfg._1)).map(_._1)
      val otherFpSource = otherCfg.filter(_._4.contains(cfg._1)).map(_._1)
      val intSource = findInWbPorts(intWbPorts, intraIntScheOuter ++ otherIntSource)
      val fpSource = findInWbPorts(fpWbPorts, intraFpScheOuter ++ otherFpSource)
186
      getFastWakeupIndex(cfg._1, intSource, fpSource, intWbPorts.length).sorted
187 188 189 190 191
    })
    println(s"inter-scheduler wakeup sources for $i: $outerPorts")
    outerPorts
  }

192
  // allow mdu and fmisc to have 2*numDeq enqueue ports
193 194
  val intDpPorts = (0 until exuParameters.AluCnt).map(i => {
    if (i < exuParameters.JmpCnt) Seq((0, i), (1, i), (2, i))
195
    else if (i < 2 * exuParameters.MduCnt) Seq((0, i), (1, i))
196 197
    else Seq((0, i))
  })
198 199 200
  val lsDpPorts = (0 until exuParameters.LduCnt).map(i => Seq((3, i))) ++
                  (0 until exuParameters.StuCnt).map(i => Seq((4, i))) ++
                  (0 until exuParameters.StuCnt).map(i => Seq((5, i)))
201
  val fpDpPorts = (0 until exuParameters.FmacCnt).map(i => {
202
    if (i < 2 * exuParameters.FmiscCnt) Seq((0, i), (1, i))
203 204 205
    else Seq((0, i))
  })

206
  val dispatchPorts = Seq(intDpPorts ++ lsDpPorts, fpDpPorts)
207

208
  val outIntRfReadPorts = Seq(0, 0)
209
  val outFpRfReadPorts = Seq(0, StorePipelineWidth)
210 211 212
  val hasIntRf = Seq(true, false)
  val hasFpRf = Seq(false, true)
  val exuBlocks = schedulePorts.zip(dispatchPorts).zip(otherFastPorts).zipWithIndex.map {
213 214
    case (((sche, disp), other), i) =>
      LazyModule(new ExuBlock(sche, disp, intWbPorts, fpWbPorts, other, outIntRfReadPorts(i), outFpRfReadPorts(i), hasIntRf(i), hasFpRf(i)))
215
  }
216

217 218
  val memBlock = LazyModule(new MemBlock()(p.alter((site, here, up) => {
    case XSCoreParamsKey => up(XSCoreParamsKey).copy(
219
      IssQueSize = exuBlocks.head.scheduler.getMemRsEntries
220 221
    )
  })))
222 223 224

  val wb2Ctrl = LazyModule(new Wb2Ctrl(exuConfigs))
  wb2Ctrl.addWritebackSink(exuBlocks :+ memBlock)
225 226
  val dpExuConfigs = exuBlocks.flatMap(_.scheduler.dispatch2.map(_.configs))
  val ctrlBlock = LazyModule(new CtrlBlock(dpExuConfigs))
227 228
  val writebackSources = Seq(Seq(wb2Ctrl), Seq(wbArbiter))
  writebackSources.foreach(s => ctrlBlock.addWritebackSink(s))
229 230 231 232 233
}

class XSCore()(implicit p: config.Parameters) extends XSCoreBase
  with HasXSDts
{
L
linjiawei 已提交
234 235 236
  lazy val module = new XSCoreImp(this)
}

237
class XSCoreImp(outer: XSCoreBase) extends LazyModuleImp(outer)
238
  with HasXSParameter
239
  with HasSoCParameter {
Y
Yinan Xu 已提交
240
  val io = IO(new Bundle {
241
    val hartId = Input(UInt(64.W))
242
    val reset_vector = Input(UInt(PAddrBits.W))
Y
Yinan Xu 已提交
243
    val cpu_halt = Output(Bool())
244
    val l2_pf_enable = Output(Bool())
245
    val perfEvents = Input(Vec(numPCntHc * coreParams.L2NBanks, new PerfEvent))
J
Jiawei Lin 已提交
246
    val beu_errors = Output(new XSL1BusErrors())
Y
Yinan Xu 已提交
247
  })
248

Z
ZhangZifei 已提交
249 250
  println(s"FPGAPlatform:${env.FPGAPlatform} EnableDebug:${env.EnableDebug}")

J
jinyue110 已提交
251
  val frontend = outer.frontend.module
252 253
  val ctrlBlock = outer.ctrlBlock.module
  val wb2Ctrl = outer.wb2Ctrl.module
254
  val memBlock = outer.memBlock.module
L
linjiawei 已提交
255
  val ptw = outer.ptw.module
J
Jiawei Lin 已提交
256
  val ptw_to_l2_buffer = outer.ptw_to_l2_buffer.module
257 258
  val exuBlocks = outer.exuBlocks.map(_.module)

259
  frontend.io.hartId  := io.hartId
J
Jiawei Lin 已提交
260 261 262 263
  ctrlBlock.io.hartId := io.hartId
  exuBlocks.foreach(_.io.hartId := io.hartId)
  memBlock.io.hartId := io.hartId
  outer.wbArbiter.module.io.hartId := io.hartId
264
  frontend.io.reset_vector := io.reset_vector
J
Jiawei Lin 已提交
265

Y
Yinan Xu 已提交
266 267
  io.cpu_halt := ctrlBlock.io.cpu_halt

268
  outer.wbArbiter.module.io.redirect <> ctrlBlock.io.redirect
269
  val allWriteback = exuBlocks.flatMap(_.io.fuWriteback) ++ memBlock.io.writeback
270
  require(exuConfigs.length == allWriteback.length, s"${exuConfigs.length} != ${allWriteback.length}")
271 272
  outer.wbArbiter.module.io.in <> allWriteback
  val rfWriteback = outer.wbArbiter.module.io.out
273

274
  // memblock error exception writeback, 1 cycle after normal writeback
275
  wb2Ctrl.io.s3_delayed_load_error <> memBlock.io.s3_delayed_load_error
276

277 278 279
  wb2Ctrl.io.redirect <> ctrlBlock.io.redirect
  outer.wb2Ctrl.generateWritebackIO()

280 281
  io.beu_errors.icache <> frontend.io.error.toL1BusErrorUnitInfo()
  io.beu_errors.dcache <> memBlock.io.error.toL1BusErrorUnitInfo()
282

283 284 285 286 287
  require(exuBlocks.count(_.fuConfigs.map(_._1).contains(JumpCSRExeUnitCfg)) == 1)
  val csrFenceMod = exuBlocks.filter(_.fuConfigs.map(_._1).contains(JumpCSRExeUnitCfg)).head
  val csrioIn = csrFenceMod.io.fuExtra.csrio.get
  val fenceio = csrFenceMod.io.fuExtra.fenceio.get

288
  frontend.io.backend <> ctrlBlock.io.frontend
289 290 291 292
  frontend.io.sfence <> fenceio.sfence
  frontend.io.tlbCsr <> csrioIn.tlb
  frontend.io.csrCtrl <> csrioIn.customCtrl
  frontend.io.fencei := fenceio.fencei
293

294 295
  ctrlBlock.io.csrCtrl <> csrioIn.customCtrl
  val redirectBlocks = exuBlocks.reverse.filter(_.fuConfigs.map(_._1).map(_.hasRedirect).reduce(_ || _))
296
  ctrlBlock.io.exuRedirect <> redirectBlocks.flatMap(_.io.fuExtra.exuRedirect)
297 298
  ctrlBlock.io.stIn <> memBlock.io.stIn
  ctrlBlock.io.memoryViolation <> memBlock.io.memoryViolation
Y
Yinan Xu 已提交
299
  exuBlocks.head.io.scheExtra.enqLsq.get <> memBlock.io.enqLsq
300 301 302 303 304 305
  exuBlocks.foreach(b => {
    b.io.scheExtra.lcommit := ctrlBlock.io.robio.lsq.lcommit
    b.io.scheExtra.scommit := memBlock.io.sqDeq
    b.io.scheExtra.lqCancelCnt := memBlock.io.lqCancelCnt
    b.io.scheExtra.sqCancelCnt := memBlock.io.sqCancelCnt
  })
306 307
  val sourceModules = outer.writebackSources.map(_.map(_.module.asInstanceOf[HasWritebackSourceImp]))
  outer.ctrlBlock.generateWritebackIO()
308

Y
Yinan Xu 已提交
309 310
  val allFastUop = exuBlocks.flatMap(b => b.io.fastUopOut.dropRight(b.numOutFu)) ++ memBlock.io.otherFastWakeup
  require(allFastUop.length == exuConfigs.length, s"${allFastUop.length} != ${exuConfigs.length}")
311 312
  val intFastUop = allFastUop.zip(exuConfigs).filter(_._2.writeIntRf).map(_._1)
  val fpFastUop = allFastUop.zip(exuConfigs).filter(_._2.writeFpRf).map(_._1)
313 314
  val intFastUop1 = outer.wbArbiter.intConnections.map(c => intFastUop(c.head))
  val fpFastUop1 = outer.wbArbiter.fpConnections.map(c => fpFastUop(c.head))
315 316
  val allFastUop1 = intFastUop1 ++ fpFastUop1

317
  ctrlBlock.io.dispatch <> exuBlocks.flatMap(_.io.in)
318 319 320 321 322
  ctrlBlock.io.rsReady := exuBlocks.flatMap(_.io.scheExtra.rsReady)
  ctrlBlock.io.enqLsq <> memBlock.io.enqLsq
  ctrlBlock.io.sqDeq := memBlock.io.sqDeq
  ctrlBlock.io.lqCancelCnt := memBlock.io.lqCancelCnt
  ctrlBlock.io.sqCancelCnt := memBlock.io.sqCancelCnt
323 324

  exuBlocks(0).io.scheExtra.fpRfReadIn.get <> exuBlocks(1).io.scheExtra.fpRfReadOut.get
325
  exuBlocks(0).io.scheExtra.fpStateReadIn.get <> exuBlocks(1).io.scheExtra.fpStateReadOut.get
326

327
  memBlock.io.issue <> exuBlocks(0).io.issue.get
328 329
  // By default, instructions do not have exceptions when they enter the function units.
  memBlock.io.issue.map(_.bits.uop.clearExceptions())
330
  exuBlocks(0).io.scheExtra.loadFastMatch.get <> memBlock.io.loadFastMatch
331
  exuBlocks(0).io.scheExtra.loadFastImm.get <> memBlock.io.loadFastImm
332

333
  val stdIssue = exuBlocks(0).io.issue.get.takeRight(exuParameters.StuCnt)
334 335
  exuBlocks.map(_.io).foreach { exu =>
    exu.redirect <> ctrlBlock.io.redirect
336
    exu.allocPregs <> ctrlBlock.io.allocPregs
337 338 339 340 341 342 343
    exu.rfWriteback <> rfWriteback
    exu.fastUopIn <> allFastUop1
    exu.scheExtra.jumpPc <> ctrlBlock.io.jumpPc
    exu.scheExtra.jalr_target <> ctrlBlock.io.jalr_target
    exu.scheExtra.stIssuePtr <> memBlock.io.stIssuePtr
    exu.scheExtra.debug_fp_rat <> ctrlBlock.io.debug_fp_rat
    exu.scheExtra.debug_int_rat <> ctrlBlock.io.debug_int_rat
344 345
    exu.scheExtra.lqFull := memBlock.io.lqFull
    exu.scheExtra.sqFull := memBlock.io.sqFull
346 347
    exu.scheExtra.memWaitUpdateReq.staIssue.zip(memBlock.io.stIn).foreach{case (sink, src) => {
      sink.bits := src.bits
348
      sink.valid := src.valid
349 350 351 352 353
    }}
    exu.scheExtra.memWaitUpdateReq.stdIssue.zip(stdIssue).foreach{case (sink, src) => {
      sink.valid := src.valid
      sink.bits := src.bits
    }}
354
  }
355 356
  XSPerfHistogram("fastIn_count", PopCount(allFastUop1.map(_.valid)), true.B, 0, allFastUop1.length, 1)
  XSPerfHistogram("wakeup_count", PopCount(rfWriteback.map(_.valid)), true.B, 0, rfWriteback.length, 1)
357

358 359 360 361
  ctrlBlock.perfinfo.perfEventsEu0 := exuBlocks(0).getPerf.dropRight(outer.exuBlocks(0).scheduler.numRs)
  ctrlBlock.perfinfo.perfEventsEu1 := exuBlocks(1).getPerf.dropRight(outer.exuBlocks(1).scheduler.numRs)
  memBlock.io.perfEventsPTW  := ptw.getPerf
  ctrlBlock.perfinfo.perfEventsRs  := outer.exuBlocks.flatMap(b => b.module.getPerf.takeRight(b.scheduler.numRs))
362

363 364
  csrioIn.hartId <> io.hartId
  csrioIn.perf <> DontCare
Y
Yinan Xu 已提交
365
  csrioIn.perf.retiredInstr <> ctrlBlock.io.robio.toCSR.perfinfo.retiredInstr
366 367 368 369
  csrioIn.perf.ctrlInfo <> ctrlBlock.io.perfInfo.ctrlInfo
  csrioIn.perf.memInfo <> memBlock.io.memInfo
  csrioIn.perf.frontendInfo <> frontend.io.frontendInfo

370 371 372
  csrioIn.perf.perfEventsFrontend <> frontend.getPerf
  csrioIn.perf.perfEventsCtrl     <> ctrlBlock.getPerf
  csrioIn.perf.perfEventsLsu      <> memBlock.getPerf
373 374
  csrioIn.perf.perfEventsHc       <> io.perfEvents

Y
Yinan Xu 已提交
375
  csrioIn.fpu.fflags <> ctrlBlock.io.robio.toCSR.fflags
376
  csrioIn.fpu.isIllegal := false.B
Y
Yinan Xu 已提交
377
  csrioIn.fpu.dirty_fs <> ctrlBlock.io.robio.toCSR.dirty_fs
378
  csrioIn.fpu.frm <> exuBlocks(1).io.fuExtra.frm.get
Y
Yinan Xu 已提交
379 380 381 382
  csrioIn.exception <> ctrlBlock.io.robio.exception
  csrioIn.isXRet <> ctrlBlock.io.robio.toCSR.isXRet
  csrioIn.trapTarget <> ctrlBlock.io.robio.toCSR.trapTarget
  csrioIn.interrupt <> ctrlBlock.io.robio.toCSR.intrBitSet
Y
Yinan Xu 已提交
383
  csrioIn.wfi_event <> ctrlBlock.io.robio.toCSR.wfiEvent
384
  csrioIn.memExceptionVAddr <> memBlock.io.lsqio.exceptionAddr.vaddr
J
Jiawei Lin 已提交
385 386 387 388

  csrioIn.externalInterrupt.msip := outer.clint_int_sink.in.head._1(0)
  csrioIn.externalInterrupt.mtip := outer.clint_int_sink.in.head._1(1)
  csrioIn.externalInterrupt.meip := outer.plic_int_sink.in.head._1(0)
389
  csrioIn.externalInterrupt.seip := outer.plic_int_sink.in.last._1(0)
J
Jiawei Lin 已提交
390
  csrioIn.externalInterrupt.debug := outer.debug_int_sink.in.head._1(0)
391

392 393 394 395
  csrioIn.distributedUpdate(0).w.valid := memBlock.io.csrUpdate.w.valid
  csrioIn.distributedUpdate(0).w.bits := memBlock.io.csrUpdate.w.bits
  csrioIn.distributedUpdate(1).w.valid := frontend.io.csrUpdate.w.valid
  csrioIn.distributedUpdate(1).w.bits := frontend.io.csrUpdate.w.bits
396

397 398
  fenceio.sfence <> memBlock.io.sfence
  fenceio.sbuffer <> memBlock.io.fenceToSbuffer
Y
Yinan Xu 已提交
399

400
  memBlock.io.redirect <> ctrlBlock.io.redirect
401
  memBlock.io.rsfeedback <> exuBlocks(0).io.scheExtra.feedback.get
402 403
  memBlock.io.csrCtrl <> csrioIn.customCtrl
  memBlock.io.tlbCsr <> csrioIn.tlb
Y
Yinan Xu 已提交
404 405
  memBlock.io.lsqio.rob <> ctrlBlock.io.robio.lsq
  memBlock.io.lsqio.exceptionAddr.isStore := CommitType.lsInstIsStore(ctrlBlock.io.robio.exception.bits.uop.ctrl.commitType)
406

407 408 409 410
  val itlbRepeater1 = PTWFilter(itlbParams.fenceDelay,frontend.io.ptw, fenceio.sfence, csrioIn.tlb, l2tlbParams.ifilterSize)
  val itlbRepeater2 = PTWRepeaterNB(passReady = false, itlbParams.fenceDelay, itlbRepeater1.io.ptw, ptw.io.tlb(0), fenceio.sfence, csrioIn.tlb)
  val dtlbRepeater1  = PTWFilter(ldtlbParams.fenceDelay, memBlock.io.ptw, fenceio.sfence, csrioIn.tlb, l2tlbParams.dfilterSize)
  val dtlbRepeater2  = PTWRepeaterNB(passReady = false, ldtlbParams.fenceDelay, dtlbRepeater1.io.ptw, ptw.io.tlb(1), fenceio.sfence, csrioIn.tlb)
411
  ptw.io.sfence <> fenceio.sfence
L
Lemover 已提交
412 413
  ptw.io.csr.tlb <> csrioIn.tlb
  ptw.io.csr.distribute_csr <> csrioIn.customCtrl.distribute_csr
414

415
  // if l2 prefetcher use stream prefetch, it should be placed in XSCore
416
  io.l2_pf_enable := csrioIn.customCtrl.l2_pf_enable
417

418
  // Modules are reset one by one
J
Jiawei Lin 已提交
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440
  val resetTree = ResetGenNode(
    Seq(
      ModuleNode(memBlock), ModuleNode(dtlbRepeater1),
      ResetGenNode(Seq(
        ModuleNode(itlbRepeater2),
        ModuleNode(ptw),
        ModuleNode(dtlbRepeater2),
        ModuleNode(ptw_to_l2_buffer),
      )),
      ResetGenNode(Seq(
        ModuleNode(exuBlocks.head),
        ResetGenNode(
          exuBlocks.tail.map(m => ModuleNode(m)) :+ ModuleNode(outer.wbArbiter.module)
        ),
        ResetGenNode(Seq(
          ModuleNode(ctrlBlock),
          ResetGenNode(Seq(
            ModuleNode(frontend), ModuleNode(itlbRepeater1)
          ))
        ))
      ))
    )
441
  )
J
Jiawei Lin 已提交
442 443 444

  ResetGen(resetTree, reset.asBool, !debugOpts.FPGAPlatform)

L
LinJiawei 已提交
445
}