test: use passive generators and some cleanup

This commit is contained in:
Florent Kermarrec 2016-03-23 01:42:35 +01:00
parent e73f35c733
commit 7ea1b5a22d
8 changed files with 17 additions and 37 deletions

5
test/arp_tb.py Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/env python3
from litex.gen import * from litex.gen import *
from litex.soc.interconnect import wishbone from litex.soc.interconnect import wishbone
@ -34,10 +35,6 @@ def main_generator(dut):
yield yield
print("Received MAC : 0x{:12x}".format((yield dut.arp.table.response.mac_address))) print("Received MAC : 0x{:12x}".format((yield dut.arp.table.response.mac_address)))
# XXX: find a way to exit properly
import sys
sys.exit()
if __name__ == "__main__": if __name__ == "__main__":
tb = TB() tb = TB()
generators = { generators = {

5
test/etherbone_tb.py Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/env python3
from litex.gen import * from litex.gen import *
from litex.soc.interconnect import wishbone from litex.soc.interconnect import wishbone
@ -96,10 +97,6 @@ def main_generator(dut):
s, l, e = check(writes_datas, loopback_writes_datas) s, l, e = check(writes_datas, loopback_writes_datas)
print("shift " + str(s) + " / length " + str(l) + " / errors " + str(e)) print("shift " + str(s) + " / length " + str(l) + " / errors " + str(e))
# XXX: find a way to exit properly
import sys
sys.exit()
if __name__ == "__main__": if __name__ == "__main__":
tb = TB() tb = TB()
generators = { generators = {

5
test/icmp_tb.py Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/env python3
from litex.gen import * from litex.gen import *
from litex.soc.interconnect import wishbone from litex.soc.interconnect import wishbone
@ -38,10 +39,6 @@ def main_generator(dut):
for i in range(256): for i in range(256):
yield yield
# XXX: find a way to exit properly
import sys
sys.exit()
if __name__ == "__main__": if __name__ == "__main__":
tb = TB() tb = TB()
generators = { generators = {

20
test/ip_tb.py Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/env python3
from litex.gen import * from litex.gen import *
from litex.soc.interconnect import wishbone from litex.soc.interconnect import wishbone
@ -23,20 +24,15 @@ class TB(Module):
self.ip_port = self.ip.ip.crossbar.get_port(udp_protocol) self.ip_port = self.ip.ip.crossbar.get_port(udp_protocol)
def main_generator(dut): def main_generator(dut):
while True: yield dut.ip_port.sink.valid.eq(1)
yield dut.ip_port.sink.valid.eq(1) yield dut.ip_port.sink.last.eq(1)
yield dut.ip_port.sink.last.eq(1) yield dut.ip_port.sink.ip_address.eq(0x12345678)
yield dut.ip_port.sink.ip_address.eq(0x12345678) yield dut.ip_port.sink.protocol.eq(udp_protocol)
yield dut.ip_port.sink.protocol.eq(udp_protocol)
yield dut.ip_port.source.ready.eq(1)
if (yield dut.ip_port.source.valid) == 1 and (yield dut.ip_port.source.last) == 1:
print("packet from IP 0x{:08x}".format((yield dut.ip_port.sink.ip_address)))
# XXX: find a way to exit properly
import sys
sys.exit()
yield dut.ip_port.source.ready.eq(1)
while not ((yield dut.ip_port.source.valid) and (yield dut.ip_port.source.last)):
yield yield
print("packet from IP 0x{:08x}".format((yield dut.ip_port.sink.ip_address)))
if __name__ == "__main__": if __name__ == "__main__":
tb = TB() tb = TB()

9
test/mac_core_tb.py Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/env python3
from litex.gen import * from litex.gen import *
from litex.soc.interconnect import wishbone from litex.soc.interconnect import wishbone
@ -16,9 +17,9 @@ class TB(Module):
self.submodules.core = LiteEthMACCore(phy=self.phy_model, dw=8, with_preamble_crc=True) self.submodules.core = LiteEthMACCore(phy=self.phy_model, dw=8, with_preamble_crc=True)
self.submodules.streamer = PacketStreamer(eth_phy_description(8), last_be=1) self.submodules.streamer = PacketStreamer(eth_phy_description(8), last_be=1)
self.submodules.streamer_randomizer = AckRandomizer(eth_phy_description(8), level=50) self.submodules.streamer_randomizer = Randomizer(eth_phy_description(8), level=50)
self.submodules.logger_randomizer = AckRandomizer(eth_phy_description(8), level=50) self.submodules.logger_randomizer = Randomizer(eth_phy_description(8), level=50)
self.submodules.logger = PacketLogger(eth_phy_description(8)) self.submodules.logger = PacketLogger(eth_phy_description(8))
self.comb += [ self.comb += [
@ -43,10 +44,6 @@ def main_generator(dut):
s, l, e = check(packet, dut.logger.packet) s, l, e = check(packet, dut.logger.packet)
print("shift " + str(s) + " / length " + str(l) + " / errors " + str(e)) print("shift " + str(s) + " / length " + str(l) + " / errors " + str(e))
# XXX: find a way to exit properly
import sys
sys.exit()
if __name__ == "__main__": if __name__ == "__main__":
tb = TB() tb = TB()
generators = { generators = {

4
test/mac_wishbone_tb.py Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/env python3
from litex.gen import * from litex.gen import *
from litex.soc.interconnect import wishbone from litex.soc.interconnect import wishbone
@ -111,9 +112,6 @@ def main_generator(dut):
dat = int.from_bytes(tx_payload[4*i:4*(i+1)], "big") dat = int.from_bytes(tx_payload[4*i:4*(i+1)], "big")
yield from wishbone_master.write(sram_reader_slots_offset[slot]+i, dat) yield from wishbone_master.write(sram_reader_slots_offset[slot]+i, dat)
# XXX: find a way to exit properly
import sys
sys.exit()
# # send tx payload & wait # # send tx payload & wait
# yield from sram_reader_driver.start(slot, length) # yield from sram_reader_driver.start(slot, length)

View File

@ -54,6 +54,7 @@ class PHY(Module):
print_phy(r) print_phy(r)
self.packet = self.phy_sink.packet self.packet = self.phy_sink.packet
@passive
def generator(self): def generator(self):
while True: while True:
yield from self.receive() yield from self.receive()

5
test/udp_tb.py Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/env python3
from litex.gen import * from litex.gen import *
from litex.soc.interconnect import wishbone from litex.soc.interconnect import wishbone
@ -43,10 +44,6 @@ def main_generator(dut):
s, l, e = check(packet, dut.logger.packet) s, l, e = check(packet, dut.logger.packet)
print("shift " + str(s) + " / length " + str(l) + " / errors " + str(e)) print("shift " + str(s) + " / length " + str(l) + " / errors " + str(e))
# XXX: find a way to exit properly
import sys
sys.exit()
if __name__ == "__main__": if __name__ == "__main__":
tb = TB(8) tb = TB(8)
generators = { generators = {