diff --git a/liteeth/test/arp_tb.py b/liteeth/test/arp_tb.py index 373a48018..3cd9ad362 100644 --- a/liteeth/test/arp_tb.py +++ b/liteeth/test/arp_tb.py @@ -50,7 +50,7 @@ class TB(Module): while selfp.arp.table.response.stb != 1: selfp.arp.table.response.ack = 1 yield - print("Model's MAC : 0x%12x" %selfp.arp.table.response.mac_address) + print("Received MAC : 0x{:12x}".format(selfp.arp.table.response.mac_address)) if __name__ == "__main__": diff --git a/liteeth/test/ip_tb.py b/liteeth/test/ip_tb.py index 96b6d3418..1c21ffa5c 100644 --- a/liteeth/test/ip_tb.py +++ b/liteeth/test/ip_tb.py @@ -51,7 +51,7 @@ class TB(Module): selfp.ip_port.source.ack = 1 if selfp.ip_port.source.stb == 1 and selfp.ip_port.source.sop == 1: - print("IP Packet / from ip_address %08x" %selfp.ip_port.sink.ip_address) + print("packet from from IP 0x{:08x}".format(selfp.ip_port.sink.ip_address)) yield diff --git a/liteeth/test/model/arp.py b/liteeth/test/model/arp.py index 7a23f23ff..677904cc7 100644 --- a/liteeth/test/model/arp.py +++ b/liteeth/test/model/arp.py @@ -33,10 +33,10 @@ class ARPPacket(Packet): def __repr__(self): r = "--------\n" for k in sorted(arp_header.keys()): - r += k + " : 0x%x" %getattr(self,k) + "\n" + r += k + " : 0x{:0x}\n".format(getattr(self,k)) r += "payload: " for d in self: - r += "%02x" %d + r += "{:02x}".format(d) return r class ARP(Module): diff --git a/liteeth/test/model/icmp.py b/liteeth/test/model/icmp.py index 8a27b61f9..cf54b17c3 100644 --- a/liteeth/test/model/icmp.py +++ b/liteeth/test/model/icmp.py @@ -31,10 +31,10 @@ class ICMPPacket(Packet): def __repr__(self): r = "--------\n" for k in sorted(icmp_header.keys()): - r += k + " : 0x%x" %getattr(self,k) + "\n" + r += k + " : 0x{:0x}\n".format(getattr(self,k)) r += "payload: " for d in self: - r += "%02x" %d + r += "{:02x}".format(d) return r class ICMP(Module): diff --git a/liteeth/test/model/ip.py b/liteeth/test/model/ip.py index 964284470..03c5f8b58 100644 --- a/liteeth/test/model/ip.py +++ b/liteeth/test/model/ip.py @@ -55,10 +55,10 @@ class IPPacket(Packet): def __repr__(self): r = "--------\n" for k in sorted(ipv4_header.keys()): - r += k + " : 0x%x" %getattr(self,k) + "\n" + r += k + " : 0x{:0x}\n".format(getattr(self,k)) r += "payload: " for d in self: - r += "%02x" %d + r += "{:02x}".format(d) return r class IP(Module): @@ -101,7 +101,7 @@ class IP(Module): received = packet.get_checksum() packet.insert_checksum() expected = packet.get_checksum() - raise ValueError("Checksum error received %04x / expected %04x" %(received, expected)) + raise ValueError("Checksum error received {:04x} / expected {:04x}".format(received, expected)) packet.decode() if self.debug: print_ip("<<<<<<<<") diff --git a/liteeth/test/model/mac.py b/liteeth/test/model/mac.py index f18f49906..9267f88bb 100644 --- a/liteeth/test/model/mac.py +++ b/liteeth/test/model/mac.py @@ -77,10 +77,10 @@ class MACPacket(Packet): def __repr__(self): r = "--------\n" for k in sorted(mac_header.keys()): - r += k + " : 0x%x" %getattr(self,k) + "\n" + r += k + " : 0x{:0x}\n".format(getattr(self,k)) r += "payload: " for d in self: - r += "%02x" %d + r += "{:02x}".format(d) return r class MAC(Module): diff --git a/liteeth/test/model/phy.py b/liteeth/test/model/phy.py index 8fc716295..1401110fe 100644 --- a/liteeth/test/model/phy.py +++ b/liteeth/test/model/phy.py @@ -35,7 +35,7 @@ class PHY(Module): r = ">>>>>>>>\n" r += "length " + str(len(datas)) + "\n" for d in datas: - r += "%02x" %d + r += "{:02x}".format(d) print_phy(r) self.phy_source.send(packet) @@ -45,7 +45,7 @@ class PHY(Module): r = "<<<<<<<<\n" r += "length " + str(len(self.phy_sink.packet)) + "\n" for d in self.phy_sink.packet: - r += "%02x" %d + r += "{:02x}".format(d) print_phy(r) self.packet = self.phy_sink.packet diff --git a/liteeth/test/model/udp.py b/liteeth/test/model/udp.py index 7179b9ff2..1892a2d56 100644 --- a/liteeth/test/model/udp.py +++ b/liteeth/test/model/udp.py @@ -31,10 +31,10 @@ class UDPPacket(Packet): def __repr__(self): r = "--------\n" for k in sorted(udp_header.keys()): - r += k + " : 0x%x" %getattr(self,k) + "\n" + r += k + " : 0x{:0x}\n".format(getattr(self,k)) r += "payload: " for d in self: - r += "%02x" %d + r += "{:02x}".format(d) return r class UDP(Module):