forked from M-Labs/humpback-dds
35 lines
798 B
Python
35 lines
798 B
Python
|
from humpback import HumpbackPlatform
|
||
|
from migen.fhdl.module import Module
|
||
|
|
||
|
class UrukulConnector(Module):
|
||
|
def __init__(self, platform):
|
||
|
# Request EEM I/O & SPI
|
||
|
eem = platform.request("eem", 1)
|
||
|
spi = platform.request("spi")
|
||
|
|
||
|
# Assert signal length
|
||
|
assert len(eem.p) == 8
|
||
|
assert len(eem.n) == 8
|
||
|
assert len(spi.sclk) == 1
|
||
|
assert len(spi.mosi) == 1
|
||
|
assert len(spi.miso) == 1
|
||
|
assert len(spi.cs) == 3
|
||
|
|
||
|
# Flip positive signal as negative output
|
||
|
self.comb += eem.n.eq(~eem.p)
|
||
|
|
||
|
# Link EEM to SPI
|
||
|
self.comb += [
|
||
|
eem.p[0].eq(spi.sclk),
|
||
|
eem.p[1].eq(spi.mosi),
|
||
|
eem.p[2].eq(spi.miso),
|
||
|
eem.p[3].eq(spi.cs[0]),
|
||
|
eem.p[4].eq(spi.cs[1]),
|
||
|
eem.p[5].eq(spi.cs[2]),
|
||
|
]
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
platform = HumpbackPlatform()
|
||
|
platform.build(UrukulConnector(platform))
|