data/full_repos/permissive/487568919/SystemVerilog-Bitmap-Library-AXI-Image-VIP/axi_stream_video_image_in_vip.sv
1: b"%Error: data/full_repos/permissive/487568919/SystemVerilog-Bitmap-Library-AXI-Image-VIP/axi_stream_video_image_in_vip.sv:16: syntax error, unexpected IDENTIFIER, expecting PACKAGE-IDENTIFIER or STRING\nimport bitmap_processing::*;\n       ^~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/487568919/SystemVerilog-Bitmap-Library-AXI-Image-VIP/axi_stream_video_image_in_vip.sv:87: Unsupported: new with arguments\n    frameBitmap = new();\n                  ^~~\n%Error: data/full_repos/permissive/487568919/SystemVerilog-Bitmap-Library-AXI-Image-VIP/axi_stream_video_image_in_vip.sv:95: Unsupported: fork statements\n    fork begin\n    ^~~~\n%Error: data/full_repos/permissive/487568919/SystemVerilog-Bitmap-Library-AXI-Image-VIP/axi_stream_video_image_in_vip.sv:122: syntax error, unexpected '@'\n                    @(posedge clk);\n                    ^\n%Error: Exiting due to 4 error(s)\n"
module axis_video_img_in_vip
#(

    parameter IMAGE_WIDTH = 960,
    parameter IMAGE_HEIGHT = 540,


    parameter PIXEL_PER_CLK = 1,


    parameter BITS_PER_PIXEL = 32
)
(

    ref Bitmap frameBitmap,


    ref AxisVideoImageCallback callbacks,


    input logic clk,




























    output logic [BITS_PER_PIXEL * PIXEL_PER_CLK - 1:0] m_axis_video_out_tdata,
    output logic                                        m_axis_video_out_tvalid,
    output logic                                        m_axis_video_out_tlast,
    output logic                                        m_axis_video_out_tuser,
    input  logic                                        m_axis_video_out_tready
);

logic [BITS_PER_PIXEL * PIXEL_PER_CLK - 1:0] pixel_buffer;


initial begin
    m_axis_video_out_tdata = 'h0;
    m_axis_video_out_tuser = 'b0;
    m_axis_video_out_tlast = 'b0;
    m_axis_video_out_tvalid = 'b0;
end


task ReadAndSendBitmap(input string fileName);
    frameBitmap = new();
    frameBitmap.read(fileName);

    SendBitmap();
endtask


task SendBitmap();
    fork begin
        automatic bit[31:0] color;
        
        if ((frameBitmap.width != IMAGE_WIDTH) || (frameBitmap.height != IMAGE_HEIGHT)) begin
            $display("Error: Bitmap size is not meet VIP setting");
        end
        else begin
            for (int y = 0; y < IMAGE_HEIGHT; y++) begin
                for (int x = 0; x < IMAGE_WIDTH; ) begin
                    pixel_buffer = 0;

                    if (PIXEL_PER_CLK > 1) begin
                        for (int i = 0; i < PIXEL_PER_CLK; i++) begin
                            color = frameBitmap.getPixel(x + i, y);
                            pixel_buffer = {color, pixel_buffer[BITS_PER_PIXEL * PIXEL_PER_CLK - 1 : BITS_PER_PIXEL]};
                        end
                    end
                    else begin
                        color = frameBitmap.getPixel(x, y);
                        pixel_buffer = color;
                    end

                    m_axis_video_out_tdata = pixel_buffer;
                    m_axis_video_out_tuser = (x == 0) && (y == 0);
                    m_axis_video_out_tlast = (x == IMAGE_WIDTH - PIXEL_PER_CLK);
                    m_axis_video_out_tvalid = 'b1;

                    @(posedge clk);
                    if (m_axis_video_out_tready) begin
                        x = x + PIXEL_PER_CLK;
                    end
                end
            end

            m_axis_video_out_tvalid = 'b0;

            $display("A frame of bitmap sent.");
            callbacks.SentCallback();
        end
    end
    join_none 
endtask

endmodule
module axis_video_img_in_vip
#(

    parameter IMAGE_WIDTH = 960,
    parameter IMAGE_HEIGHT = 540,


    parameter PIXEL_PER_CLK = 1,


    parameter BITS_PER_PIXEL = 32
)
(

    ref Bitmap frameBitmap,


    ref AxisVideoImageCallback callbacks,


    input logic clk,




























    output logic [BITS_PER_PIXEL * PIXEL_PER_CLK - 1:0] m_axis_video_out_tdata,
    output logic                                        m_axis_video_out_tvalid,
    output logic                                        m_axis_video_out_tlast,
    output logic                                        m_axis_video_out_tuser,
    input  logic                                        m_axis_video_out_tready
);


logic [BITS_PER_PIXEL * PIXEL_PER_CLK - 1:0] pixel_buffer;


initial begin
    m_axis_video_out_tdata = 'h0;
    m_axis_video_out_tuser = 'b0;
    m_axis_video_out_tlast = 'b0;
    m_axis_video_out_tvalid = 'b0;
end


task ReadAndSendBitmap(input string fileName);
    frameBitmap = new();
    frameBitmap.read(fileName);

    SendBitmap();
endtask


task SendBitmap();
    fork begin
        automatic bit[31:0] color;
        
        if ((frameBitmap.width != IMAGE_WIDTH) || (frameBitmap.height != IMAGE_HEIGHT)) begin
            $display("Error: Bitmap size is not meet VIP setting");
        end
        else begin
            for (int y = 0; y < IMAGE_HEIGHT; y++) begin
                for (int x = 0; x < IMAGE_WIDTH; ) begin
                    pixel_buffer = 0;

                    if (PIXEL_PER_CLK > 1) begin
                        for (int i = 0; i < PIXEL_PER_CLK; i++) begin
                            color = frameBitmap.getPixel(x + i, y);
                            pixel_buffer = {color, pixel_buffer[BITS_PER_PIXEL * PIXEL_PER_CLK - 1 : BITS_PER_PIXEL]};
                        end
                    end
                    else begin
                        color = frameBitmap.getPixel(x, y);
                        pixel_buffer = color;
                    end

                    m_axis_video_out_tdata = pixel_buffer;
                    m_axis_video_out_tuser = (x == 0) && (y == 0);
                    m_axis_video_out_tlast = (x == IMAGE_WIDTH - PIXEL_PER_CLK);
                    m_axis_video_out_tvalid = 'b1;

                    @(posedge clk);
                    if (m_axis_video_out_tready) begin
                        x = x + PIXEL_PER_CLK;
                    end
                end
            end

            m_axis_video_out_tvalid = 'b0;

            $display("A frame of bitmap sent.");
            callbacks.SentCallback();
        end
    end
    join_none 
endtask

endmodule