1package top 2 3import chisel3._ 4import chisel3.util._ 5 6import bus.simplebus.SimpleBus 7 8class DeviceHelper extends BlackBox { 9 val io = IO(new Bundle { 10 val clk = Input(Clock()) 11 val reset = Input(Bool()) 12 val reqValid = Input(Bool()) 13 val reqWen = Input(Bool()) 14 val reqAddr = Input(UInt(32.W)) 15 val reqWdata = Input(UInt(32.W)) 16 val reqWmask = Input(UInt(4.W)) 17 val respRdata = Output(UInt(32.W)) 18 }) 19} 20 21class SimMMIO extends Module { 22 val io = IO(new Bundle { 23 val rw = Flipped(new SimpleBus) 24 }) 25 26 val helper = Module(new DeviceHelper) 27 helper.io.clk := clock 28 helper.io.reset := reset.asBool 29 helper.io.reqValid := io.rw.req.valid 30 helper.io.reqWen := io.rw.isWrite() 31 helper.io.reqAddr := io.rw.req.bits.addr 32 helper.io.reqWdata := io.rw.req.bits.wdata 33 helper.io.reqWmask := io.rw.req.bits.wmask 34 io.rw.resp.bits.rdata := helper.io.respRdata 35 36 io.rw.req.ready := true.B 37 io.rw.resp.valid := RegNext(io.rw.req.valid) 38} 39