xref: /XiangShan/src/main/scala/system/SoC.scala (revision 35377176d38e904fb7b49a97fa51538affd67e09)
1006e1884SZihao Yupackage system
2006e1884SZihao Yu
3eb8bdfa7SZihao 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
11eb8bdfa7SZihao 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
27d2d827d9Szhanglinjuan
28eb8bdfa7SZihao Yu	if (HasL2cache) {
29*35377176Szhanglinjuan    val l2cacheOut = Wire(new SimpleBusC)
30*35377176Szhanglinjuan    if (HasPrefetch) {
31096ea47eSzhanglinjuan			val prefetcher = Module(new Prefetcher)
32096ea47eSzhanglinjuan			prefetcher.io.in <> noop.io.prefetchReq
33096ea47eSzhanglinjuan			val l2cacheIn = Wire(new SimpleBusUC)
34d2d827d9Szhanglinjuan			val l2cacheInReqArb = Module(new Arbiter(chiselTypeOf(noop.io.prefetchReq.bits), 2))
35*35377176Szhanglinjuan			l2cacheInReqArb.io.in(0) <> xbar.io.out.req
36096ea47eSzhanglinjuan			l2cacheInReqArb.io.in(1) <> prefetcher.io.out
37096ea47eSzhanglinjuan			l2cacheIn.req <> l2cacheInReqArb.io.out
38*35377176Szhanglinjuan			xbar.io.out.resp <> l2cacheIn.resp
39*35377176Szhanglinjuan			l2cacheOut <> Cache(in = l2cacheIn, mmio = 0.U.asTypeOf(new SimpleBusUC), flush = "b00".U, enable = true)(CacheConfig(ro = false, name = "l2cache", cacheLevel = 2))
40*35377176Szhanglinjuan		} else {
41eb8bdfa7SZihao 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))
42*35377176Szhanglinjuan		}
43*35377176Szhanglinjuan    io.mem <> l2cacheOut.mem.toAXI4()
44*35377176Szhanglinjuan		l2cacheOut.coh.resp.ready := true.B
45*35377176Szhanglinjuan		l2cacheOut.coh.req.valid := false.B
46*35377176Szhanglinjuan		l2cacheOut.coh.req.bits := DontCare
47eb8bdfa7SZihao Yu  } else {
48635253aaSZihao Yu    io.mem <> xbar.io.out.toAXI4()
49eb8bdfa7SZihao Yu  }
50096ea47eSzhanglinjuan
51*35377176Szhanglinjuan	if (!HasPrefetch) {
52*35377176Szhanglinjuan		noop.io.prefetchReq.ready := true.B
53*35377176Szhanglinjuan	}
54096ea47eSzhanglinjuan
55635253aaSZihao Yu  noop.io.imem.coh.resp.ready := true.B
56635253aaSZihao Yu  noop.io.imem.coh.req.valid := false.B
57635253aaSZihao Yu  noop.io.imem.coh.req.bits := DontCare
58096ea47eSzhanglinjuan
59ad255e6cSZihao Yu  if (p.FPGAPlatform) io.mmio <> noop.io.mmio.toAXI4Lite()
60006e1884SZihao Yu  else io.mmio <> noop.io.mmio
61d2d827d9Szhanglinjuan
625d41d760SZihao Yu  val mtipSync = RegNext(RegNext(io.mtip))
63466eb0a8SZihao Yu  val meipSync = RegNext(RegNext(io.meip))
645d41d760SZihao Yu  BoringUtils.addSource(mtipSync, "mtip")
65466eb0a8SZihao Yu  BoringUtils.addSource(meipSync, "meip")
66006e1884SZihao Yu}
67