diff --git a/src/gateware/cxp_frame_pipeline.py b/src/gateware/cxp_frame_pipeline.py index 0c52ef5..33bc038 100644 --- a/src/gateware/cxp_frame_pipeline.py +++ b/src/gateware/cxp_frame_pipeline.py @@ -159,7 +159,7 @@ class CXPCRC32_Checker(Module): class Stream_Broadcaster(Module): - def __init__(self, n_buffer, default_id=0): + def __init__(self, n_buffer=1, default_id=0): assert n_buffer > 0 self.routing_ids = [Signal(char_width) for _ in range(1, n_buffer)] @@ -539,9 +539,12 @@ class Pixel_Gearbox(Module): ), ] -class Pixel_Parser(Module): - """Parses the 4x pixels and track pixel coordinates.""" +class Pixel_Coordinate_Tracker(Module): + """track pixel coordinates.""" def __init__(self, res_width): + # largest x/y pixel size supported by frame header are 24 bits + assert res_width == 3*char_width + self.y_size = Signal(3*char_width) self.sink = stream.Endpoint(pixel4x_layout) @@ -687,7 +690,7 @@ class ROI(Module): -class Frame_Deserializer(Module): +class Pixel_Parser(Module): def __init__(self, res_width): # TODO: use new_frame or remove it self.new_frame = Signal() @@ -719,9 +722,9 @@ class Frame_Deserializer(Module): "mono16": 0x0105, } - self.submodules.parser = parser = Pixel_Parser(res_width) - self.sync += parser.y_size.eq(self.y_size) - self.pixel4x = parser.pixel4x + self.submodules.tracker = tracker = Pixel_Coordinate_Tracker(res_width) + self.sync += tracker.y_size.eq(self.y_size) + self.pixel4x = tracker.pixel4x mux_cases = { "default": [ @@ -732,7 +735,7 @@ class Frame_Deserializer(Module): for fmt in pix_fmt: mux_cases[pix_fmt[fmt]] = [ eol_inserter.source.connect(gearboxes[fmt].sink), - gearboxes[fmt].source.connect(parser.sink), + gearboxes[fmt].source.connect(tracker.sink), ] self.comb += Case(self.pixel_format, mux_cases) @@ -740,7 +743,6 @@ class Frame_Deserializer(Module): class ROI_Pipeline(Module): - # largest x/y pixel size supported by frame header are 24 bits def __init__(self, res_width, count_width): # NOTE: csr need to stay outside since this module need to be cdr in the CXP_FRAME_Pipeline module @@ -750,19 +752,19 @@ class ROI_Pipeline(Module): self.submodules.buffer = buffer = Buffer(word_layout_dchar) # to improve timing from broadcaster self.submodules.crc_checker = crc_checker = CXPCRC32_Checker() self.submodules.header_decoder = header_decoder = Frame_Header_Decoder() - self.submodules.deserializer = deserializer = Frame_Deserializer(res_width) + self.submodules.parser = parser = Pixel_Parser(res_width) - self.submodules.roi = ROI(deserializer.pixel4x, count_width) + self.submodules.roi = ROI(parser.pixel4x, count_width) self.comb += [ - deserializer.new_frame.eq(header_decoder.new_frame), - deserializer.l_size.eq(header_decoder.metadata.l_size), - deserializer.x_size.eq(header_decoder.metadata.x_size), - deserializer.y_size.eq(header_decoder.metadata.y_size), - deserializer.pixel_format.eq(header_decoder.metadata.pixel_format), + parser.new_frame.eq(header_decoder.new_frame), + parser.l_size.eq(header_decoder.metadata.l_size), + parser.x_size.eq(header_decoder.metadata.x_size), + parser.y_size.eq(header_decoder.metadata.y_size), + parser.pixel_format.eq(header_decoder.metadata.pixel_format), ] - self.pipeline = [buffer, crc_checker, header_decoder, deserializer] + self.pipeline = [buffer, crc_checker, header_decoder, parser] for s, d in zip(self.pipeline, self.pipeline[1:]): self.comb += s.source.connect(d.sink) self.sink = self.pipeline[0].sink