Problem with HLS buffered HDMI stream on PYNQ-Z2

Hi everyone,

I am trying to implement an HLS design in which two buffers are used to store a downscaled input frame. One buffer is used to store the incoming input frame and the other is used to send the output frame, and after a full frame transfer is complete, the roles of the buffers reverse.
The code is as follows:

#include <iostream>
#include <stdint.h>
#include <hls_stream.h>
#include <ap_axi_sdata.h>

typedef ap_axiu<32,1,1,1> pixel_data;
typedef hls::stream<pixel_data> pixel_stream;

#define WIDTH 1280
#define HEIGHT 720

void invstripe(pixel_stream &src, pixel_stream &dst)
#pragma HLS INTERFACE ap_ctrl_none port=return
#pragma HLS INTERFACE axis port=&src
#pragma HLS INTERFACE axis port=&dst

	//x and y are the counter for the input stream
	static uint16_t x = 0;
	static uint16_t y = 0;

	//buffers and state variable. State is the index of the buffer to which the input buffer is writtem
	static uint32_t state = 0;

	//Buffers indeces
	uint16_t buffer_x;
	uint16_t buffer_y;

	//Whether the incoming pixel should be stored
    bool to_be_written;

	pixel_data input_pixel;
	uint32_t read_data;
	pixel_data output_pixel;

	// Load pixel data from source
	src >> input_pixel;

	// Reset X and Y counters on user signal, state goes from 0 to 1 then back to 0
	if (input_pixel.user){
		x = y = 0;
		state = (state + 1) % 2;

	//Dowscaled coordinates to wrtie into the buffers
	buffer_x = x / COMPRESSION_SCALE;
	buffer_y = y / COMPRESSION_SCALE;

	//Not all incoming pixels are stored
	if ((x % COMPRESSION_SCALE == 0) && (y % COMPRESSION_SCALE == 0)) {
		to_be_written = true;
	else {
		to_be_written = false;

	//Where the storing and reading from the buffers happens
	if (state == 0 ) {
		read_data = buffer_first[buffer_x][buffer_y];
		if (to_be_written) {
			buffer_second[buffer_x][buffer_y] =;
	} else {
		read_data = buffer_second[buffer_x][buffer_y];
		if (to_be_written) {
			buffer_first[buffer_x][buffer_y] =;

    output_pixel = input_pixel; = read_data;
	dst << output_pixel;

	// Increment X and Y counters
	if (input_pixel.last)
		x = 0;
	else {


My HLS design is connected to the video pipeline as follows:

To start everything, I am using the following Jupyter script:

However, the screen shows that the top (about 30%) part of the frame is simply a repetition of the bottom part, as shown bellow. I also noticed that the top part of the frame looks more red, while the bottom part looks more green.

Any ideas as to why I can’t see the entire frame I sent on the screen? I am a bit lost

Thank you for your time

This looks like an issue with your HLS code rather than an issue with PYNQ. Did this work in debug/simulation?


Yes, the HLS code worked perfectly in simulation. That is why I am confused


I think you should not connect your IP between the hdmi_in hierarchy and the axi_vdma.

Can you try to connect your IP within the hdmi_in hierarchy between the color_conver and pixel_pack?


Thank you for your answer,
do you mean between the “axis_register_slice_0” and the “pixel_pack” modules? I just tried that and it solved some color issue but I still see that the top part of the screen is a repetition of the bottom part