Skip to content

Commit

Permalink
phy: switch to bus
Browse files Browse the repository at this point in the history
switch to SDR/DDRTristateBus and SDROutputBus.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
  • Loading branch information
maass-hamburg committed Nov 14, 2024
1 parent c6a5d81 commit dcd9c19
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 26 deletions.
27 changes: 12 additions & 15 deletions litespi/phy/generic_ddr.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,23 @@ def __init__(self, pads, flash, cs_delay, extra_latency=0):
cs_enable = Signal()
self.comb += cs_timer.wait.eq(self.cs != 0)
self.comb += cs_enable.eq(cs_timer.done)
for i in range(len(pads.cs_n)):
self.specials += SDROutput(
i = ~(cs_enable & self.cs[i]),
o = pads.cs_n[i]
)

# I/Os.
data_bits = 32
cs_n = Signal().like(pads.cs_n)
self.comb += cs_n.eq(~(Replicate(cs_enable, len(pads.cs_n)) & self.cs))
self.specials += SDROutput(
i = cs_n,
o = pads.cs_n
)

dq_o = Array([Signal(len(pads.dq)) for _ in range(2)])
dq_i = Array([Signal(len(pads.dq)) for _ in range(2)])
dq_oe = Array([Signal(len(pads.dq)) for _ in range(2)])

for i in range(len(pads.dq)):
self.specials += DDRTristate(
io = pads.dq[i],
o1 = dq_o[0][i], o2 = dq_o[1][i],
oe1 = dq_oe[0][i], oe2 = dq_oe[1][i],
i1 = dq_i[0][i], i2 = dq_i[1][i]
)
self.specials += DDRTristate(
io = pads.dq,
o1 = dq_o[0], o2 = dq_o[1],
oe1 = dq_oe[0], oe2 = dq_oe[1],
i1 = dq_i[0], i2 = dq_i[1]
)

# Data Shift Registers.
sr_cnt = Signal(8, reset_less=True)
Expand Down
22 changes: 11 additions & 11 deletions litespi/phy/generic_sdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,12 @@ def __init__(self, pads, flash, device, clock_domain, default_divisor, cs_delay)
cs_enable = Signal()
self.comb += cs_timer.wait.eq(self.cs != 0)
self.comb += cs_enable.eq(cs_timer.done)
for i in range(len(pads.cs_n)):
self.specials += SDROutput(
i = ~(cs_enable & self.cs[i]),
o = pads.cs_n[i]
)
cs_n = Signal().like(pads.cs_n)
self.comb += cs_n.eq(~(Replicate(cs_enable, len(pads.cs_n)) & self.cs))
self.specials += SDROutput(
i = cs_n,
o = pads.cs_n
)

if hasattr(pads, "mosi"):
dq_o = Signal()
Expand All @@ -118,12 +119,11 @@ def __init__(self, pads, flash, device, clock_domain, default_divisor, cs_delay)
dq_o = Signal().like(pads.dq)
dq_i = Signal().like(pads.dq)
dq_oe = Signal().like(pads.dq)
for i in range(len(pads.dq)):
self.specials += SDRTristate(
io = pads.dq[i],
o = dq_o[i],
oe = dq_oe[i],
i = dq_i[i],
self.specials += SDRTristate(
io = pads.dq,
o = dq_o,
oe = dq_oe,
i = dq_i,
)

# Data Shift Registers.
Expand Down

0 comments on commit dcd9c19

Please sign in to comment.