frontend/wishbone: add base_address param. to LiteDRAMWishbone2Native

This commit is contained in:
Gabriel Somlo 2019-10-24 11:31:56 -04:00
parent 24203cfc7b
commit 7356d3b15d
1 changed files with 4 additions and 2 deletions

View File

@ -7,11 +7,13 @@ from migen import *
class LiteDRAMWishbone2Native(Module): class LiteDRAMWishbone2Native(Module):
def __init__(self, wishbone, port): def __init__(self, wishbone, port, base_address=0x00000000):
assert len(wishbone.dat_w) == len(port.wdata.data) assert len(wishbone.dat_w) == len(port.wdata.data)
# # # # # #
adr_offset = base_address >> log2_int(port.data_width//8)
# Control # Control
self.submodules.fsm = fsm = FSM(reset_state="CMD") self.submodules.fsm = fsm = FSM(reset_state="CMD")
fsm.act("CMD", fsm.act("CMD",
@ -43,7 +45,7 @@ class LiteDRAMWishbone2Native(Module):
# Datapath # Datapath
self.comb += [ self.comb += [
# cmd # cmd
port.cmd.addr.eq(wishbone.adr), port.cmd.addr.eq(wishbone.adr - adr_offset),
# write # write
port.wdata.we.eq(wishbone.sel), port.wdata.we.eq(wishbone.sel),
port.wdata.data.eq(wishbone.dat_w), port.wdata.data.eq(wishbone.dat_w),