xref: /XiangShan/src/main/scala/device/AXI4Flash.scala (revision bfa9f4f22671af26138b635eae78350b4a9db25c)
1b4cc98d2SZihao Yupackage device
2b4cc98d2SZihao Yu
3b4cc98d2SZihao Yuimport chisel3._
4b4cc98d2SZihao Yuimport chisel3.util._
5b4cc98d2SZihao Yu
6b4cc98d2SZihao Yuimport bus.axi4._
7b4cc98d2SZihao Yuimport utils._
8b4cc98d2SZihao Yu
9b4cc98d2SZihao Yuclass AXI4Flash extends AXI4SlaveModule(new AXI4Lite) {
10b4cc98d2SZihao Yu  val jmpToDramInstr1 = "h0010029b".U  // addiw t0,zero,1
11b4cc98d2SZihao Yu  val jmpToDramInstr2 = "h01f29293".U  // slli  t0,t0,0x1f
12b4cc98d2SZihao Yu  val jmpToDramInstr3 = "h00028067".U  // jr t0
13b4cc98d2SZihao Yu
14b4cc98d2SZihao Yu  val mapping = Map(
15b4cc98d2SZihao Yu    RegMap(0x0, jmpToDramInstr1, RegMap.Unwritable),
16b4cc98d2SZihao Yu    RegMap(0x4, jmpToDramInstr2, RegMap.Unwritable),
17b4cc98d2SZihao Yu    RegMap(0x8, jmpToDramInstr3, RegMap.Unwritable)
18b4cc98d2SZihao Yu  )
19b4cc98d2SZihao Yu  def getOffset(addr: UInt) = addr(12,0)
20b4cc98d2SZihao Yu
21*bfa9f4f2SZihao Yu  val rdata = Wire(UInt(64.W))
22b4cc98d2SZihao Yu  RegMap.generate(mapping, getOffset(raddr), rdata,
23b4cc98d2SZihao Yu    getOffset(waddr), in.w.fire(), in.w.bits.data, MaskExpand(in.w.bits.strb))
24b4cc98d2SZihao Yu
25*bfa9f4f2SZihao Yu  in.r.bits.data := RegEnable(RegNext(Fill(2, rdata(31,0))), ren)
26b4cc98d2SZihao Yu}
27