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

import noop.{NOOP, NOOPConfig}
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 12 13 14 15 16 17 18 19 20 21 22 23
trait HasILAParameter {
  val enableILA = false
}

class ILABundle extends Bundle {
  val WBUpc = UInt(32.W)
  val WBUvalid = UInt(1.W)
  val WBUrfWen = UInt(1.W)
  val WBUrfDest = UInt(5.W)
  val WBUrfData = UInt(64.W)
  val InstrCnt = UInt(64.W)
}

class NOOPSoC(implicit val p: NOOPConfig) extends Module with HasILAParameter {
Z
Zihao Yu 已提交
24
  val io = IO(new Bundle{
25
    val mem = new AXI4
26
    val mmio = (if (p.FPGAPlatform) { new AXI4Lite } else { new SimpleBusUC })
27
    val mtip = Input(Bool())
Z
Zihao Yu 已提交
28
    val meip = Input(Bool())
29
    val ila = if (p.FPGAPlatform && enableILA) Some(Output(new ILABundle)) else None
Z
Zihao Yu 已提交
30 31 32
  })

  val noop = Module(new NOOP)
33 34 35 36 37 38 39 40 41 42 43
  val cohMg = Module(new CoherenceManager)
  val xbar = Module(new SimpleBusCrossbarNto1(2))
  cohMg.io.in <> noop.io.imem.mem
  noop.io.dmem.coh <> cohMg.io.out.coh
  xbar.io.in(0) <> cohMg.io.out.mem
  xbar.io.in(1) <> noop.io.dmem.mem
  io.mem <> xbar.io.out.toAXI4()

  noop.io.imem.coh.resp.ready := true.B
  noop.io.imem.coh.req.valid := false.B
  noop.io.imem.coh.req.bits := DontCare
Z
Zihao Yu 已提交
44

45
  if (p.FPGAPlatform) io.mmio <> noop.io.mmio.toAXI4Lite()
Z
Zihao Yu 已提交
46
  else io.mmio <> noop.io.mmio
47

Z
Zihao Yu 已提交
48
  val mtipSync = RegNext(RegNext(io.mtip))
Z
Zihao Yu 已提交
49
  val meipSync = RegNext(RegNext(io.meip))
Z
Zihao Yu 已提交
50
  BoringUtils.addSource(mtipSync, "mtip")
Z
Zihao Yu 已提交
51
  BoringUtils.addSource(meipSync, "meip")
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69

  // ILA
  if (p.FPGAPlatform) {
    def BoringUtilsConnect(sink: UInt, id: String) {
      val temp = WireInit(0.U(64.W))
      BoringUtils.addSink(temp, id)
      sink := temp
    }

    val dummy = WireInit(0.U.asTypeOf(new ILABundle))
    val ila = io.ila.getOrElse(dummy)
    BoringUtilsConnect(ila.WBUpc      ,"ilaWBUpc")
    BoringUtilsConnect(ila.WBUvalid   ,"ilaWBUvalid")
    BoringUtilsConnect(ila.WBUrfWen   ,"ilaWBUrfWen")
    BoringUtilsConnect(ila.WBUrfDest  ,"ilaWBUrfDest")
    BoringUtilsConnect(ila.WBUrfData  ,"ilaWBUrfData")
    BoringUtilsConnect(ila.InstrCnt   ,"ilaInstrCnt")
  }
Z
Zihao Yu 已提交
70
}