SoC.scala 2.1 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._
Z
zhanglinjuan 已提交
8
import chisel3.util._
9
import chisel3.util.experimental.BoringUtils
Z
Zihao Yu 已提交
10 11 12

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

  val noop = Module(new NOOP)
20 21 22
  val cohMg = Module(new CoherenceInterconnect)
  cohMg.io.in(0) <> noop.io.imem
  cohMg.io.in(1) <> noop.io.dmem
Z
zhanglinjuan 已提交
23 24 25 26 27 28 29 30 31 32 33 34 35
	
	/*
	// add L2 Cache and Dcache Prefetcher
	val prefetcher = Module(new Prefetcher)
	prefetcher.io.in <> noop.io.prefetchReq

	val l2cacheIn = Wire(new SimpleBusUC)
	val l2cacheInReqArb = Module(new Arbiter(noop.io.prefetchReq, 2))
	l2cacheInReqArb.io.in(0) <> cohMg.io.out.req
	l2cacheInReqArb.io.in(1) <> prefetcher.io.out
	l2cacheIn.req <> l2cacheInReqArb.io.out
	cohMg.io.out.resp <> l2cacheIn.resp

36 37 38
	val mmioXbar = Module(new SimpleBusCrossbarNto1(2))
	
	val l2cacheOut = Wire(new SimpleBusUC)
Z
zhanglinjuan 已提交
39
	l2cacheOut <> Cache(in = l2cacheIn, mmio = mmioXbar.io.in(0), flush = "b00".U, enable = true)(CacheConfig(ro = false, name = "l2cache", cacheLevel = 2))
40
	io.mem <> l2cacheOut.toAXI4()
Z
zhanglinjuan 已提交
41 42 43 44

	mmioXbar.io.in(1) <> noop.io.mmio
	if (p.FPGAPlatform) io.mmio <> mmioXbar.io.out.toAXI4Lite()
  else io.mmio <> mmioXbar.io.out
45
	*/
Z
zhanglinjuan 已提交
46 47 48 49 50 51 52
	
	// add L2 Cache
	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()
Z
Zihao Yu 已提交
53

54 55 56
	mmioXbar.io.in(1) <> noop.io.mmio
	if (p.FPGAPlatform) io.mmio <> mmioXbar.io.out.toAXI4Lite()
  else io.mmio <> mmioXbar.io.out
Z
zhanglinjuan 已提交
57
	
58
	/*
Z
zhanglinjuan 已提交
59 60 61
	// no L2 Cache
	io.mem <> cohMg.io.out.toAXI4()

62
  if (p.FPGAPlatform) io.mmio <> noop.io.mmio.toAXI4Lite()
Z
Zihao Yu 已提交
63
  else io.mmio <> noop.io.mmio
64
	*/
Z
Zihao Yu 已提交
65
  val mtipSync = RegNext(RegNext(io.mtip))
Z
Zihao Yu 已提交
66
  val meipSync = RegNext(RegNext(io.meip))
Z
Zihao Yu 已提交
67
  BoringUtils.addSource(mtipSync, "mtip")
Z
Zihao Yu 已提交
68
  BoringUtils.addSource(meipSync, "meip")
Z
Zihao Yu 已提交
69
}