1
0
mirror of https://github.com/corundum/corundum.git synced 2025-01-16 08:12:53 +08:00

Test very short packets

This commit is contained in:
Alex Forencich 2015-03-04 12:58:22 -08:00
parent 17ad08e412
commit 8ba6cf00d6
4 changed files with 154 additions and 0 deletions

View File

@ -26,6 +26,8 @@ THE SOFTWARE.
from myhdl import *
import os
from Queue import Queue
import struct
import zlib
import axis_ep
import eth_ep
@ -369,6 +371,42 @@ def bench():
yield delay(100)
for payload_len in list(range(1,18)):
yield clk.posedge
print("test 4: test short packet, length %d" % payload_len)
current_test.next = 4
test_frame = bytearray(range(payload_len))
for wait in wait_normal, wait_pause_source, wait_pause_sink:
source_queue.put(test_frame)
yield clk.posedge
yield clk.posedge
yield wait()
yield clk.posedge
yield clk.posedge
yield clk.posedge
rx_frame = None
if not sink_queue.empty():
rx_frame = sink_queue.get()
payload = rx_frame.data[:-4]
fcs = struct.unpack('<L', rx_frame.data[-4:])[0]
check_fcs = zlib.crc32(bytes(payload)) & 0xffffffff
print(hex(fcs))
print(hex(check_fcs))
assert test_frame == payload
assert check_fcs == fcs
assert sink_queue.empty()
yield delay(100)
raise StopSimulation
return dut, source, sink, clkgen, check

View File

@ -26,6 +26,8 @@ THE SOFTWARE.
from myhdl import *
import os
from Queue import Queue
import struct
import zlib
import axis_ep
import eth_ep
@ -386,6 +388,42 @@ def bench():
yield delay(100)
for payload_len in list(range(1,18)):
yield clk.posedge
print("test 4: test short packet, length %d" % payload_len)
current_test.next = 4
test_frame = bytearray(range(payload_len))
for wait in wait_normal, wait_pause_source, wait_pause_sink:
source_queue.put(test_frame)
yield clk.posedge
yield clk.posedge
yield wait()
yield clk.posedge
yield clk.posedge
yield clk.posedge
rx_frame = None
if not sink_queue.empty():
rx_frame = sink_queue.get()
payload = rx_frame.data[:-4]
fcs = struct.unpack('<L', rx_frame.data[-4:])[0]
check_fcs = zlib.crc32(bytes(payload)) & 0xffffffff
print(hex(fcs))
print(hex(check_fcs))
assert test_frame == payload
assert check_fcs == fcs
assert sink_queue.empty()
yield delay(100)
raise StopSimulation
return dut, source, sink, clkgen, check

View File

@ -26,6 +26,8 @@ THE SOFTWARE.
from myhdl import *
import os
from Queue import Queue
import struct
import zlib
import axis_ep
import eth_ep
@ -386,6 +388,43 @@ def bench():
yield delay(100)
for payload_len in list(range(1,18)):
yield clk.posedge
print("test 4: test short packet, length %d" % payload_len)
current_test.next = 4
test_frame = bytearray(range(payload_len))
for wait in wait_normal, wait_pause_source, wait_pause_sink:
source_queue.put(test_frame)
yield clk.posedge
yield clk.posedge
yield wait()
yield clk.posedge
yield clk.posedge
yield clk.posedge
rx_frame = None
if not sink_queue.empty():
rx_frame = sink_queue.get()
payload = rx_frame.data[:-4]
fcs = struct.unpack('<L', rx_frame.data[-4:])[0]
check_fcs = zlib.crc32(bytes(payload)) & 0xffffffff
print(hex(fcs))
print(hex(check_fcs))
assert len(payload) == 60
assert payload.index(test_frame) == 0
assert check_fcs == fcs
assert sink_queue.empty()
yield delay(100)
raise StopSimulation
return dut, source, sink, clkgen, check

View File

@ -26,6 +26,8 @@ THE SOFTWARE.
from myhdl import *
import os
from Queue import Queue
import struct
import zlib
import axis_ep
import eth_ep
@ -369,6 +371,43 @@ def bench():
yield delay(100)
for payload_len in list(range(1,18)):
yield clk.posedge
print("test 4: test short packet, length %d" % payload_len)
current_test.next = 4
test_frame = bytearray(range(payload_len))
for wait in wait_normal, wait_pause_source, wait_pause_sink:
source_queue.put(test_frame)
yield clk.posedge
yield clk.posedge
yield wait()
yield clk.posedge
yield clk.posedge
yield clk.posedge
rx_frame = None
if not sink_queue.empty():
rx_frame = sink_queue.get()
payload = rx_frame.data[:-4]
fcs = struct.unpack('<L', rx_frame.data[-4:])[0]
check_fcs = zlib.crc32(bytes(payload)) & 0xffffffff
print(hex(fcs))
print(hex(check_fcs))
assert len(payload) == 60
assert payload.index(test_frame) == 0
assert check_fcs == fcs
assert sink_queue.empty()
yield delay(100)
raise StopSimulation
return dut, source, sink, clkgen, check