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