Skip to content

Commit

Permalink
soc/cores/hyperbus: Add automatic write burst detection.
Browse files Browse the repository at this point in the history
  • Loading branch information
enjoy-digital committed Aug 29, 2024
1 parent fac80c3 commit f283f7a
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions litex/soc/cores/hyperbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
Supports variable latency, configurable clocking (4:1, 2:1), and burst operations.
Features:
- 8-bit or 16-bit Data-Width
- Variable latency: "fixed" or "variable".
- Configurable clock ratios: 4:1 or 2:1.
- Burst read/write support.
Expand Down Expand Up @@ -311,6 +312,12 @@ def __init__(self, phy, latency=7, latency_mode="fixed", clk_ratio="4:1", with_b
self.cycles = cycles = Signal(8)
self.latency_x2 = latency_x2 = Signal()
self.bus_latch = bus_latch = Signal()
self.bus_we = bus_we = Signal()
self.bus_sel = bus_sel = Signal(4)
self.bus_adr = bus_adr = Signal(32)
self.bus_dat_w = bus_dat_w = Signal(32)
self.burst_w = burst_w = Signal()
self.burst_r = burst_r = Signal()

# PHY.
# ----
Expand Down Expand Up @@ -455,20 +462,30 @@ def __init__(self, phy, latency=7, latency_mode="fixed", clk_ratio="4:1", with_b
# Data Write State.
self.sync += [
If(bus_latch,
dat_tx_conv.sink.dq.eq(bus.dat_w),
dat_tx_conv.sink.rwds.eq(~bus.sel),
bus_we.eq(bus.we),
bus_sel.eq(bus.sel),
bus_adr.eq(bus.adr),
bus_dat_w.eq(bus.dat_w),
)
]
self.comb += If(bus_latch, bus.ack.eq(1))
self.comb += burst_w.eq(
# Notified Incrementing Burst.
(bus.cti == 0b10) | (bus.cti == 0b11) |
# Detected Incrementing Burst.
((bus.we == bus_we) & (bus.adr == (bus_adr + 1))),
)
fsm.act("DAT-WRITE",
dat_tx_conv.sink.valid.eq(1),
dat_tx_conv.sink.dq.eq(bus_dat_w),
dat_tx_conv.sink.rwds.eq(~bus_sel),
dat_tx_conv.source.connect(source),
source.dq_oe.eq(1),
source.rwds_oe.eq(1),
source.dat_w.eq(1),
If(dat_tx_conv.sink.ready,
# Stay in DAT-WRITE while incrementing burst ongoing...
If(with_bursting & bus.cyc & bus.stb & ((bus.cti == 0b10) | (bus.cti == 0b11)),
# Stay in DAT-WRITE while Incrementing Burst ongoing...
If(with_bursting & bus.cyc & bus.stb & burst_w,
bus_latch.eq(1),
NextState("DAT-WRITE")
# ..else exit.
Expand All @@ -479,14 +496,18 @@ def __init__(self, phy, latency=7, latency_mode="fixed", clk_ratio="4:1", with_b
)

# Data Read State.
self.comb += burst_r.eq(
# Notified Incrementing Burst.
(bus.cti == 0b10)
)
fsm.act("DAT-READ",
source.valid.eq(bus.cyc & bus.stb),
source.dat_r.eq(1),
If(dat_rx_conv.source.valid,
bus.ack.eq(1),
bus.dat_r.eq(dat_rx_conv.source.dq),
# Stay in DAT-READ while incrementing burst ongoing...
If(with_bursting & (bus.cti == 0b10),
# Stay in DAT-READ while Incrementing Burst ongoing...
If(with_bursting & bus.cyc & bus.stb & burst_r,
NextState("DAT-READ")
# ..else exit.
).Else(
Expand Down

0 comments on commit f283f7a

Please sign in to comment.