"destination_ip_address": HField(16, 0, 32),
"options": HField(20, 0, 32)
}
+
udp_header_len = 8
udp_header = {
"source_port": HField( 0, 0, 16),
def eth_ipv4_user_description(dw):
layout = [
- ("total_length", 16),
+ ("length", 16),
("protocol", 8),
- ("destination_ip_address", 32),
+ ("ip_address", 32),
("data", dw),
("error", dw//8)
]
packetizer = LiteEthIPV4Packetizer()
self.submodules += packetizer
self.comb += [
- Record.connect(self.sink, packetizer.sink),
- packetizer.sink.version.eq(0x5),
- packetizer.sink.ihl.eq(0x4),
+ packetizer.sink.stb.eq(self.sink.stb),
+ packetizer.sink.sop.eq(self.sink.sop),
+ packetizer.sink.eop.eq(self.sink.eop),
+ self.sink.eq(packetizer.sink.ack),
+ packetizer.sink.destination_ip_address.eq(ip_address),
+ packetizer.sink.protocol.eq(self.sink.protocol),
+ packetizer.sink.total_length.eq(self.sink.length + (0x5*4)),
+ packetizer.sink.version.eq(0x4), # ipv4
+ packetizer.sink.ihl.eq(0x5), # 20 bytes
packetizer.sink.dscp.eq(0),
packetizer.sink.ecn.eq(0),
packetizer.sink.identification.eq(0),
)
fsm.act("SEND_MAC_ADDRESS_REQUEST",
arp_table.request.stb.eq(1),
- arp_table.request.ip_address.eq(self.sink.destination_ip_address),
+ arp_table.request.ip_address.eq(self.sink.ip_address),
If(arp_table.request.stb & arp_table.request.ack,
NextState("WAIT_MAC_ADDRESS_RESPONSE")
)
source.sop.eq(sink.sop),
source.eop.eq(sink.eop),
sink.ack.eq(source.ack),
- source.total_length.eq(sink.total_length),
+ source.length.eq(sink.total_length - (sink.ihl*4)),
source.protocol.eq(sink.protocol),
- source.destination_ip_address.eq(sink.destination_ip_address),
+ source.ip_address.eq(sink.destination_ip_address),
source.data.eq(sink.data),
source.error.eq(sink.error),
If(source.stb & source.eop & source.ack,
class TB(Module):
def __init__(self):
- self.submodules.phy_model = phy.PHY(8, debug=False)
+ self.submodules.phy_model = phy.PHY(8, debug=True)
self.submodules.mac_model = mac.MAC(self.phy_model, debug=False, loopback=False)
self.submodules.arp_model = arp.ARP(self.mac_model, mac_address, ip_address, debug=False)
while selfp.arp.table.response.stb != 1:
selfp.arp.table.response.ack = 1
yield
- print("Model MAC : 0x%12x" %selfp.arp.table.response.mac_address)
+ print("Model's MAC : 0x%12x" %selfp.arp.table.response.mac_address)
if __name__ == "__main__":