("d", 8)
]
+
class LiteUSBPipe:
def __init__(self, layout):
self.sink = Sink(layout)
self.source = Source(layout)
+
class LiteUSBTimeout(Module):
def __init__(self, clk_freq, length):
cnt_max = int(clk_freq*length)
#
import random
+
def randn(max_n):
return random.randint(0, max_n-1)
+
class RandRun:
def __init__(self, level=0):
self.run = True
from misoclib.com.liteusb.core.packetizer import LiteUSBPacketizer
from misoclib.com.liteusb.core.depacketizer import LiteUSBDepacketizer
+
class LiteUSBCom(Module):
def __init__(self, phy, *ports):
# crossbar
from misoclib.com.liteusb.common import *
+
class CRCEngine(Module):
"""Cyclic Redundancy Check Engine
xors += [self.d[n]]
self.comb += self.next[i].eq(optree("^", xors))
+
@DecorateModule(InsertReset)
@DecorateModule(InsertCE)
class CRC32(Module):
self.error.eq(self.engine.next != self.check)
]
+
class CRCInserter(Module):
"""CRC Inserter
)
self.comb += self.busy.eq(~fsm.ongoing("IDLE"))
+
class CRC32Inserter(CRCInserter):
def __init__(self, layout):
CRCInserter.__init__(self, CRC32, layout)
+
class CRCChecker(Module):
"""CRC Checker
)
self.comb += self.busy.eq(~fsm.ongoing("IDLE"))
+
class CRC32Checker(CRCChecker):
def __init__(self, layout):
CRCChecker.__init__(self, CRC32, layout)
+
class LiteUSBCRC32(Module):
def __init__(self, tag):
self.tag = tag
from misoclib.com.liteusb.common import *
+
class LiteUSBDepacketizer(Module):
def __init__(self, timeout=10):
self.sink = sink = Sink(phy_layout)
0x5A, 0xA5, 0x5A, 0xA5, 0x12, 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
]*4
+
class DepacketizerSourceModel(Module, Source, RandRun):
def __init__(self, data):
Source.__init__(self, phy_layout)
self.dut.source.connect(self.sink),
]
+
def main():
from migen.sim.generic import run_simulation
run_simulation(TB(), ncycles=400, vcd_name="tb_depacketizer.vcd")
from misoclib.com.liteusb.common import *
+
class LiteUSBPacketizer(Module):
def __init__(self):
self.sink = sink = Sink(user_layout)
),
(0x22, 16,
[0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF]
- ),
+ )
]
+
class PacketizerSourceModel(Module, Source, RandRun):
def __init__(self, data):
Source.__init__(self, user_layout, True)
if self._frame_cnt == len(self.data):
raise StopSimulation
+
class PacketizerSinkModel(Module, Sink, RandRun):
def __init__(self):
Sink.__init__(self, phy_layout)
self.dut.source.connect(self.sink),
]
+
def main():
from migen.sim.generic import run_simulation
run_simulation(TB(), ncycles=400, vcd_name="tb_packetizer.vcd")
from misoclib.com.liteusb.common import *
+
class LiteUSBCrossbar(Module):
def __init__(self, masters, slave=None):
if slave is None:
from migen.genlib.record import Record
from misoclib.mem.sdram.frontend import dma_lasmi
-
from misoclib.com.liteusb.common import *
+
class LiteUSBDMAWriter(Module, AutoCSR):
def __init__(self, lasmim):
self.sink = sink = Sink(user_layout)
self._crc_failed.status.eq(sink.error)
)
+
class LiteUSBDMAReader(Module, AutoCSR):
def __init__(self, lasmim, tag):
self.source = source = Source(user_layout)
self.ev.finalize()
self.comb += self.ev.done.trigger.eq(source.stb & source.eop)
+
class LiteUSBDMA(Module, AutoCSR):
def __init__(self, lasmim_ftdi_dma_wr, lasmim_ftdi_dma_rd, tag):
self.tag = tag
from misoclib.com.liteusb.common import *
+
class LiteUSBUART(Module, AutoCSR):
def __init__(self, tag, fifo_depth=64):
self.tag = tag
from misoclib.com.liteusb.common import *
+
class FT2232HPHY(Module):
def __init__(self, pads, fifo_depth=32, read_time=16, write_time=16):
dw = flen(pads.data)
self.wr_sim(selfp)
self.rd_sim(selfp)
+
class UserModel(Module, RandRun):
def __init__(self, wr_data):
RandRun.__init__(self, 50)
model_rd_data = [i%256 for i in range(LENGTH)][::-1]
user_wr_data = [i%256 for i in range(LENGTH)]
+
class TB(Module):
def __init__(self):
self.submodules.model = FT2232HModel(model_rd_data)
ResetSignal("ftdi").eq(ResetSignal())
]
+
def print_results(s, l1, l2):
def comp(l1, l2):
r = True
r += "[KO]"
print(r)
+
def main():
from migen.sim.generic import run_simulation
tb = TB()