forked from M-Labs/artiq-zynq
replaced increment logic with ready Incr module
This commit is contained in:
parent
67ed7fae78
commit
3e1d14ff38
@ -36,10 +36,6 @@ class SRAM(Module):
|
|||||||
|
|
||||||
# Dout : Data received from CPU, output by SRAM <- port.dat_r
|
# Dout : Data received from CPU, output by SRAM <- port.dat_r
|
||||||
# Din : Data driven into SRAM, written into CPU <- port.dat_w
|
# Din : Data driven into SRAM, written into CPU <- port.dat_w
|
||||||
#
|
|
||||||
# Cycle:
|
|
||||||
# Then out_burst_len words are strobed out of dout
|
|
||||||
# Then, when din_ready is high, in_burst_len words are strobed in to din
|
|
||||||
self.dout_index = Signal(bus_addr_width) # is this legal?
|
self.dout_index = Signal(bus_addr_width) # is this legal?
|
||||||
self.din_index = Signal(bus_addr_width)
|
self.din_index = Signal(bus_addr_width)
|
||||||
self.din_ready = Signal()
|
self.din_ready = Signal()
|
||||||
@ -48,21 +44,17 @@ class SRAM(Module):
|
|||||||
|
|
||||||
ar, aw, w, r, b = attrgetter("ar", "aw", "w", "r", "b")(bus)
|
ar, aw, w, r, b = attrgetter("ar", "aw", "w", "r", "b")(bus)
|
||||||
|
|
||||||
|
self.r_addr_incr = axi.Incr(ar)
|
||||||
|
|
||||||
### Read
|
### Read
|
||||||
self.comb += [
|
|
||||||
port.adr.eq(ar.addr), # still not sure if legal hm
|
self.comb += r.data.eq(port.dat_r)
|
||||||
r.data.eq(port.dat_r),
|
|
||||||
# r.ready.eq(1),
|
|
||||||
# ar.burst.eq(axi.Burst.incr.value),
|
|
||||||
# ar.len.eq(OUT_BURST_LEN-1), # Number of transfers in burst (0->1 transfer, 1->2 transfers...)
|
|
||||||
# ar.size.eq(3), # Width of burst: 3 = 8 bytes = 64 bits
|
|
||||||
# ar.cache.eq(0xf),
|
|
||||||
]
|
|
||||||
|
|
||||||
# read control
|
# read control
|
||||||
self.submodules.read_fsm = read_fsm = FSM(reset_state="IDLE")
|
self.submodules.read_fsm = read_fsm = FSM(reset_state="IDLE")
|
||||||
read_fsm.act("IDLE",
|
read_fsm.act("IDLE",
|
||||||
If(ar.valid,
|
If(ar.valid,
|
||||||
|
port.adr.eq(self.r_addr_incr.addr),
|
||||||
ar.ready.eq(1),
|
ar.ready.eq(1),
|
||||||
NextState("READ_START"),
|
NextState("READ_START"),
|
||||||
)
|
)
|
||||||
@ -85,16 +77,11 @@ class SRAM(Module):
|
|||||||
self.sync += [
|
self.sync += [
|
||||||
If(read_fsm.ongoing("IDLE"),
|
If(read_fsm.ongoing("IDLE"),
|
||||||
self.dout_index.eq(0),
|
self.dout_index.eq(0),
|
||||||
r.ready.eq(0), # shall it be reset too on IDLE?
|
r.valid.eq(0), # shall it be reset too on IDLE?
|
||||||
ar.ready.eq(0)
|
ar.ready.eq(0),
|
||||||
).Else(If(r.ready & read_fsm.ongoing("READ"),
|
).Else(If(r.ready & read_fsm.ongoing("READ"),
|
||||||
self.dout_index.eq(self.dout_index+1),
|
self.dout_index.eq(self.dout_index+1),
|
||||||
If(ar.burst==axi.Burst.incr.value,
|
port.adr.eq(self.r_addr_incr.addr),
|
||||||
port.adr.eq(port.adr + self.dout_index)
|
|
||||||
).Else(If(ar.burst==axi.Burst.wrap.value,
|
|
||||||
port.adr.eq(port.adr + (self.dout_index | ar.len))
|
|
||||||
)), # update address in the port if it's incr or wrapped burst value
|
|
||||||
# no port.adr update for fixed burst type
|
|
||||||
If(self.dout_index==ar.len, r.last.eq(1)) # and update last
|
If(self.dout_index==ar.len, r.last.eq(1)) # and update last
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -104,12 +91,12 @@ class SRAM(Module):
|
|||||||
self.comb += [
|
self.comb += [
|
||||||
port.dat_w.eq(w.data),
|
port.dat_w.eq(w.data),
|
||||||
port.addr.eq(aw.addr),
|
port.addr.eq(aw.addr),
|
||||||
w.strb.eq(0xff),
|
# w.strb.eq(0xff),
|
||||||
aw.burst.eq(axi.Burst.incr.value),
|
# aw.burst.eq(axi.Burst.incr.value),
|
||||||
aw.len.eq(IN_BURST_LEN-1), # Number of transfers in burst minus 1
|
# aw.len.eq(IN_BURST_LEN-1), # Number of transfers in burst minus 1
|
||||||
aw.size.eq(3), # Width of burst: 3 = 8 bytes = 64 bits
|
# aw.size.eq(3), # Width of burst: 3 = 8 bytes = 64 bits
|
||||||
aw.cache.eq(0xf),
|
# aw.cache.eq(0xf),
|
||||||
b.ready.eq(1),
|
# b.ready.eq(1),
|
||||||
]
|
]
|
||||||
|
|
||||||
self.submodules.write_fsm = write_fsm = FSM(reset_state="IDLE")
|
self.submodules.write_fsm = write_fsm = FSM(reset_state="IDLE")
|
||||||
@ -150,7 +137,7 @@ class SRAM(Module):
|
|||||||
|
|
||||||
self.sync += [
|
self.sync += [
|
||||||
If(write_fsm.ongoing("IDLE"),
|
If(write_fsm.ongoing("IDLE"),
|
||||||
self.din_index.eq(0) # replace with address?
|
self.din_index.eq(0)
|
||||||
), # but need to synchronise the address too
|
), # but need to synchronise the address too
|
||||||
If(w.ready & w.valid, self.din_index.eq(self.din_index+1), port.adr.eq(port.addr+self.din_index))
|
If(w.ready & w.valid, self.din_index.eq(self.din_index+1), port.adr.eq(port.addr+self.din_index))
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user