xref: /XiangShan/src/main/scala/system/SoC.scala (revision eb8bdfa799772363d7ec3353db0f1f5a2730aa8f)
1006e1884SZihao Yupackage system
2006e1884SZihao Yu
3*eb8bdfa7SZihao Yuimport noop._
4006e1884SZihao Yuimport bus.axi4.{AXI4, AXI4Lite}
58f36f779SZihao Yuimport bus.simplebus._
6006e1884SZihao Yu
7006e1884SZihao Yuimport chisel3._
8096ea47eSzhanglinjuanimport chisel3.util._
9fe820c3dSZihao Yuimport chisel3.util.experimental.BoringUtils
10006e1884SZihao Yu
11*eb8bdfa7SZihao Yuclass NOOPSoC(implicit val p: NOOPConfig) extends NOOPModule {
12006e1884SZihao Yu  val io = IO(new Bundle{
13cdd59e9fSZihao Yu    val mem = new AXI4
14ad255e6cSZihao Yu    val mmio = (if (p.FPGAPlatform) { new AXI4Lite } else { new SimpleBusUC })
15fe820c3dSZihao Yu    val mtip = Input(Bool())
16466eb0a8SZihao Yu    val meip = Input(Bool())
17006e1884SZihao Yu  })
18006e1884SZihao Yu
19006e1884SZihao Yu  val noop = Module(new NOOP)
20096ea47eSzhanglinjuan
21635253aaSZihao Yu  val cohMg = Module(new CoherenceManager)
22635253aaSZihao Yu  val xbar = Module(new SimpleBusCrossbarNto1(2))
23635253aaSZihao Yu  cohMg.io.in <> noop.io.imem.mem
24635253aaSZihao Yu  noop.io.dmem.coh <> cohMg.io.out.coh
25635253aaSZihao Yu  xbar.io.in(0) <> cohMg.io.out.mem
26635253aaSZihao Yu  xbar.io.in(1) <> noop.io.dmem.mem
27096ea47eSzhanglinjuan
28*eb8bdfa7SZihao Yu  if (HasL2cache) {
29096ea47eSzhanglinjuan    val l2cacheOut = Wire(new SimpleBusUC)
30*eb8bdfa7SZihao Yu    l2cacheOut <> Cache(in = xbar.io.out, mmio = 0.U.asTypeOf(new SimpleBusUC), flush = "b00".U, enable = true)(CacheConfig(ro = false, name = "l2cache", cacheLevel = 2))
31096ea47eSzhanglinjuan    io.mem <> l2cacheOut.toAXI4()
32*eb8bdfa7SZihao Yu  } else {
33635253aaSZihao Yu    io.mem <> xbar.io.out.toAXI4()
34*eb8bdfa7SZihao Yu  }
35096ea47eSzhanglinjuan
36635253aaSZihao Yu  noop.io.imem.coh.resp.ready := true.B
37635253aaSZihao Yu  noop.io.imem.coh.req.valid := false.B
38635253aaSZihao Yu  noop.io.imem.coh.req.bits := DontCare
39096ea47eSzhanglinjuan
40ad255e6cSZihao Yu  if (p.FPGAPlatform) io.mmio <> noop.io.mmio.toAXI4Lite()
41006e1884SZihao Yu  else io.mmio <> noop.io.mmio
42fe820c3dSZihao Yu
435d41d760SZihao Yu  val mtipSync = RegNext(RegNext(io.mtip))
44466eb0a8SZihao Yu  val meipSync = RegNext(RegNext(io.meip))
455d41d760SZihao Yu  BoringUtils.addSource(mtipSync, "mtip")
46466eb0a8SZihao Yu  BoringUtils.addSource(meipSync, "meip")
47006e1884SZihao Yu}
48