xref: /XiangShan/src/test/scala/top/SimMMIO.scala (revision fe820c3d12c0fbbef7df33d7e38a5544e32d418a)
1package top
2
3import chisel3._
4import chisel3.util._
5
6import bus.simplebus._
7import device._
8
9class DeviceHelper extends BlackBox {
10  val io = IO(new Bundle {
11    val clk = Input(Clock())
12    val reset = Input(Bool())
13    val reqValid = Input(Bool())
14    val reqWen = Input(Bool())
15    val reqAddr = Input(UInt(64.W))
16    val reqWdata = Input(UInt(64.W))
17    val reqWmask = Input(UInt(8.W))
18    val respRdata = Output(UInt(64.W))
19  })
20}
21
22class SimMMIO extends Module {
23  val io = IO(new Bundle {
24    val rw = Flipped(new SimpleBusUC)
25    val mtip = Output(Bool())
26  })
27
28  val devAddrSpace = List(
29    (0x40600000L, 0x10L), // uart
30    (0x40700000L, 0x10L), // timer
31    (0x40000000L, 0x400000L), // vmem
32    (0x40800000L, 0x8L)  // vga ctrl
33  )
34
35  val xbar = Module(new SimpleBusCrossbar(1, devAddrSpace))
36  xbar.io.in(0) <> io.rw
37
38  val uart = Module(new AXI4UART)
39  val timer = Module(new AXI4Timer(sim = true))
40  val vga = Module(new AXI4VGA(sim = true))
41  uart.io.in <> xbar.io.out(0).toAXI4Lite()
42  timer.io.in <> xbar.io.out(1).toAXI4Lite()
43  vga.io.in.fb <> xbar.io.out(2).toAXI4Lite()
44  vga.io.in.ctrl <> xbar.io.out(3).toAXI4Lite()
45  vga.io.vga := DontCare
46
47  io.mtip := timer.io.extra.get.mtip
48
49  //val helper = Module(new DeviceHelper)
50  //val helperIO = xbar.io.out(0)
51  //helper.io.clk := clock
52  //helper.io.reset := reset.asBool
53  //helper.io.reqValid := helperIO.req.valid
54  //helper.io.reqWen := helperIO.isWrite()
55  //helper.io.reqAddr := helperIO.req.bits.addr
56  //helper.io.reqWdata := helperIO.req.bits.wdata
57  //helper.io.reqWmask := helperIO.req.bits.wmask
58  //helperIO.resp.bits.rdata := helper.io.respRdata
59  //helperIO.resp.bits.cmd := 0.U
60  //helperIO.resp.bits.user := 0.U
61
62  //helperIO.req.ready := true.B
63  //helperIO.resp.valid := RegNext(helperIO.req.valid)
64}
65