forked from M-Labs/artiq-zynq
sim: fix frame metadata MSB problem
This commit is contained in:
parent
bfd901ddc4
commit
c5d16668a0
|
@ -5,6 +5,8 @@ from misoc.cores.liteeth_mini.mac.crc import LiteEthMACCRCEngine
|
||||||
|
|
||||||
from src.gateware.cxp_pipeline import *
|
from src.gateware.cxp_pipeline import *
|
||||||
|
|
||||||
|
from types import SimpleNamespace
|
||||||
|
|
||||||
class EOP_Marker(Module):
|
class EOP_Marker(Module):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.sink = stream.Endpoint(word_layout_dchar)
|
self.sink = stream.Endpoint(word_layout_dchar)
|
||||||
|
@ -276,7 +278,7 @@ class Frame_Extractor(Module):
|
||||||
self.new_line = Signal()
|
self.new_line = Signal()
|
||||||
|
|
||||||
n_metadata_chars = 23
|
n_metadata_chars = 23
|
||||||
self.metadata = Record([
|
img_header_layout = [
|
||||||
("stream_id", char_width),
|
("stream_id", char_width),
|
||||||
("source_tag", 2*char_width),
|
("source_tag", 2*char_width),
|
||||||
("x_size", 3*char_width),
|
("x_size", 3*char_width),
|
||||||
|
@ -287,8 +289,9 @@ class Frame_Extractor(Module):
|
||||||
("pixel_format", 2*char_width),
|
("pixel_format", 2*char_width),
|
||||||
("tap_geo", 2*char_width),
|
("tap_geo", 2*char_width),
|
||||||
("flag", char_width),
|
("flag", char_width),
|
||||||
])
|
]
|
||||||
assert len(self.metadata.raw_bits()) == n_metadata_chars*char_width
|
assert layout_len(img_header_layout) == n_metadata_chars*char_width
|
||||||
|
|
||||||
|
|
||||||
# # #
|
# # #
|
||||||
|
|
||||||
|
@ -332,7 +335,7 @@ class Frame_Extractor(Module):
|
||||||
type["new_frame"]: [
|
type["new_frame"]: [
|
||||||
self.new_frame.eq(1),
|
self.new_frame.eq(1),
|
||||||
NextValue(cnt, cnt.reset),
|
NextValue(cnt, cnt.reset),
|
||||||
NextState("GET_STREAM_ID"),
|
NextState("GET_FRAME_DATA"),
|
||||||
],
|
],
|
||||||
type["line_break"]: [
|
type["line_break"]: [
|
||||||
self.new_line.eq(1),
|
self.new_line.eq(1),
|
||||||
|
@ -347,11 +350,12 @@ class Frame_Extractor(Module):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
packet_buffer = Signal(layout_len(img_header_layout))
|
||||||
case = dict(
|
case = dict(
|
||||||
(i, NextValue(self.metadata.raw_bits()[8*i:8*(i+1)], self.sink.dchar))
|
(i, NextValue(packet_buffer[8*i:8*(i+1)], self.sink.dchar))
|
||||||
for i in range(n_metadata_chars)
|
for i in range(n_metadata_chars)
|
||||||
)
|
)
|
||||||
fsm.act("GET_STREAM_ID",
|
fsm.act("GET_FRAME_DATA",
|
||||||
self.sink.ack.eq(1),
|
self.sink.ack.eq(1),
|
||||||
If(self.sink.stb,
|
If(self.sink.stb,
|
||||||
Case(cnt, case),
|
Case(cnt, case),
|
||||||
|
@ -364,6 +368,13 @@ class Frame_Extractor(Module):
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# dissect packet
|
||||||
|
self.metadata = SimpleNamespace()
|
||||||
|
idx = 0
|
||||||
|
for name, size in img_header_layout:
|
||||||
|
# CXP use MSB even when sending duplicate chars
|
||||||
|
setattr(self.metadata, name, reverse_bytes(packet_buffer[idx:idx+size]))
|
||||||
|
idx += size
|
||||||
|
|
||||||
|
|
||||||
class Pixel_Decoder(Module):
|
class Pixel_Decoder(Module):
|
||||||
|
|
Loading…
Reference in New Issue