forked from M-Labs/artiq-zynq
sim: fix frame test bench & add larger img
This commit is contained in:
parent
6834f136c7
commit
853d1efc84
24
sim_frame.py
24
sim_frame.py
|
@ -53,23 +53,24 @@ def check_case(packet=[]):
|
|||
# source = dut.dchar_decoder.source
|
||||
# source = dut.stream_pipe.frame_extractor.sink
|
||||
source = dut.sink
|
||||
print(
|
||||
f"\nCYCLE#{i} : source char = {yield source.data:#X} k = {yield source.k:#X} stb = {yield source.stb} ack = {yield source.ack} eop = {yield source.eop}"
|
||||
)
|
||||
# print(
|
||||
# f"\nCYCLE#{i} : source char = {yield source.data:#X} k = {yield source.k:#X} stb = {yield source.stb} ack = {yield source.ack} eop = {yield source.eop}"
|
||||
# )
|
||||
|
||||
# extra clk cycles
|
||||
cyc = i + 1
|
||||
img = []
|
||||
line = -1
|
||||
for i in range(cyc, cyc + 50):
|
||||
total_pixel = 1000
|
||||
for i in range(cyc, cyc + total_pixel):
|
||||
yield sink.data.eq(0)
|
||||
yield sink.k.eq(0)
|
||||
yield sink.stb.eq(0)
|
||||
yield sink.eop.eq(0)
|
||||
yield
|
||||
print(
|
||||
f"\nCYCLE#{i} : source char = {yield source.data:#X} k = {yield source.k:#X} stb = {yield source.stb} ack = {yield source.ack} eop = {yield source.eop}"
|
||||
)
|
||||
# print(
|
||||
# f"\nCYCLE#{i} : source char = {yield source.data:#X} k = {yield source.k:#X} stb = {yield source.stb} ack = {yield source.ack} eop = {yield source.eop}"
|
||||
# )
|
||||
|
||||
frame_extractoer = dut.stream_pipe.frame_extractor
|
||||
new_line = yield frame_extractoer.new_line
|
||||
|
@ -83,7 +84,6 @@ def check_case(packet=[]):
|
|||
# CXP use MSB
|
||||
img[line].append(np.uint16(data & 0xFFFF))
|
||||
img[line].append(np.uint16(data >> 16))
|
||||
print(img)
|
||||
|
||||
# metadata = dut.stream_pipe.frame_extractor.metadata
|
||||
# img_header_layout = [
|
||||
|
@ -101,7 +101,7 @@ def check_case(packet=[]):
|
|||
# for name in img_header_layout:
|
||||
# print(f"{name} = {yield getattr(metadata, name):#04X} ", end="")
|
||||
# print()
|
||||
Image.fromarray(np.array(img, dtype=np.uint16)).show()
|
||||
Image.fromarray(np.array(img, dtype=np.uint8)).show()
|
||||
assert True
|
||||
|
||||
|
||||
|
@ -113,16 +113,16 @@ def testbench():
|
|||
{"data": Replicate(C(stream_id, char_width), 4), "k": Replicate(0, 4)},
|
||||
{"data": Replicate(C(packet_tag, char_width), 4), "k": Replicate(0, 4)},
|
||||
{
|
||||
"data": Replicate(C(len(frame_packet), char_width)[8:], 4),
|
||||
"data": Replicate(C(len(frame_packet), 2*char_width)[8:], 4),
|
||||
"k": Replicate(0, 4),
|
||||
},
|
||||
{
|
||||
"data": Replicate(C(len(frame_packet), char_width)[:8], 4),
|
||||
"data": Replicate(C(len(frame_packet), 2*char_width)[:8], 4),
|
||||
"k": Replicate(0, 4),
|
||||
},
|
||||
]
|
||||
packet += frame_packet
|
||||
|
||||
# NOTE: for crc inserter!!!!
|
||||
packet[-1]["eop"] = 0
|
||||
|
||||
yield from check_case(packet)
|
||||
|
|
|
@ -64,7 +64,36 @@ def get_line_marker():
|
|||
def get_frame_packet(stream_id, pixel_format="mono16"):
|
||||
assert pixel_format in ["mono16"]
|
||||
|
||||
arr = [[4156, 31078], [65063, 24837]]
|
||||
arr = [
|
||||
[204, 200, 203, 205, 190, 187, 189, 205, 214, 197, 188, 185, 181, 178, 193, 209, 211, 207, 211, 192, 168, 168, 171, 199, 210, 212, 203, 196],
|
||||
[218, 205, 199, 190, 192, 197, 196, 195, 184, 178, 182, 173, 166, 132, 122, 114, 154, 184, 187, 188, 171, 168, 170, 180, 192, 196, 202, 198],
|
||||
[223, 222, 222, 224, 216, 199, 199, 207, 205, 189, 183, 182, 144, 66, 61, 66, 80, 148, 181, 175, 169, 170, 174, 177, 196, 206, 223, 218],
|
||||
[221, 226, 225, 222, 211, 200, 202, 208, 215, 201, 187, 180, 133, 116, 113, 118, 96, 111, 206, 193, 170, 169, 186, 211, 218, 224, 231, 223],
|
||||
[219, 216, 206, 197, 210, 201, 206, 203, 191, 190, 185, 145, 134, 140, 159, 170, 150, 116, 180, 173, 179, 170, 172, 185, 201, 218, 227, 227],
|
||||
[203, 198, 194, 208, 227, 201, 201, 201, 215, 221, 209, 170, 136, 113, 141, 139, 141, 145, 188, 170, 180, 169, 184, 173, 174, 192, 215, 230],
|
||||
[206, 224, 213, 213, 233, 207, 204, 226, 233, 227, 214, 166, 145, 123, 145, 155, 147, 186, 213, 187, 171, 169, 193, 193, 171, 178, 186, 207],
|
||||
[212, 228, 216, 205, 214, 205, 204, 230, 235, 225, 219, 187, 143, 122, 146, 163, 158, 195, 209, 203, 174, 168, 190, 185, 187, 202, 180, 174],
|
||||
[197, 206, 201, 223, 213, 201, 203, 231, 234, 225, 218, 206, 147, 125, 149, 155, 190, 208, 206, 203, 175, 168, 171, 179, 184, 206, 189, 176],
|
||||
[213, 202, 209, 235, 223, 200, 202, 202, 227, 227, 202, 176, 138, 122, 144, 153, 190, 209, 207, 191, 172, 167, 179, 204, 190, 191, 180, 193],
|
||||
[225, 225, 207, 231, 219, 197, 215, 200, 194, 199, 181, 172, 131, 129, 147, 159, 113, 175, 196, 179, 184, 169, 181, 210, 202, 204, 200, 177],
|
||||
[208, 222, 204, 223, 210, 191, 195, 198, 203, 167, 171, 168, 135, 129, 149, 175, 66, 57, 90, 121, 147, 165, 181, 205, 195, 217, 209, 173],
|
||||
[188, 216, 201, 206, 199, 180, 185, 180, 129, 75, 139, 166, 124, 146, 189, 135, 51, 41, 38, 40, 45, 63, 131, 201, 189, 215, 193, 170],
|
||||
[188, 194, 195, 192, 182, 180, 134, 68, 45, 41, 96, 130, 116, 156, 163, 64, 46, 41, 43, 41, 42, 42, 74, 181, 177, 198, 175, 193],
|
||||
[179, 179, 209, 224, 198, 182, 99, 42, 44, 41, 44, 100, 116, 125, 100, 46, 45, 42, 42, 37, 44, 43, 49, 150, 183, 170, 172, 198],
|
||||
[175, 177, 208, 223, 197, 180, 94, 40, 42, 40, 41, 99, 134, 117, 80, 43, 46, 43, 37, 37, 44, 42, 35, 129, 195, 170, 170, 180],
|
||||
[179, 181, 187, 217, 193, 175, 91, 38, 41, 41, 42, 106, 151, 107, 62, 43, 45, 41, 33, 38, 42, 34, 33, 77, 188, 175, 173, 208],
|
||||
[190, 191, 180, 213, 194, 175, 78, 38, 40, 40, 40, 98, 134, 97, 51, 44, 59, 50, 37, 40, 36, 26, 36, 44, 100, 178, 192, 206],
|
||||
[199, 191, 184, 204, 196, 176, 78, 33, 38, 38, 39, 80, 102, 83, 43, 44, 112, 130, 122, 63, 33, 24, 29, 34, 33, 74, 162, 195],
|
||||
[191, 170, 196, 193, 186, 177, 88, 27, 34, 37, 36, 74, 101, 70, 36, 37, 81, 127, 137, 113, 40, 28, 30, 32, 36, 29, 69, 173],
|
||||
[164, 189, 190, 180, 176, 172, 83, 26, 28, 33, 32, 68, 97, 62, 32, 30, 44, 97, 123, 136, 58, 42, 44, 43, 43, 40, 58, 162],
|
||||
[177, 202, 205, 181, 174, 163, 78, 38, 35, 47, 54, 67, 92, 51, 28, 29, 26, 21, 39, 85, 47, 46, 52, 47, 46, 45, 48, 141],
|
||||
[181, 193, 199, 192, 171, 163, 91, 67, 121, 123, 91, 63, 89, 45, 25, 25, 23, 20, 15, 13, 20, 48, 54, 35, 34, 34, 68, 146],
|
||||
[175, 192, 195, 179, 165, 163, 100, 64, 99, 94, 82, 58, 83, 37, 23, 22, 22, 27, 21, 15, 14, 44, 98, 83, 94, 118, 164, 157],
|
||||
[153, 184, 171, 163, 161, 157, 140, 70, 58, 89, 61, 53, 76, 30, 20, 20, 20, 31, 24, 19, 16, 47, 159, 163, 160, 171, 160, 142],
|
||||
[142, 150, 161, 168, 154, 154, 164, 138, 76, 55, 26, 37, 62, 24, 19, 19, 20, 21, 23, 27, 31, 46, 142, 156, 151, 153, 147, 145],
|
||||
[153, 147, 174, 171, 151, 150, 169, 158, 142, 92, 28, 60, 59, 20, 20, 18, 20, 26, 27, 29, 33, 38, 125, 153, 150, 147, 147, 148],
|
||||
[138, 141, 166, 164, 146, 144, 164, 149, 132, 72, 34, 88, 72, 24, 19, 18, 18, 23, 25, 28, 31, 30, 98, 150, 146, 144, 146, 144]
|
||||
]
|
||||
source_tag = 0
|
||||
xsize, ysize = len(arr[0]), len(arr)
|
||||
|
||||
|
@ -95,9 +124,8 @@ def get_frame_packet(stream_id, pixel_format="mono16"):
|
|||
if pixel_format == "mono16":
|
||||
for i in range(len(line)):
|
||||
if (i % 2) == 0:
|
||||
|
||||
if i == len(line) - 1:
|
||||
print(C(line[i]))
|
||||
# print(C(line[i]))
|
||||
packet += [
|
||||
{
|
||||
"data": C(line[i], 4 * char_width),
|
||||
|
@ -105,7 +133,7 @@ def get_frame_packet(stream_id, pixel_format="mono16"):
|
|||
},
|
||||
]
|
||||
else:
|
||||
print(C(line[i], 2 * char_width), C(line[i + 1]))
|
||||
# print(C(line[i], 2 * char_width), C(line[i + 1]))
|
||||
# CXP use MSB
|
||||
packet += [
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue