Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5480099f1bbd
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: aeae565d35c0
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Feb 29, 2016

  1. Copy the full SHA
    ad34927 View commit details
  2. gateware.spi: style

    jordens committed Feb 29, 2016
    Copy the full SHA
    948fefa View commit details
  3. 2
    Copy the full SHA
    aeae565 View commit details
Showing with 19 additions and 21 deletions.
  1. +16 −18 artiq/gateware/spi.py
  2. +1 −1 artiq/gateware/targets/kc705.py
  3. +1 −1 artiq/gateware/targets/pipistrello.py
  4. +1 −1 artiq/runtime/spi.c
34 changes: 16 additions & 18 deletions artiq/gateware/spi.py
Original file line number Diff line number Diff line change
@@ -282,10 +282,9 @@ def __init__(self, pads, bus=None, data_width=32):
])
assert len(xfer) <= len(bus.dat_w)

# SPI
spi = SPIMachine(data_width, clock_width=len(config.div_read),
bits_width=len(xfer.read_length))
self.submodules += spi
self.submodules.spi = spi = SPIMachine(
data_width, clock_width=len(config.div_read),
bits_width=len(xfer.read_length))

wb_we = Signal()
pending = Signal()
@@ -344,12 +343,12 @@ def __init__(self, pads, bus=None, data_width=32):

self.comb += [
clk_t.oe.eq(~config.offline),
clk_t.o.eq((spi.cg.clk & spi.cs) ^ config.clk_polarity),
mosi_t.oe.eq(~config.offline & spi.cs &
(spi.oe | ~config.half_duplex)),
clk_t.o.eq((spi.cg.clk & spi.cs) ^ config.clk_polarity),
mosi_t.o.eq(spi.reg.o),
spi.reg.i.eq(Mux(config.half_duplex, mosi_t.i,
getattr(pads, "miso", mosi_t.i))),
mosi_t.o.eq(spi.reg.o),
]


@@ -438,32 +437,31 @@ def _test_gen(bus):
hex(wdata), hex(rdata), hex(a), hex(b))



class _TestPads:
def __init__(self):
self.cs_n = Signal(3)
self.cs_n = Signal(2)
self.clk = Signal()
self.mosi = Signal()
self.miso = Signal()


class _TestTristate(Module):
def __init__(self, t):
oe = Signal()
self.comb += [
t.target.eq(t.o),
oe.eq(t.oe),
t.i.eq(t.o),
]

if __name__ == "__main__":
from migen.fhdl.specials import Tristate

class T(Module):
def __init__(self, t):
oe = Signal()
self.comb += [
t.target.eq(t.o),
oe.eq(t.oe),
t.i.eq(t.o),
]
Tristate.lower = staticmethod(lambda dr: T(dr))

pads = _TestPads()
dut = SPIMaster(pads)
dut.comb += pads.miso.eq(pads.mosi)
# from migen.fhdl.verilog import convert
# print(convert(dut))

Tristate.lower = _TestTristate
run_simulation(dut, _test_gen(dut.bus), vcd_name="spi_master.vcd")
2 changes: 1 addition & 1 deletion artiq/gateware/targets/kc705.py
Original file line number Diff line number Diff line change
@@ -259,7 +259,7 @@ def __init__(self, cpu_type="or1k", **kwargs):

phy = spi.SPIMaster(spi_pins)
self.submodules += phy
self.config["RTIO_SPI_CHANNEL"] = len(rtio_channels)
self.config["RTIO_FIRST_SPI_CHANNEL"] = len(rtio_channels)
rtio_channels.append(rtio.Channel.from_phy(
phy, ofifo_depth=4, ififo_depth=4))

2 changes: 1 addition & 1 deletion artiq/gateware/targets/pipistrello.py
Original file line number Diff line number Diff line change
@@ -200,7 +200,7 @@ def __init__(self, cpu_type="or1k", **kwargs):
spi_pins.cs_n = pmod.d[3:]
phy = spi.SPIMaster(spi_pins)
self.submodules += phy
self.config["RTIO_SPI_CHANNEL"] = len(rtio_channels)
self.config["RTIO_FIRST_SPI_CHANNEL"] = len(rtio_channels)
rtio_channels.append(rtio.Channel.from_phy(
phy, ofifo_depth=4, ififo_depth=4))

2 changes: 1 addition & 1 deletion artiq/runtime/spi.c
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
void spi_write(long long int timestamp, int channel, int addr,
unsigned int data)
{
rtio_chan_sel_write(CONFIG_RTIO_SPI_CHANNEL + channel);
rtio_chan_sel_write(channel);
rtio_o_address_write(addr);
rtio_o_data_write(data);
rtio_o_timestamp_write(timestamp);