liteeth: pep8 (E265)

This commit is contained in:
Florent Kermarrec 2015-04-13 11:23:27 +02:00
parent 45dc4920ec
commit 154d3d3b04
35 changed files with 158 additions and 79 deletions

View File

@ -24,7 +24,9 @@ class LiteEthARPTX(Module):
def __init__(self, mac_address, ip_address): def __init__(self, mac_address, ip_address):
self.sink = sink = Sink(_arp_table_layout) self.sink = sink = Sink(_arp_table_layout)
self.source = source = Source(eth_mac_description(8)) self.source = source = Source(eth_mac_description(8))
###
# # #
self.submodules.packetizer = packetizer = LiteEthARPPacketizer() self.submodules.packetizer = packetizer = LiteEthARPPacketizer()
counter = Counter(max=max(arp_header_len, eth_min_len)) counter = Counter(max=max(arp_header_len, eth_min_len))
@ -88,7 +90,9 @@ class LiteEthARPRX(Module):
def __init__(self, mac_address, ip_address): def __init__(self, mac_address, ip_address):
self.sink = sink = Sink(eth_mac_description(8)) self.sink = sink = Sink(eth_mac_description(8))
self.source = source = Source(_arp_table_layout) self.source = source = Source(_arp_table_layout)
###
# # #
self.submodules.depacketizer = depacketizer = LiteEthARPDepacketizer() self.submodules.depacketizer = depacketizer = LiteEthARPDepacketizer()
self.comb += Record.connect(sink, depacketizer.sink) self.comb += Record.connect(sink, depacketizer.sink)
@ -139,12 +143,14 @@ class LiteEthARPRX(Module):
class LiteEthARPTable(Module): class LiteEthARPTable(Module):
def __init__(self, clk_freq, max_requests=8): def __init__(self, clk_freq, max_requests=8):
self.sink = sink = Sink(_arp_table_layout) # from arp_rx self.sink = sink = Sink(_arp_table_layout) # from arp_rx
self.source = source = Source(_arp_table_layout) # to arp_tx self.source = source = Source(_arp_table_layout) # to arp_tx
# Request/Response interface # Request/Response interface
self.request = request = Sink(arp_table_request_layout) self.request = request = Sink(arp_table_request_layout)
self.response = response = Source(arp_table_response_layout) self.response = response = Source(arp_table_response_layout)
###
# # #
request_timeout = Timeout(clk_freq//10) request_timeout = Timeout(clk_freq//10)
request_counter = Counter(max=max_requests) request_counter = Counter(max=max_requests)
request_pending = FlipFlop() request_pending = FlipFlop()

View File

@ -17,7 +17,9 @@ class LiteEthEtherbonePacketTX(Module):
def __init__(self, udp_port): def __init__(self, udp_port):
self.sink = sink = Sink(eth_etherbone_packet_user_description(32)) self.sink = sink = Sink(eth_etherbone_packet_user_description(32))
self.source = source = Source(eth_udp_user_description(32)) self.source = source = Source(eth_udp_user_description(32))
###
# # #
self.submodules.packetizer = packetizer = LiteEthEtherbonePacketPacketizer() self.submodules.packetizer = packetizer = LiteEthEtherbonePacketPacketizer()
self.comb += [ self.comb += [
packetizer.sink.stb.eq(sink.stb), packetizer.sink.stb.eq(sink.stb),
@ -68,7 +70,9 @@ class LiteEthEtherbonePacketRX(Module):
def __init__(self): def __init__(self):
self.sink = sink = Sink(eth_udp_user_description(32)) self.sink = sink = Sink(eth_udp_user_description(32))
self.source = source = Source(eth_etherbone_packet_user_description(32)) self.source = source = Source(eth_etherbone_packet_user_description(32))
###
# # #
self.submodules.depacketizer = depacketizer = LiteEthEtherbonePacketDepacketizer() self.submodules.depacketizer = depacketizer = LiteEthEtherbonePacketDepacketizer()
self.comb += Record.connect(sink, depacketizer.sink) self.comb += Record.connect(sink, depacketizer.sink)

View File

@ -6,7 +6,9 @@ class LiteEthEtherboneProbe(Module):
def __init__(self): def __init__(self):
self.sink = sink = Sink(eth_etherbone_packet_user_description(32)) self.sink = sink = Sink(eth_etherbone_packet_user_description(32))
self.source = source = Source(eth_etherbone_packet_user_description(32)) self.source = source = Source(eth_etherbone_packet_user_description(32))
###
# # #
self.submodules.fsm = fsm = FSM(reset_state="IDLE") self.submodules.fsm = fsm = FSM(reset_state="IDLE")
fsm.act("IDLE", fsm.act("IDLE",
sink.ack.eq(1), sink.ack.eq(1),

View File

@ -26,7 +26,9 @@ class LiteEthEtherboneRecordReceiver(Module):
def __init__(self, buffer_depth=256): def __init__(self, buffer_depth=256):
self.sink = sink = Sink(eth_etherbone_record_description(32)) self.sink = sink = Sink(eth_etherbone_record_description(32))
self.source = source = Source(eth_etherbone_mmap_description(32)) self.source = source = Source(eth_etherbone_mmap_description(32))
###
# # #
fifo = SyncFIFO(eth_etherbone_record_description(32), buffer_depth, buffered=True) fifo = SyncFIFO(eth_etherbone_record_description(32), buffer_depth, buffered=True)
self.submodules += fifo self.submodules += fifo
self.comb += Record.connect(sink, fifo.sink) self.comb += Record.connect(sink, fifo.sink)
@ -98,7 +100,9 @@ class LiteEthEtherboneRecordSender(Module):
def __init__(self, buffer_depth=256): def __init__(self, buffer_depth=256):
self.sink = sink = Sink(eth_etherbone_mmap_description(32)) self.sink = sink = Sink(eth_etherbone_mmap_description(32))
self.source = source = Source(eth_etherbone_record_description(32)) self.source = source = Source(eth_etherbone_record_description(32))
###
# # #
pbuffer = PacketBuffer(eth_etherbone_mmap_description(32), buffer_depth) pbuffer = PacketBuffer(eth_etherbone_mmap_description(32), buffer_depth)
self.submodules += pbuffer self.submodules += pbuffer
self.comb += Record.connect(sink, pbuffer.sink) self.comb += Record.connect(sink, pbuffer.sink)
@ -148,7 +152,8 @@ class LiteEthEtherboneRecord(Module):
def __init__(self, endianness="big"): def __init__(self, endianness="big"):
self.sink = sink = Sink(eth_etherbone_packet_user_description(32)) self.sink = sink = Sink(eth_etherbone_packet_user_description(32))
self.source = source = Sink(eth_etherbone_packet_user_description(32)) self.source = source = Sink(eth_etherbone_packet_user_description(32))
###
# # #
# receive record, decode it and generate mmap stream # receive record, decode it and generate mmap stream
self.submodules.depacketizer = depacketizer = LiteEthEtherboneRecordDepacketizer() self.submodules.depacketizer = depacketizer = LiteEthEtherboneRecordDepacketizer()

View File

@ -8,7 +8,8 @@ class LiteEthEtherboneWishboneMaster(Module):
self.sink = sink = Sink(eth_etherbone_mmap_description(32)) self.sink = sink = Sink(eth_etherbone_mmap_description(32))
self.source = source = Source(eth_etherbone_mmap_description(32)) self.source = source = Source(eth_etherbone_mmap_description(32))
self.bus = bus = wishbone.Interface() self.bus = bus = wishbone.Interface()
###s
# # #
self.submodules.data = data = FlipFlop(32) self.submodules.data = data = FlipFlop(32)
self.comb += data.d.eq(bus.dat_r) self.comb += data.d.eq(bus.dat_r)

View File

@ -17,7 +17,9 @@ class LiteEthICMPTX(Module):
def __init__(self, ip_address): def __init__(self, ip_address):
self.sink = sink = Sink(eth_icmp_user_description(8)) self.sink = sink = Sink(eth_icmp_user_description(8))
self.source = source = Source(eth_ipv4_user_description(8)) self.source = source = Source(eth_ipv4_user_description(8))
###
# # #
self.submodules.packetizer = packetizer = LiteEthICMPPacketizer() self.submodules.packetizer = packetizer = LiteEthICMPPacketizer()
self.comb += [ self.comb += [
packetizer.sink.stb.eq(sink.stb), packetizer.sink.stb.eq(sink.stb),
@ -63,7 +65,9 @@ class LiteEthICMPRX(Module):
def __init__(self, ip_address): def __init__(self, ip_address):
self.sink = sink = Sink(eth_ipv4_user_description(8)) self.sink = sink = Sink(eth_ipv4_user_description(8))
self.source = source = Source(eth_icmp_user_description(8)) self.source = source = Source(eth_icmp_user_description(8))
###
# # #
self.submodules.depacketizer = depacketizer = LiteEthICMPDepacketizer() self.submodules.depacketizer = depacketizer = LiteEthICMPDepacketizer()
self.comb += Record.connect(sink, depacketizer.sink) self.comb += Record.connect(sink, depacketizer.sink)
@ -118,7 +122,9 @@ class LiteEthICMPEcho(Module):
def __init__(self): def __init__(self):
self.sink = sink = Sink(eth_icmp_user_description(8)) self.sink = sink = Sink(eth_icmp_user_description(8))
self.source = source = Source(eth_icmp_user_description(8)) self.source = source = Source(eth_icmp_user_description(8))
###
# # #
self.submodules.buffer = PacketBuffer(eth_icmp_user_description(8), 128, 2) self.submodules.buffer = PacketBuffer(eth_icmp_user_description(8), 128, 2)
self.comb += [ self.comb += [
Record.connect(sink, self.buffer.sink), Record.connect(sink, self.buffer.sink),

View File

@ -20,7 +20,9 @@ class LiteEthIPTX(Module):
self.sink = sink = Sink(eth_ipv4_user_description(8)) self.sink = sink = Sink(eth_ipv4_user_description(8))
self.source = source = Source(eth_mac_description(8)) self.source = source = Source(eth_mac_description(8))
self.target_unreachable = Signal() self.target_unreachable = Signal()
###
# # #
self.submodules.checksum = checksum = LiteEthIPV4Checksum(skip_checksum=True) self.submodules.checksum = checksum = LiteEthIPV4Checksum(skip_checksum=True)
self.comb += [ self.comb += [
checksum.ce.eq(sink.stb & sink.sop), checksum.ce.eq(sink.stb & sink.sop),
@ -108,7 +110,9 @@ class LiteEthIPRX(Module):
def __init__(self, mac_address, ip_address): def __init__(self, mac_address, ip_address):
self.sink = sink = Sink(eth_mac_description(8)) self.sink = sink = Sink(eth_mac_description(8))
self.source = source = Source(eth_ipv4_user_description(8)) self.source = source = Source(eth_ipv4_user_description(8))
###
# # #
self.submodules.depacketizer = depacketizer = LiteEthIPV4Depacketizer() self.submodules.depacketizer = depacketizer = LiteEthIPV4Depacketizer()
self.comb += Record.connect(sink, depacketizer.sink) self.comb += Record.connect(sink, depacketizer.sink)

View File

@ -9,7 +9,9 @@ class LiteEthIPV4Checksum(Module):
self.header = Signal(ipv4_header_len*8) self.header = Signal(ipv4_header_len*8)
self.value = Signal(16) self.value = Signal(16)
self.done = Signal() self.done = Signal()
###
# # #
s = Signal(17) s = Signal(17)
r = Signal(17) r = Signal(17)
n_cycles = 0 n_cycles = 0

View File

@ -6,7 +6,9 @@ class LiteEthTTYTX(Module):
def __init__(self, ip_address, udp_port, fifo_depth=None): def __init__(self, ip_address, udp_port, fifo_depth=None):
self.sink = sink = Sink(eth_tty_description(8)) self.sink = sink = Sink(eth_tty_description(8))
self.source = source = Source(eth_udp_user_description(8)) self.source = source = Source(eth_udp_user_description(8))
###
# # #
if fifo_depth is None: if fifo_depth is None:
self.comb += [ self.comb += [
source.stb.eq(sink.stb), source.stb.eq(sink.stb),
@ -64,7 +66,9 @@ class LiteEthTTYRX(Module):
def __init__(self, ip_address, udp_port, fifo_depth=None): def __init__(self, ip_address, udp_port, fifo_depth=None):
self.sink = sink = Sink(eth_udp_user_description(8)) self.sink = sink = Sink(eth_udp_user_description(8))
self.source = source = Source(eth_tty_description(8)) self.source = source = Source(eth_tty_description(8))
###
# # #
valid = Signal() valid = Signal()
self.comb += valid.eq( self.comb += valid.eq(
(sink.ip_address == ip_address) & (sink.ip_address == ip_address) &

View File

@ -18,7 +18,9 @@ class LiteEthUDPTX(Module):
def __init__(self, ip_address): def __init__(self, ip_address):
self.sink = sink = Sink(eth_udp_user_description(8)) self.sink = sink = Sink(eth_udp_user_description(8))
self.source = source = Source(eth_ipv4_user_description(8)) self.source = source = Source(eth_ipv4_user_description(8))
###
# # #
self.submodules.packetizer = packetizer = LiteEthUDPPacketizer() self.submodules.packetizer = packetizer = LiteEthUDPPacketizer()
self.comb += [ self.comb += [
packetizer.sink.stb.eq(sink.stb), packetizer.sink.stb.eq(sink.stb),
@ -64,7 +66,9 @@ class LiteEthUDPRX(Module):
def __init__(self, ip_address): def __init__(self, ip_address):
self.sink = sink = Sink(eth_ipv4_user_description(8)) self.sink = sink = Sink(eth_ipv4_user_description(8))
self.source = source = Source(eth_udp_user_description(8)) self.source = source = Source(eth_udp_user_description(8))
###
# # #
self.submodules.depacketizer = depacketizer = LiteEthUDPDepacketizer() self.submodules.depacketizer = depacketizer = LiteEthUDPDepacketizer()
self.comb += Record.connect(sink, depacketizer.sink) self.comb += Record.connect(sink, depacketizer.sink)

View File

@ -7,8 +7,7 @@ def main(wb):
wb.open() wb.open()
regs = wb.regs regs = wb.regs
### # # #
conditions = {} conditions = {}
la.configure_term(port=0, cond=conditions) la.configure_term(port=0, cond=conditions)
la.configure_sum("term") la.configure_sum("term")
@ -20,6 +19,5 @@ def main(wb):
la.upload() la.upload()
la.save("dump.vcd") la.save("dump.vcd")
# # #
###
wb.close() wb.close()

View File

@ -1,12 +1,12 @@
def main(wb): def main(wb):
wb.open() wb.open()
regs = wb.regs regs = wb.regs
### # # #
print("sysid : 0x{:04x}".format(regs.identifier_sysid.read())) print("sysid : 0x{:04x}".format(regs.identifier_sysid.read()))
print("revision : 0x{:04x}".format(regs.identifier_revision.read())) print("revision : 0x{:04x}".format(regs.identifier_revision.read()))
print("frequency : {}MHz".format(int(regs.identifier_frequency.read()/1000000))) print("frequency : {}MHz".format(int(regs.identifier_frequency.read()/1000000)))
SRAM_BASE = 0x02000000 SRAM_BASE = 0x02000000
wb.write(SRAM_BASE, [i for i in range(64)]) wb.write(SRAM_BASE, [i for i in range(64)])
print(wb.read(SRAM_BASE, 64)) print(wb.read(SRAM_BASE, 64))
### # # #
wb.close() wb.close()

View File

@ -68,7 +68,8 @@ class PacketBuffer(Module):
self.sink = sink = Sink(description) self.sink = sink = Sink(description)
self.source = source = Source(description) self.source = source = Source(description)
### # # #
sink_status = EndpointPacketStatus(self.sink) sink_status = EndpointPacketStatus(self.sink)
source_status = EndpointPacketStatus(self.source) source_status = EndpointPacketStatus(self.source)
self.submodules += sink_status, source_status self.submodules += sink_status, source_status

View File

@ -16,7 +16,9 @@ class LiteEthDepacketizer(Module):
self.sink = sink = Sink(sink_description) self.sink = sink = Sink(sink_description)
self.source = source = Source(source_description) self.source = source = Source(source_description)
self.header = Signal(header_length*8) self.header = Signal(header_length*8)
###
# # #
dw = flen(sink.data) dw = flen(sink.data)
header_words = (header_length*8)//dw header_words = (header_length*8)//dw

View File

@ -14,7 +14,9 @@ class Dispatcher(Module):
self.sel = Signal(len(sinks)) self.sel = Signal(len(sinks))
else: else:
self.sel = Signal(max=len(sinks)) self.sel = Signal(max=len(sinks))
###
# # #
sop = Signal() sop = Signal()
self.comb += sop.eq(source.stb & source.sop) self.comb += sop.eq(source.stb & source.sop)
sel = Signal(flen(self.sel)) sel = Signal(flen(self.sel))

View File

@ -16,7 +16,9 @@ class LiteEthPacketizer(Module):
self.sink = sink = Sink(sink_description) self.sink = sink = Sink(sink_description)
self.source = source = Source(source_description) self.source = source = Source(source_description)
self.header = Signal(header_length*8) self.header = Signal(header_length*8)
###
# # #
dw = flen(self.sink.data) dw = flen(self.sink.data)
header_reg = Signal(header_length*8) header_reg = Signal(header_length*8)

View File

@ -31,7 +31,7 @@ class LiteEthMACCRCEngine(Module):
self.last = Signal(width) self.last = Signal(width)
self.next = Signal(width) self.next = Signal(width)
### # # #
def _optimize_eq(l): def _optimize_eq(l):
""" """
@ -101,7 +101,7 @@ class LiteEthMACCRC32(Module):
self.value = Signal(self.width) self.value = Signal(self.width)
self.error = Signal() self.error = Signal()
### # # #
self.submodules.engine = LiteEthMACCRCEngine(data_width, self.width, self.polynom) self.submodules.engine = LiteEthMACCRCEngine(data_width, self.width, self.polynom)
reg = Signal(self.width, reset=self.init) reg = Signal(self.width, reset=self.init)
@ -137,7 +137,7 @@ class LiteEthMACCRCInserter(Module):
self.source = source = Source(description) self.source = source = Source(description)
self.busy = Signal() self.busy = Signal()
### # # #
dw = flen(sink.data) dw = flen(sink.data)
crc = crc_class(dw) crc = crc_class(dw)
@ -218,7 +218,7 @@ class LiteEthMACCRCChecker(Module):
self.source = source = Source(description) self.source = source = Source(description)
self.busy = Signal() self.busy = Signal()
### # # #
dw = flen(sink.data) dw = flen(sink.data)
crc = crc_class(dw) crc = crc_class(dw)

View File

@ -6,7 +6,9 @@ class LiteEthMACGap(Module):
def __init__(self, dw, ack_on_gap=False): def __init__(self, dw, ack_on_gap=False):
self.sink = sink = Sink(eth_phy_description(dw)) self.sink = sink = Sink(eth_phy_description(dw))
self.source = source = Source(eth_phy_description(dw)) self.source = source = Source(eth_phy_description(dw))
###
# # #
gap = math.ceil(eth_interpacket_gap/(dw//8)) gap = math.ceil(eth_interpacket_gap/(dw//8))
self.submodules.counter = counter = Counter(max=gap) self.submodules.counter = counter = Counter(max=gap)

View File

@ -6,7 +6,9 @@ class LiteEthMACTXLastBE(Module):
def __init__(self, dw): def __init__(self, dw):
self.sink = sink = Sink(eth_phy_description(dw)) self.sink = sink = Sink(eth_phy_description(dw))
self.source = source = Source(eth_phy_description(dw)) self.source = source = Source(eth_phy_description(dw))
###
# # #
ongoing = Signal() ongoing = Signal()
self.sync += \ self.sync += \
If(sink.stb & sink.ack, If(sink.stb & sink.ack,
@ -29,7 +31,9 @@ class LiteEthMACRXLastBE(Module):
def __init__(self, dw): def __init__(self, dw):
self.sink = sink = Sink(eth_phy_description(dw)) self.sink = sink = Sink(eth_phy_description(dw))
self.source = source = Source(eth_phy_description(dw)) self.source = source = Source(eth_phy_description(dw))
###
# # #
self.comb += [ self.comb += [
source.stb.eq(sink.stb), source.stb.eq(sink.stb),
source.sop.eq(sink.sop), source.sop.eq(sink.sop),

View File

@ -6,7 +6,9 @@ class LiteEthMACPaddingInserter(Module):
def __init__(self, dw, packet_min_length): def __init__(self, dw, packet_min_length):
self.sink = sink = Sink(eth_phy_description(dw)) self.sink = sink = Sink(eth_phy_description(dw))
self.source = source = Source(eth_phy_description(dw)) self.source = source = Source(eth_phy_description(dw))
###
# # #
packet_min_data = math.ceil(packet_min_length/(dw/8)) packet_min_data = math.ceil(packet_min_length/(dw/8))
self.submodules.counter = counter = Counter(max=eth_mtu) self.submodules.counter = counter = Counter(max=eth_mtu)
@ -42,7 +44,9 @@ class LiteEthMACPaddingChecker(Module):
def __init__(self, dw, packet_min_length): def __init__(self, dw, packet_min_length):
self.sink = sink = Sink(eth_phy_description(dw)) self.sink = sink = Sink(eth_phy_description(dw))
self.source = source = Source(eth_phy_description(dw)) self.source = source = Source(eth_phy_description(dw))
###
# # #
# XXX see if we should drop the packet when # XXX see if we should drop the packet when
# payload size < minimum ethernet payload size # payload size < minimum ethernet payload size
self.comb += Record.connect(sink, source) self.comb += Record.connect(sink, source)

View File

@ -7,7 +7,7 @@ class LiteEthMACPreambleInserter(Module):
self.sink = Sink(eth_phy_description(dw)) self.sink = Sink(eth_phy_description(dw))
self.source = Source(eth_phy_description(dw)) self.source = Source(eth_phy_description(dw))
### # # #
preamble = Signal(64, reset=eth_preamble) preamble = Signal(64, reset=eth_preamble)
cnt_max = (64//dw)-1 cnt_max = (64//dw)-1
@ -57,7 +57,7 @@ class LiteEthMACPreambleChecker(Module):
self.sink = Sink(eth_phy_description(dw)) self.sink = Sink(eth_phy_description(dw))
self.source = Source(eth_phy_description(dw)) self.source = Source(eth_phy_description(dw))
### # # #
preamble = Signal(64, reset=eth_preamble) preamble = Signal(64, reset=eth_preamble)
cnt_max = (64//dw) - 1 cnt_max = (64//dw) - 1

View File

@ -20,7 +20,7 @@ class LiteEthMACSRAMWriter(Module, AutoCSR):
self.ev.available = EventSourceLevel() self.ev.available = EventSourceLevel()
self.ev.finalize() self.ev.finalize()
### # # #
# packet dropped if no slot available # packet dropped if no slot available
sink.ack.reset = 1 sink.ack.reset = 1
@ -133,7 +133,7 @@ class LiteEthMACSRAMReader(Module, AutoCSR):
self.ev.done = EventSourcePulse() self.ev.done = EventSourcePulse()
self.ev.finalize() self.ev.finalize()
### # # #
# command fifo # command fifo
fifo = SyncFIFO([("slot", slotbits), ("length", lengthbits)], nslots) fifo = SyncFIFO([("slot", slotbits), ("length", lengthbits)], nslots)

View File

@ -11,7 +11,9 @@ class LiteEthMACWishboneInterface(Module, AutoCSR):
self.sink = Sink(eth_phy_description(dw)) self.sink = Sink(eth_phy_description(dw))
self.source = Source(eth_phy_description(dw)) self.source = Source(eth_phy_description(dw))
self.bus = wishbone.Interface() self.bus = wishbone.Interface()
###
# # #
# storage in SRAM # storage in SRAM
sram_depth = buffer_depth//(dw//8) sram_depth = buffer_depth//(dw//8)
self.submodules.sram = sram.LiteEthMACSRAM(dw, sram_depth, nrxslots, ntxslots) self.submodules.sram = sram.LiteEthMACSRAM(dw, sram_depth, nrxslots, ntxslots)

View File

@ -7,7 +7,9 @@ from misoclib.com.liteeth.generic import *
class LiteEthPHYGMIITX(Module): class LiteEthPHYGMIITX(Module):
def __init__(self, pads, pads_register): def __init__(self, pads, pads_register):
self.sink = sink = Sink(eth_phy_description(8)) self.sink = sink = Sink(eth_phy_description(8))
###
# # #
if hasattr(pads, "tx_er"): if hasattr(pads, "tx_er"):
self.sync += pads.tx_er.eq(0) self.sync += pads.tx_er.eq(0)
pads_eq = [ pads_eq = [
@ -24,7 +26,9 @@ class LiteEthPHYGMIITX(Module):
class LiteEthPHYGMIIRX(Module): class LiteEthPHYGMIIRX(Module):
def __init__(self, pads): def __init__(self, pads):
self.source = source = Source(eth_phy_description(8)) self.source = source = Source(eth_phy_description(8))
###
# # #
dv_d = Signal() dv_d = Signal()
self.sync += dv_d.eq(pads.dv) self.sync += dv_d.eq(pads.dv)
@ -45,7 +49,9 @@ class LiteEthPHYGMIIRX(Module):
class LiteEthPHYGMIICRG(Module, AutoCSR): class LiteEthPHYGMIICRG(Module, AutoCSR):
def __init__(self, clock_pads, pads, with_hw_init_reset, mii_mode=0): def __init__(self, clock_pads, pads, with_hw_init_reset, mii_mode=0):
self._reset = CSRStorage() self._reset = CSRStorage()
###
# # #
self.clock_domains.cd_eth_rx = ClockDomain() self.clock_domains.cd_eth_rx = ClockDomain()
self.clock_domains.cd_eth_tx = ClockDomain() self.clock_domains.cd_eth_tx = ClockDomain()

View File

@ -21,7 +21,9 @@ rx_pads_layout = [("rx_er", 1), ("dv", 1), ("rx_data", 8)]
class LiteEthPHYGMIIMIITX(Module): class LiteEthPHYGMIIMIITX(Module):
def __init__(self, pads, mode): def __init__(self, pads, mode):
self.sink = sink = Sink(eth_phy_description(8)) self.sink = sink = Sink(eth_phy_description(8))
###
# # #
gmii_tx_pads = Record(tx_pads_layout) gmii_tx_pads = Record(tx_pads_layout)
gmii_tx = LiteEthPHYGMIITX(gmii_tx_pads, pads_register=False) gmii_tx = LiteEthPHYGMIITX(gmii_tx_pads, pads_register=False)
self.submodules += gmii_tx self.submodules += gmii_tx
@ -55,7 +57,9 @@ class LiteEthPHYGMIIMIITX(Module):
class LiteEthPHYGMIIMIIRX(Module): class LiteEthPHYGMIIMIIRX(Module):
def __init__(self, pads, mode): def __init__(self, pads, mode):
self.source = source = Source(eth_phy_description(8)) self.source = source = Source(eth_phy_description(8))
###
# # #
pads_d = Record(rx_pads_layout) pads_d = Record(rx_pads_layout)
self.sync += [ self.sync += [
pads_d.dv.eq(pads.dv), pads_d.dv.eq(pads.dv),
@ -82,7 +86,9 @@ class LiteEthGMIIMIIClockCounter(Module, AutoCSR):
def __init__(self): def __init__(self):
self._reset = CSRStorage() self._reset = CSRStorage()
self._value = CSRStatus(32) self._value = CSRStatus(32)
###
# # #
counter = RenameClockDomains(Counter(32), "eth_rx") counter = RenameClockDomains(Counter(32), "eth_rx")
self.submodules += counter self.submodules += counter
self.comb += [ self.comb += [

View File

@ -5,7 +5,9 @@ from misoclib.com.liteeth.generic import *
class LiteEthPHYLoopbackCRG(Module, AutoCSR): class LiteEthPHYLoopbackCRG(Module, AutoCSR):
def __init__(self): def __init__(self):
self._reset = CSRStorage() self._reset = CSRStorage()
###
# # #
self.clock_domains.cd_eth_rx = ClockDomain() self.clock_domains.cd_eth_rx = ClockDomain()
self.clock_domains.cd_eth_tx = ClockDomain() self.clock_domains.cd_eth_tx = ClockDomain()
self.comb += [ self.comb += [

View File

@ -10,7 +10,9 @@ def converter_description(dw):
class LiteEthPHYMIITX(Module): class LiteEthPHYMIITX(Module):
def __init__(self, pads, pads_register=True): def __init__(self, pads, pads_register=True):
self.sink = sink = Sink(eth_phy_description(8)) self.sink = sink = Sink(eth_phy_description(8))
###
# # #
if hasattr(pads, "tx_er"): if hasattr(pads, "tx_er"):
self.sync += pads.tx_er.eq(0) self.sync += pads.tx_er.eq(0)
converter = Converter(converter_description(8), converter_description(4)) converter = Converter(converter_description(8), converter_description(4))
@ -34,7 +36,9 @@ class LiteEthPHYMIITX(Module):
class LiteEthPHYMIIRX(Module): class LiteEthPHYMIIRX(Module):
def __init__(self, pads): def __init__(self, pads):
self.source = source = Source(eth_phy_description(8)) self.source = source = Source(eth_phy_description(8))
###
# # #
sop = FlipFlop(reset=1) sop = FlipFlop(reset=1)
self.submodules += sop self.submodules += sop
@ -59,7 +63,9 @@ class LiteEthPHYMIIRX(Module):
class LiteEthPHYMIICRG(Module, AutoCSR): class LiteEthPHYMIICRG(Module, AutoCSR):
def __init__(self, clock_pads, pads, with_hw_init_reset): def __init__(self, clock_pads, pads, with_hw_init_reset):
self._reset = CSRStorage() self._reset = CSRStorage()
###
# # #
if hasattr(clock_pads, "phy"): if hasattr(clock_pads, "phy"):
self.sync.base50 += clock_pads.phy.eq(~clock_pads.phy) self.sync.base50 += clock_pads.phy.eq(~clock_pads.phy)

View File

@ -8,7 +8,7 @@ class LiteEthPHYSimCRG(Module, AutoCSR):
def __init__(self): def __init__(self):
self._reset = CSRStorage() self._reset = CSRStorage()
### # # #
self.clock_domains.cd_eth_rx = ClockDomain() self.clock_domains.cd_eth_rx = ClockDomain()
self.clock_domains.cd_eth_tx = ClockDomain() self.clock_domains.cd_eth_tx = ClockDomain()

View File

@ -86,7 +86,9 @@ class PacketStreamer(Module):
def __init__(self, description, last_be=None): def __init__(self, description, last_be=None):
self.source = Source(description) self.source = Source(description)
self.last_be = last_be self.last_be = last_be
###
# # #
self.packets = [] self.packets = []
self.packet = Packet() self.packet = Packet()
self.packet.done = True self.packet.done = True
@ -130,7 +132,9 @@ class PacketStreamer(Module):
class PacketLogger(Module): class PacketLogger(Module):
def __init__(self, description): def __init__(self, description):
self.sink = Sink(description) self.sink = Sink(description)
###
# # #
self.packet = Packet() self.packet = Packet()
def receive(self): def receive(self):

View File

@ -130,12 +130,12 @@ if __name__ == "__main__":
packet = ARPPacket(packet) packet = ARPPacket(packet)
# check decoding # check decoding
packet.decode() packet.decode()
#print(packet) # print(packet)
errors += verify_packet(packet, arp_request_infos) errors += verify_packet(packet, arp_request_infos)
# check encoding # check encoding
packet.encode() packet.encode()
packet.decode() packet.decode()
#print(packet) # print(packet)
errors += verify_packet(packet, arp_request_infos) errors += verify_packet(packet, arp_request_infos)
# ARP Reply # ARP Reply
@ -144,12 +144,12 @@ if __name__ == "__main__":
packet = ARPPacket(packet) packet = ARPPacket(packet)
# check decoding # check decoding
packet.decode() packet.decode()
#print(packet) # print(packet)
errors += verify_packet(packet, arp_reply_infos) errors += verify_packet(packet, arp_reply_infos)
# check encoding # check encoding
packet.encode() packet.encode()
packet.decode() packet.decode()
#print(packet) # print(packet)
errors += verify_packet(packet, arp_reply_infos) errors += verify_packet(packet, arp_reply_infos)
print("arp errors " + str(errors)) print("arp errors " + str(errors))

View File

@ -349,9 +349,9 @@ if __name__ == "__main__":
packet.nr = 0 packet.nr = 0
packet.pr = 0 packet.pr = 0
packet.pf = 0 packet.pf = 0
#print(packet) # print(packet)
packet.encode() packet.encode()
#print(packet) # print(packet)
# Send packet over UDP to check against Wireshark dissector # Send packet over UDP to check against Wireshark dissector
import socket import socket

View File

@ -89,17 +89,17 @@ if __name__ == "__main__":
# ICMP packet # ICMP packet
packet = MACPacket(ping_request) packet = MACPacket(ping_request)
packet.decode_remove_header() packet.decode_remove_header()
#print(packet) # print(packet)
packet = IPPacket(packet) packet = IPPacket(packet)
packet.decode() packet.decode()
#print(packet) # print(packet)
packet = ICMPPacket(packet) packet = ICMPPacket(packet)
packet.decode() packet.decode()
#print(packet) # print(packet)
errors += verify_packet(packet, ping_request_infos) errors += verify_packet(packet, ping_request_infos)
packet.encode() packet.encode()
packet.decode() packet.decode()
#print(packet) # print(packet)
errors += verify_packet(packet, ping_request_infos) errors += verify_packet(packet, ping_request_infos)
print("icmp errors " + str(errors)) print("icmp errors " + str(errors))

View File

@ -135,19 +135,19 @@ if __name__ == "__main__":
# UDP packet # UDP packet
packet = MACPacket(udp) packet = MACPacket(udp)
packet.decode_remove_header() packet.decode_remove_header()
#print(packet) # print(packet)
packet = IPPacket(packet) packet = IPPacket(packet)
# check decoding # check decoding
errors += not packet.check_checksum() errors += not packet.check_checksum()
packet.decode() packet.decode()
#print(packet) # print(packet)
errors += verify_packet(packet, {}) errors += verify_packet(packet, {})
# check encoding # check encoding
packet.encode() packet.encode()
packet.insert_checksum() packet.insert_checksum()
errors += not packet.check_checksum() errors += not packet.check_checksum()
packet.decode() packet.decode()
#print(packet) # print(packet)
errors += verify_packet(packet, {}) errors += verify_packet(packet, {})
print("ip errors " + str(errors)) print("ip errors " + str(errors))

View File

@ -136,20 +136,20 @@ if __name__ == "__main__":
errors = 0 errors = 0
packet = MACPacket(arp_request) packet = MACPacket(arp_request)
packet.decode_remove_header() packet.decode_remove_header()
#print(packet) # print(packet)
errors += verify_packet(packet, arp_request_infos) errors += verify_packet(packet, arp_request_infos)
packet.encode_header() packet.encode_header()
packet.decode_remove_header() packet.decode_remove_header()
#print(packet) # print(packet)
errors += verify_packet(packet, arp_request_infos) errors += verify_packet(packet, arp_request_infos)
#print(packet) # print(packet)
packet = MACPacket(arp_reply) packet = MACPacket(arp_reply)
packet.decode_remove_header() packet.decode_remove_header()
errors += verify_packet(packet, arp_reply_infos) errors += verify_packet(packet, arp_reply_infos)
packet.encode_header() packet.encode_header()
packet.decode_remove_header() packet.decode_remove_header()
#print(packet) # print(packet)
errors += verify_packet(packet, arp_reply_infos) errors += verify_packet(packet, arp_reply_infos)
print("mac errors " + str(errors)) print("mac errors " + str(errors))

View File

@ -100,19 +100,19 @@ if __name__ == "__main__":
# UDP packet # UDP packet
packet = MACPacket(udp) packet = MACPacket(udp)
packet.decode_remove_header() packet.decode_remove_header()
#print(packet) # print(packet)
packet = IPPacket(packet) packet = IPPacket(packet)
packet.decode() packet.decode()
#print(packet) # print(packet)
packet = UDPPacket(packet) packet = UDPPacket(packet)
packet.decode() packet.decode()
#print(packet) # print(packet)
if packet.length != (len(packet)+udp_header_len): if packet.length != (len(packet)+udp_header_len):
errors += 1 errors += 1
errors += verify_packet(packet, udp_infos) errors += verify_packet(packet, udp_infos)
packet.encode() packet.encode()
packet.decode() packet.decode()
#print(packet) # print(packet)
if packet.length != (len(packet)+udp_header_len): if packet.length != (len(packet)+udp_header_len):
errors += 1 errors += 1
errors += verify_packet(packet, udp_infos) errors += verify_packet(packet, udp_infos)