From: Florent Kermarrec Date: Wed, 4 Feb 2015 21:15:59 +0000 (+0100) Subject: udpip_tb: able to send valid UDP msg to model X-Git-Tag: 24jan2021_ls180~2604^2~87 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a9da9dc7509eb8c89cb66ae21dfb26f544d3db25;p=litex.git udpip_tb: able to send valid UDP msg to model --- diff --git a/liteeth/core/ip.py b/liteeth/core/ip.py index d1978682..812dc8a0 100644 --- a/liteeth/core/ip.py +++ b/liteeth/core/ip.py @@ -49,7 +49,7 @@ class LiteEthIPTX(Module): 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), + self.sink.ack.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)), @@ -61,7 +61,8 @@ class LiteEthIPTX(Module): packetizer.sink.flags.eq(0), packetizer.sink.fragment_offset.eq(0), packetizer.sink.time_to_live.eq(0x80), - packetizer.sink.source_ip_address.eq(ip_address) + packetizer.sink.source_ip_address.eq(ip_address), + packetizer.sink.data.eq(self.sink.data) ] sink = packetizer.source diff --git a/liteeth/core/udp.py b/liteeth/core/udp.py index 2a6d93ec..777d76d3 100644 --- a/liteeth/core/udp.py +++ b/liteeth/core/udp.py @@ -29,11 +29,12 @@ class LiteEthUDPTX(Module): 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), + self.sink.ack.eq(packetizer.sink.ack), packetizer.sink.source_port.eq(self.sink.source_port), packetizer.sink.destination_port.eq(self.sink.destination_port), packetizer.sink.length.eq(self.sink.length + udp_header_len), packetizer.sink.checksum.eq(0), + packetizer.sink.data.eq(self.sink.data) ] sink = packetizer.source diff --git a/liteeth/test/common.py b/liteeth/test/common.py index 496df5d8..bbdca435 100644 --- a/liteeth/test/common.py +++ b/liteeth/test/common.py @@ -72,7 +72,7 @@ class Packet(list): self.append(data) class PacketStreamer(Module): - def __init__(self, description, last_be=1): + def __init__(self, description, last_be=None): self.source = Source(description) self.last_be = last_be ### diff --git a/liteeth/test/udpip_tb.py b/liteeth/test/udpip_tb.py index 69efa4bb..10fd7e19 100644 --- a/liteeth/test/udpip_tb.py +++ b/liteeth/test/udpip_tb.py @@ -14,13 +14,21 @@ mac_address = 0x12345678abcd class TB(Module): def __init__(self): - self.submodules.phy_model = phy.PHY(8, debug=False) - 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) - self.submodules.ip_model = ip.IP(self.mac_model, mac_address, ip_address, debug=False, loopback=True) - self.submodules.udp_model = udp.UDP(self.ip_model, ip_address, debug=False, loopback=True) + self.submodules.phy_model = phy.PHY(8, debug=True) + self.submodules.mac_model = mac.MAC(self.phy_model, debug=True, loopback=False) + self.submodules.arp_model = arp.ARP(self.mac_model, mac_address, ip_address, debug=True) + self.submodules.ip_model = ip.IP(self.mac_model, mac_address, ip_address, debug=True, loopback=False) + self.submodules.udp_model = udp.UDP(self.ip_model, ip_address, debug=True, loopback=False) self.submodules.udp_ip = LiteEthUDPIPCore(self.phy_model, mac_address, ip_address) + self.submodules.streamer = PacketStreamer(eth_udp_user_description(8)) + self.comb += [ + Record.connect(self.streamer.source, self.udp_ip.sink), + self.udp_ip.sink.ip_address.eq(0x12345678), + self.udp_ip.sink.source_port.eq(0x1234), + self.udp_ip.sink.destination_port.eq(0x5678), + self.udp_ip.sink.length.eq(64) + ] # use sys_clk for each clock_domain self.clock_domains.cd_eth_rx = ClockDomain() @@ -43,19 +51,8 @@ class TB(Module): yield while True: - selfp.udp_ip.sink.stb = 1 - selfp.udp_ip.sink.sop = 1 - selfp.udp_ip.sink.eop = 1 - selfp.udp_ip.sink.ip_address = 0x12345678 - selfp.udp_ip.sink.source_port = 0x1234 - selfp.udp_ip.sink.destination_port = 0x5678 - selfp.udp_ip.sink.length = 64 - - selfp.udp_ip.source.ack = 1 - if selfp.udp_ip.source.stb == 1 and selfp.udp_ip.source.sop == 1: - print("IP Packet / from ip_address %08x" %selfp.udp_ip.sink.source_port) - - yield + packet = Packet([i for i in range(64)]) + yield from self.streamer.send(packet) if __name__ == "__main__": run_simulation(TB(), ncycles=2048, vcd_name="my.vcd", keep_files=True)