SoC.scala 1.5 KB
Newer Older
Z
Zihao Yu 已提交
1 2
package system

3
import noop.{NOOP, NOOPConfig, Cache, L2Cache, CacheConfig}
Z
Zihao Yu 已提交
4
import bus.axi4.{AXI4, AXI4Lite}
5
import bus.simplebus._
Z
Zihao Yu 已提交
6 7

import chisel3._
8
import chisel3.util.experimental.BoringUtils
Z
Zihao Yu 已提交
9 10 11

class NOOPSoC(implicit val p: NOOPConfig) extends Module {
  val io = IO(new Bundle{
12
    val mem = new AXI4
13
    val mmio = (if (p.FPGAPlatform) { new AXI4Lite } else { new SimpleBusUC })
14
    val mtip = Input(Bool())
Z
Zihao Yu 已提交
15
    val meip = Input(Bool())
Z
Zihao Yu 已提交
16 17 18
  })

  val noop = Module(new NOOP)
19 20 21
  val cohMg = Module(new CoherenceInterconnect)
  cohMg.io.in(0) <> noop.io.imem
  cohMg.io.in(1) <> noop.io.dmem
22 23 24 25 26 27 28 29 30 31 32 33 34
  // io.mem <> cohMg.io.out.toAXI4()
	val mmioXbar = Module(new SimpleBusCrossbarNto1(2))
	
	val l2cacheOut = Wire(new SimpleBusUC)
	l2cacheOut <> Cache(in = cohMg.io.out, mmio = mmioXbar.io.in(0), flush = "b00".U, enable = true)(CacheConfig(ro = false, name = "l2cache", cacheLevel = 2))
	io.mem <> l2cacheOut.toAXI4()
	/*
	val l2cache = Module(new L2Cache)
	l2cache.io.in <> cohMg.io.out
	mmioXbar.io.in(0) <> l2cache.io.mmio
	l2cache.io.flush := "b00".U
	io.mem <> l2cache.io.out.toAXI4()
	*/
Z
Zihao Yu 已提交
35

36 37 38 39
	mmioXbar.io.in(1) <> noop.io.mmio
	if (p.FPGAPlatform) io.mmio <> mmioXbar.io.out.toAXI4Lite()
  else io.mmio <> mmioXbar.io.out
	/*
40
  if (p.FPGAPlatform) io.mmio <> noop.io.mmio.toAXI4Lite()
Z
Zihao Yu 已提交
41
  else io.mmio <> noop.io.mmio
42
	*/
Z
Zihao Yu 已提交
43
  val mtipSync = RegNext(RegNext(io.mtip))
Z
Zihao Yu 已提交
44
  val meipSync = RegNext(RegNext(io.meip))
Z
Zihao Yu 已提交
45
  BoringUtils.addSource(mtipSync, "mtip")
Z
Zihao Yu 已提交
46
  BoringUtils.addSource(meipSync, "meip")
Z
Zihao Yu 已提交
47
}