def eth_etherbone_packet_user_description(dw):
param_layout = _layout_from_header(etherbone_packet_header)
- param_layout = _remove_from_layout(param_layout, "magic", "portsize", "addrsize", "version")
+ param_layout = _remove_from_layout(param_layout,
+ "magic",
+ "portsize",
+ "addrsize",
+ "version")
param_layout += eth_udp_user_description(dw).param_layout
payload_layout = [
("data", dw),
)
fsm.act("DROP",
depacketizer.source.ack.eq(1),
- If(depacketizer.source.stb & depacketizer.source.eop & depacketizer.source.ack,
+ If(depacketizer.source.stb &
+ depacketizer.source.eop &
+ depacketizer.source.ack,
NextState("IDLE")
)
)
# # #
- 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.comb += Record.connect(sink, fifo.sink)
self.comb += [
Record.connect(sender.source, packetizer.sink),
Record.connect(packetizer.source, source),
- source.length.eq(sender.source.wcount*4 + 4 + etherbone_record_header_len), # XXX improve this
+ # XXX improve this
+ source.length.eq(sender.source.wcount*4 + 4 + etherbone_record_header_len),
source.ip_address.eq(last_ip_address)
]
if endianness is "big":
)
fsm.act("DROP",
depacketizer.source.ack.eq(1),
- If(depacketizer.source.stb & depacketizer.source.eop & depacketizer.source.ack,
+ If(depacketizer.source.stb &
+ depacketizer.source.eop &
+ depacketizer.source.ack,
NextState("IDLE")
)
)
)
fsm.act("DROP",
packetizer.source.ack.eq(1),
- If(packetizer.source.stb & packetizer.source.eop & packetizer.source.ack,
+ If(packetizer.source.stb &
+ packetizer.source.eop &
+ packetizer.source.ack,
NextState("IDLE")
)
)
)
fsm.act("DROP",
depacketizer.source.ack.eq(1),
- If(depacketizer.source.stb & depacketizer.source.eop & depacketizer.source.ack,
+ If(depacketizer.source.stb &
+ depacketizer.source.eop &
+ depacketizer.source.ack,
NextState("IDLE")
)
)
)
fsm.act("DROP",
depacketizer.source.ack.eq(1),
- If(depacketizer.source.stb & depacketizer.source.eop & depacketizer.source.ack,
+ If(depacketizer.source.stb &
+ depacketizer.source.eop &
+ depacketizer.source.ack,
NextState("IDLE")
)
)
user_port = LiteEthUDPUserPort(dw)
internal_port = LiteEthUDPUserPort(8)
if dw != 8:
- converter = Converter(eth_udp_user_description(user_port.dw), eth_udp_user_description(8))
+ converter = Converter(eth_udp_user_description(user_port.dw),
+ eth_udp_user_description(8))
self.submodules += converter
self.comb += [
Record.connect(user_port.sink, converter.sink),
Record.connect(converter.source, internal_port.sink)
]
- converter = Converter(eth_udp_user_description(8), eth_udp_user_description(user_port.dw))
+ converter = Converter(eth_udp_user_description(8),
+ eth_udp_user_description(user_port.dw))
self.submodules += converter
self.comb += [
Record.connect(internal_port.source, converter.sink),
parser.add_argument("-b", "--bridge", default="uart", help="Bridge to use")
parser.add_argument("--port", default="2", help="UART port")
parser.add_argument("--baudrate", default=115200, help="UART baudrate")
- parser.add_argument("--ip_address", default="192.168.0.42", help="Etherbone IP address")
+ parser.add_argument("--ip_address", default="192.168.0.42", help="Etherbone IP address")
parser.add_argument("--udp_port", default=20000, help="Etherbone UDP port")
parser.add_argument("--busword", default=32, help="CSR busword")
# RX dispatch
sources = [port.source for port in self.users.values()]
- self.submodules.dispatcher = Dispatcher(self.master.sink, sources, one_hot=True)
+ self.submodules.dispatcher = Dispatcher(self.master.sink,
+ sources,
+ one_hot=True)
cases = {}
cases["default"] = self.dispatcher.sel.eq(0)
for i, (k, v) in enumerate(self.users.items()):
# Converters
if dw != phy.dw:
reverse = endianness == "big"
- tx_converter = Converter(eth_phy_description(dw), eth_phy_description(phy.dw), reverse=reverse)
- rx_converter = Converter(eth_phy_description(phy.dw), eth_phy_description(dw), reverse=reverse)
+ tx_converter = Converter(eth_phy_description(dw),
+ eth_phy_description(phy.dw),
+ reverse=reverse)
+ rx_converter = Converter(eth_phy_description(phy.dw),
+ eth_phy_description(dw),
+ reverse=reverse)
self.submodules += RenameClockDomains(tx_converter, "eth_tx")
self.submodules += RenameClockDomains(rx_converter, "eth_rx")
self.specials += DDROutput(1, mii_mode, clock_pads.gtx, ClockSignal("eth_tx"))
# XXX Xilinx specific, replace BUFGMUX with a generic clock buffer?
self.specials += Instance("BUFGMUX",
- i_I0=self.cd_eth_rx.clk,
- i_I1=clock_pads.tx,
- i_S=mii_mode,
- o_O=self.cd_eth_tx.clk)
+ i_I0=self.cd_eth_rx.clk,
+ i_I1=clock_pads.tx,
+ i_S=mii_mode,
+ o_O=self.cd_eth_tx.clk)
if with_hw_init_reset:
reset = Signal()
class LiteEthPHYGMII(Module, AutoCSR):
def __init__(self, clock_pads, pads, with_hw_init_reset=True):
self.dw = 8
- self.submodules.crg = LiteEthPHYGMIICRG(clock_pads, pads, with_hw_init_reset)
- self.submodules.tx = RenameClockDomains(LiteEthPHYGMIITX(pads), "eth_tx")
- self.submodules.rx = RenameClockDomains(LiteEthPHYGMIIRX(pads), "eth_rx")
+ self.submodules.crg = LiteEthPHYGMIICRG(clock_pads,
+ pads,
+ with_hw_init_reset)
+ self.submodules.tx = RenameClockDomains(LiteEthPHYGMIITX(pads),
+ "eth_tx")
+ self.submodules.rx = RenameClockDomains(LiteEthPHYGMIIRX(pads),
+ "eth_rx")
self.sink, self.source = self.tx.sink, self.rx.source
if hasattr(pads, "tx_er"):
self.sync += pads.tx_er.eq(0)
- converter = Converter(converter_description(8), converter_description(4))
+ converter = Converter(converter_description(8),
+ converter_description(4))
self.submodules += converter
self.comb += [
converter.sink.stb.eq(sink.stb),
sop = FlipFlop(reset=1)
self.submodules += sop
- converter = Converter(converter_description(4), converter_description(8))
+ converter = Converter(converter_description(4),
+ converter_description(8))
converter = InsertReset(converter)
self.submodules += converter
# test writes
if test_writes:
writes_datas = [j for j in range(16)]
- writes = etherbone.EtherboneWrites(base_addr=0x1000, datas=writes_datas)
+ writes = etherbone.EtherboneWrites(base_addr=0x1000,
+ datas=writes_datas)
record = etherbone.EtherboneRecord()
record.writes = writes
record.reads = None
# test reads
if test_reads:
reads_addrs = [0x1000 + 4*j for j in range(16)]
- reads = etherbone.EtherboneReads(base_ret_addr=0x1000, addrs=reads_addrs)
+ reads = etherbone.EtherboneReads(base_ret_addr=0x1000,
+ addrs=reads_addrs)
record = etherbone.EtherboneRecord()
record.writes = None
record.reads = reads
def encode(self):
header = 0
for k, v in sorted(arp_header.items()):
- value = merge_bytes(split_bytes(getattr(self, k), math.ceil(v.width/8)), "little")
+ value = merge_bytes(split_bytes(getattr(self, k),
+ math.ceil(v.width/8)),
+ "little")
header += (value << v.offset+(v.byte*8))
for d in split_bytes(header, arp_header_len):
self.insert(0, d)
self.set_reads(self.reads)
header = 0
for k, v in sorted(etherbone_record_header.items()):
- value = merge_bytes(split_bytes(getattr(self, k), math.ceil(v.width/8)), "little")
+ value = merge_bytes(split_bytes(getattr(self, k),
+ math.ceil(v.width/8)),
+ "little")
header += (value << v.offset+(v.byte*8))
for d in split_bytes(header, etherbone_record_header_len):
self.insert(0, d)
def encode(self):
header = 0
for k, v in sorted(icmp_header.items()):
- value = merge_bytes(split_bytes(getattr(self, k), math.ceil(v.width/8)), "little")
+ value = merge_bytes(split_bytes(getattr(self, k),
+ math.ceil(v.width/8)),
+ "little")
header += (value << v.offset+(v.byte*8))
for d in split_bytes(header, icmp_header_len):
self.insert(0, d)
def encode(self):
header = 0
for k, v in sorted(ipv4_header.items()):
- value = merge_bytes(split_bytes(getattr(self, k), math.ceil(v.width/8)), "little")
+ value = merge_bytes(split_bytes(getattr(self, k),
+ math.ceil(v.width/8)),
+ "little")
header += (value << v.offset+(v.byte*8))
for d in split_bytes(header, ipv4_header_len):
self.insert(0, d)
def encode_header(self):
header = 0
for k, v in sorted(mac_header.items()):
- value = merge_bytes(split_bytes(getattr(self, k), math.ceil(v.width/8)), "little")
+ value = merge_bytes(split_bytes(getattr(self, k),
+ math.ceil(v.width/8)),
+ "little")
header += (value << v.offset+(v.byte*8))
for d in split_bytes(header, mac_header_len):
self.insert(0, d)
def encode(self):
header = 0
for k, v in sorted(udp_header.items()):
- value = merge_bytes(split_bytes(getattr(self, k), math.ceil(v.width/8)), "little")
+ value = merge_bytes(split_bytes(getattr(self, k),
+ math.ceil(v.width/8)),
+ "little")
header += (value << v.offset+(v.byte*8))
for d in split_bytes(header, udp_header_len):
self.insert(0, d)