data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v
[Errno 2] No such file or directory: 'preprocess.output'
1: b'%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:12: Cannot find include file: ../../utils/sim/sim.v\n`include "../../utils/sim/sim.v" \n         ^~~~~~~~~~~~~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/190755935/src/image/sim,data/full_repos/permissive/190755935/../../utils/sim/sim.v\n             data/full_repos/permissive/190755935/src/image/sim,data/full_repos/permissive/190755935/../../utils/sim/sim.v.v\n             data/full_repos/permissive/190755935/src/image/sim,data/full_repos/permissive/190755935/../../utils/sim/sim.v.sv\n             ../../utils/sim/sim.v\n             ../../utils/sim/sim.v.v\n             ../../utils/sim/sim.v.sv\n             obj_dir/../../utils/sim/sim.v\n             obj_dir/../../utils/sim/sim.v.v\n             obj_dir/../../utils/sim/sim.v.sv\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:14: Cannot find include file: ../../image/rtl/image_defs.v\n`include "../../image/rtl/image_defs.v" \n         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:17: Define or directive not defined: \'`IS_w\'\n        parameter [`IS_w-1:0] IS = `IS_DEFAULT\n                   ^~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:17: Define or directive not defined: \'`IS_DEFAULT\'\n        parameter [`IS_w-1:0] IS = `IS_DEFAULT\n                                   ^~~~~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:18: syntax error, unexpected \')\', expecting TYPE-IDENTIFIER\n    )(\n    ^\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:22: Define or directive not defined: \'`OutputDebug\'\n    parameter Output=`OutputDebug;\n                     ^~~~~~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:22: syntax error, unexpected \';\', expecting TYPE-IDENTIFIER\n    parameter Output=`OutputDebug;\n                                 ^\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:25: Define or directive not defined: \'`Realtime\'\n    `Realtime\n    ^~~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:28: Define or directive not defined: \'`Clock10MHz\'\n    `Clock10MHz\n    ^~~~~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:38: syntax error, unexpected \'@\'\n            @( posedge clock );\n            ^\n%Warning-STMTDLY: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:37: Unsupported: Ignoring delay on this delayed statement.\n            #2\n            ^\n                  ... Use "/* verilator lint_off STMTDLY */" and lint_on around source to disable this message.\n%Warning-STMTDLY: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:40: Unsupported: Ignoring delay on this delayed statement.\n            #2\n            ^\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:50: Define or directive not defined: \'`Info\'\n            `Info( "    Reset");\n            ^~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:50: syntax error, unexpected \';\'\n            `Info( "    Reset");\n                               ^\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:71: Define or directive not defined: \'`I_w\'\n    localparam [7:0] ImageWidth =  `I_w( IS );\n                                   ^~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:73: Define or directive not defined: \'`IS_WIDTH\'\n    localparam [7:0] Width  = `IS_WIDTH( IS );\n                              ^~~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:74: Define or directive not defined: \'`IS_HEIGHT\'\n    localparam [7:0] Height = `IS_HEIGHT( IS );\n                              ^~~~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:76: Define or directive not defined: \'`IS_PIXEL_COUNT\'\n    localparam [31:0] PixelCount = `IS_PIXEL_COUNT( IS );\n                                   ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:78: Define or directive not defined: \'`IS_WIDTH_WIDTH\'\n    localparam [7:0] WidthWidth  = `IS_WIDTH_WIDTH( IS );\n                                   ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:79: Define or directive not defined: \'`IS_HEIGHT_WIDTH\'\n    localparam [7:0] HeightWidth = `IS_HEIGHT_WIDTH( IS );\n                                   ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:80: Define or directive not defined: \'`IS_DATA_WIDTH\'\n    localparam [7:0] DataWidth   = `IS_DATA_WIDTH( IS );\n                                   ^~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:82: Define or directive not defined: \'`IS_C0_WIDTH\'\n    localparam [7:0] C0Width    = `IS_C0_WIDTH( IS );\n                                  ^~~~~~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:83: Define or directive not defined: \'`IS_C1_WIDTH\'\n    localparam [7:0] C1Width    = `IS_C1_WIDTH( IS );\n                                  ^~~~~~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:84: Define or directive not defined: \'`IS_C2_WIDTH\'\n    localparam [7:0] C2Width    = `IS_C2_WIDTH( IS );\n                                  ^~~~~~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:85: Define or directive not defined: \'`IS_ALPHA_WIDTH\'\n    localparam [7:0] AlphaWidth = `IS_ALPHA_WIDTH( IS );\n                                  ^~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:86: Define or directive not defined: \'`IS_Z_WIDTH\'\n    localparam [7:0] ZWidth     = `IS_Z_WIDTH( IS );\n                                  ^~~~~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:103: Define or directive not defined: \'`IS_w\'\n    localparam [`IS_w-1:0] IS_RGB8 = `IS( 0, 0, 32, 32, 0, 1, `IS_FORMAT_RGB, 8,  8,  8, 0, 0 );\n                ^~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:103: Define or directive not defined: \'`IS\'\n    localparam [`IS_w-1:0] IS_RGB8 = `IS( 0, 0, 32, 32, 0, 1, `IS_FORMAT_RGB, 8,  8,  8, 0, 0 );\n                                     ^~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:103: syntax error, unexpected \',\'\n    localparam [`IS_w-1:0] IS_RGB8 = `IS( 0, 0, 32, 32, 0, 1, `IS_FORMAT_RGB, 8,  8,  8, 0, 0 );\n                                           ^\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:103: Define or directive not defined: \'`IS_FORMAT_RGB\'\n    localparam [`IS_w-1:0] IS_RGB8 = `IS( 0, 0, 32, 32, 0, 1, `IS_FORMAT_RGB, 8,  8,  8, 0, 0 );\n                                                              ^~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:105: Define or directive not defined: \'`IS_DATA_WIDTH\'\n    localparam ColorDataWidth = `IS_DATA_WIDTH( IS_RGB8 );\n                                ^~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:109: syntax error, unexpected IDENTIFIER\n    image_background #(\n    ^~~~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:135: syntax error, unexpected assign\n    assign background_out_start   = `I_Start(   IS, image_background2debayer );\n    ^~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:135: Define or directive not defined: \'`I_Start\'\n    assign background_out_start   = `I_Start(   IS, image_background2debayer );\n                                    ^~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:136: Define or directive not defined: \'`I_Stop\'\n    assign background_out_stop    = `I_Stop(    IS, image_background2debayer );\n                                    ^~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:137: Define or directive not defined: \'`I_Data\'\n    assign background_out_data    = `I_Data(    IS, image_background2debayer );\n                                    ^~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:138: Define or directive not defined: \'`I_Error\'\n                                                                                 : ... Suggested alternative: \'`error\'\n    assign background_out_error   = `I_Error(   IS, image_background2debayer );\n                                    ^~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:139: Define or directive not defined: \'`I_Valid\'\n    assign background_out_valid   = `I_Valid(   IS, image_background2debayer );\n                                    ^~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:140: Define or directive not defined: \'`I_Request\'\n    assign background_out_request = `I_Request( IS, image_background2debayer );\n                                    ^~~~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:141: Define or directive not defined: \'`I_Cancel\'\n    assign background_out_cancel  = `I_Cancel(  IS, image_background2debayer );\n                                    ^~~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:142: Define or directive not defined: \'`I_Ready\'\n    assign background_out_ready   = `I_Ready(   IS, image_background2debayer );\n                                    ^~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:148: Define or directive not defined: \'`IS_w\'\n    localparam [`IS_w-1:0] IS_DB = `IS( 0, 0, Width, Height, 0, 1, `IS_FORMAT_RGB, 5, 6, 5, 0, 0 );\n                ^~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:148: Define or directive not defined: \'`IS\'\n    localparam [`IS_w-1:0] IS_DB = `IS( 0, 0, Width, Height, 0, 1, `IS_FORMAT_RGB, 5, 6, 5, 0, 0 );\n                                   ^~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:148: syntax error, unexpected \',\'\n    localparam [`IS_w-1:0] IS_DB = `IS( 0, 0, Width, Height, 0, 1, `IS_FORMAT_RGB, 5, 6, 5, 0, 0 );\n                                         ^\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:148: Define or directive not defined: \'`IS_FORMAT_RGB\'\n    localparam [`IS_w-1:0] IS_DB = `IS( 0, 0, Width, Height, 0, 1, `IS_FORMAT_RGB, 5, 6, 5, 0, 0 );\n                                                                   ^~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:150: Define or directive not defined: \'`I_w\'\n    localparam DBImageWidth     = `I_w( IS_DB );\n                                  ^~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:151: Define or directive not defined: \'`IS_DATA_WIDTH\'\n    localparam DBImageDataWidth = `IS_DATA_WIDTH( IS_DB );\n                                  ^~~~~~~~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:165: syntax error, unexpected assign\n    assign debayer_out_start = `I_Start( IS_DB, debayer_image_out );\n    ^~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:165: Define or directive not defined: \'`I_Start\'\n    assign debayer_out_start = `I_Start( IS_DB, debayer_image_out );\n                               ^~~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:166: Define or directive not defined: \'`I_Stop\'\n    assign debayer_out_stop = `I_Stop( IS_DB, debayer_image_out );\n                              ^~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:167: Define or directive not defined: \'`I_Data\'\n    assign debayer_out_data = `I_Data( IS_DB, debayer_image_out );\n                              ^~~~~~~\n%Error: data/full_repos/permissive/190755935/src/image/sim/image_debayer_tb.v:168: Define or directive not defined: \'`I_Error\'\n                                                                                 : ... Suggested alternative: \'`error\'\n    assign debayer_out_error = `I_Error( IS_DB, debayer_image_out );\n                               ^~~~~~~~\n%Error: Exiting due to too many errors encountered; --error-limit=50\n'
module image_debayer_tb();

    parameter Output=`OutputDebug;



    initial begin
      $dumpfile("image_debayer_tb.vcd");
      $dumpvars( 1, image_debayer_tb );
      $dumpvars( 1, image_debayer_tb.idebayer );
    end

    `AssertSetup






    `Realtime


    `Clock10MHz

    task i_init;
        begin
        end
    endtask

    task  i_clock;
        begin
            #2
            @( posedge clock );

            #2
            ;
        end
    endtask

    reg  reset;

    task  i_reset;
        begin
            reset = 1;
            i_clock;
            `Info( "    Reset");
            reset = 0;
            i_clock;
        end
    endtask





    localparam [`IS_w-1:0] IS_IN = `IS( 0, 0, 8, 8, 0, 1, `IS_FORMAT_BAYER, 10, 0, 0, 0, 0 );

    localparam InImageDataWidth =  `I_w( IS_IN );

    localparam InWidth       = `IS_WIDTH( IS_IN );
    localparam InHeight      = `IS_HEIGHT( IS_IN );

    localparam InPixelCount  = `IS_PIXEL_COUNT( IS_IN );

    localparam InWidthWidth  = `IS_WIDTH_WIDTH( IS_IN );
    localparam InHeightWidth = `IS_HEIGHT_WIDTH( IS_IN );
    localparam InDataWidth   = `IS_DATA_WIDTH( IS_IN );

    localparam InC0Width =     `IS_C0_WIDTH( IS_IN );
    localparam InC1Width =     `IS_C1_WIDTH( IS_IN );
    localparam InC2Width =     `IS_C2_WIDTH( IS_IN );
    localparam InAlphaWidth =  `IS_ALPHA_WIDTH( IS_IN );
    localparam InZWidth =      `IS_Z_WIDTH( IS_IN );

    localparam [`IS_w-1:0] IS_OUT = `IS( 0, 0, 8, 8, 0, 1, `IS_FORMAT_RGB, 8, 8, 8, 0, 0 );

    localparam OutImageDataWidth =  `I_w( IS_OUT );

    localparam OutWidth       = `IS_WIDTH( IS_OUT );
    localparam OutHeight      = `IS_HEIGHT( IS_OUT );

    localparam OutPixelCount  = `IS_PIXEL_COUNT( IS_OUT );

    localparam OutWidthWidth  = `IS_WIDTH_WIDTH( IS_OUT );
    localparam OutHeightWidth = `IS_HEIGHT_WIDTH( IS_OUT );
    localparam OutDataWidth   = `IS_DATA_WIDTH( IS_OUT );

    localparam OutC0Width =     `IS_C0_WIDTH( IS_OUT );
    localparam OutC1Width =     `IS_C1_WIDTH( IS_OUT );
    localparam OutC2Width =     `IS_C2_WIDTH( IS_OUT );
    localparam OutAlphaWidth =  `IS_ALPHA_WIDTH( IS_OUT );
    localparam OutZWidth =      `IS_Z_WIDTH( IS_OUT );

    wire [InImageDataWidth-1:0] image_in;

    reg                    in_start;
    reg                    in_stop;
    reg  [InDataWidth-1:0] in_data;
    reg                    in_valid;
    reg                    in_error;
    wire                   in_ready;
    wire                   in_request;
    wire                   in_cancel;

    assign `I_Start( IS_IN, image_in ) = in_start;
    assign `I_Stop(  IS_IN, image_in ) = in_stop;
    assign `I_Data(  IS_IN, image_in ) = in_data;
    assign `I_Error( IS_IN, image_in ) = in_error;
    assign `I_Valid( IS_IN, image_in ) = in_valid;
    assign in_request = `I_Request( IS_IN, image_in );
    assign in_cancel  = `I_Cancel(  IS_IN, image_in );
    assign in_ready   = `I_Ready(   IS_IN, image_in );

    wire [OutImageDataWidth-1:0] image_out;

    wire                    out_start;
    wire                    out_stop;
    wire [OutDataWidth-1:0] out_data;
    wire                    out_valid;
    wire                    out_error;
    reg                     out_ready;
    reg                     out_request;
    reg                     out_cancel;

    assign out_start   = `I_Start(   IS_OUT, image_out );
    assign out_stop    = `I_Stop(    IS_OUT, image_out );
    assign out_data    = `I_Data(    IS_OUT, image_out );
    assign out_error   = `I_Error(   IS_OUT, image_out );
    assign out_valid   = `I_Valid(   IS_OUT, image_out );
    assign `I_Request( IS_OUT, image_out ) = out_request;
    assign `I_Cancel(  IS_OUT, image_out ) = out_cancel;
    assign `I_Ready(   IS_OUT, image_out ) = out_ready;





    image_debayer #(
            .InIS( IS_IN ),
            .OutIS( IS_OUT )
    ) idebayer (
            .clock( clock ),
            .reset( reset ),

            .image_in( image_in ),
            .image_out( image_out )
        );

    task test_init;
        begin
            in_start = 0;
            in_stop = 0;
            in_data = 0;
            in_valid = 0;
            in_error = 0;
            out_ready = 1;
            out_request = 0;
            out_cancel = 0;
        end
    endtask

    task test_idle;
        begin
            `Info( "        Checking Idle" );
            `Assert( !in_request, "Idle - no request" );
            `Assert( !in_cancel, "Idle - no cancel" );
            `Assert( !out_start, "Idle - no start" );
            `Assert( !out_stop, "Idle - no stop" );
            `Assert( !out_valid, "Idle - no valid" );
        end
    endtask

    task test_control;
        begin
            `Info( "        Checking Control" );

            i_clock;

            `Assert( !in_request, "Pre Control - No Request" );
            `Assert( !in_cancel,  "Pre Control - No Cancel" );

            i_clock;

            out_request = 1;

            i_clock;

            `Assert( in_request, "Control - Request" );
            `Assert( !in_cancel, "Control - No Cancel" );

            out_request = 0;

            i_clock;

            `Assert( !in_request, "Control - No Request" );
            `Assert( !in_cancel,  "Control - No Cancel" );

            i_clock;

            out_cancel = 1;

            i_clock;

            `Assert( !in_request, "Control - No Request" );
            `Assert( in_cancel,   "Control - Cancel" );

            out_cancel = 0;

            i_clock;

            `Assert( !in_request, "Control - No Request" );
            `Assert( !in_cancel,  "Control - No Cancel" );
        end
    endtask

    integer count;
    integer count_limit;
    integer out_i;
    integer data_check;

    task test_non_start_blocking;
        begin
            `Info( "        Testing Non Start Blocking" );

            count = 0;
            while ( count < 10 ) begin

                in_data = 1;
                in_valid = 1;

                `Assert( !out_valid, "No characters without a start" );
                count = count + 1;

                i_clock;
            end

            in_data = 0;
            in_valid = 0;

            i_clock;

        end
    endtask


    task test_throughput( input reg in_pauses, input reg out_pauses );
        begin
            `InfoDo $display( "        Checking Throughput (In Pauses %d Out Pauses %d)", in_pauses, out_pauses );

            i_clock;

            `Assert( !out_start,  "Control - No Start" );
            `Assert( !out_stop,   "Control - No Stop" );
            `Assert( !out_data,   "Control - No Data" );
            `Assert( !out_valid,  "Control - No Valid" );

            out_ready = 1;

            count = 0;
            while( count < InPixelCount ) begin

                `InfoDo $display( "            C%-0d", count );

                if ( in_pauses && ( count % 10 == 0 ) ) begin

                    in_valid = 0;
                    i_clock;
                    `Assert( ( !count || !out_valid ),  "In Pause - No Out Valid" );
                    i_clock;
                    `Assert( ( !count || !out_valid ),  "In Pause - No Out Valid" );
                    i_clock;
                    `Assert( ( !count || !out_valid ),  "In Pause - No Out Valid" );
                    i_clock;

                end

                in_start = ( count == 0 );
                in_stop = ( count == ( InPixelCount - 1 ) );
                in_data = count;
                in_valid = 1;

                while ( !in_ready )
                    i_clock;

                if ( out_pauses && ( count > 0 ) && ( count % 5 == 0 ) ) begin

                    out_ready = 0;
                    i_clock;
                    in_valid = 0;

                    `Assert( out_valid,  "Out Pause - Out Valid" );
                    i_clock;
                    `Assert( !in_ready,  "Out Pause - No In Ready" );
                    `Assert( out_valid,  "Out Pause - Out Valid" );
                    i_clock;
                    `Assert( !in_ready,  "Out Pause - No In Ready" );
                    `Assert( out_valid,  "Out Pause - Out Valid" );
                    i_clock;
                    out_ready = 1;
                    i_clock;
                    in_valid = 0;

                end else begin

                    i_clock;

                    `Assert( out_valid,  "Control - Valid" );

                end

                `AssertEqual( in_start, out_start,  "Control - Start" );
                `AssertEqual( in_stop,  out_stop,   "Control - Stop" );

                count = count + 1;

            end

            in_start = 0;
            in_stop = 0;
            in_valid = 0;

            i_clock;

            `Assert( !out_start,  "Control - No Start" );
            `Assert( !out_stop,   "Control - No Stop" );
            `Assert( !out_data,   "Control - No Data" );
            `Assert( !out_valid,  "Control - No Valid" );

        end
    endtask

    integer count_in;
    integer count_out;
    integer total_transfer;
    reg in_ready_latched;

    task test_throughput_interleaved( input reg in_pauses, input reg out_pauses );
        begin
            `InfoDo $display( "        Checking Interleaved Throughput (In Pauses %d Out Pauses %d)", in_pauses, out_pauses );

            i_clock;

            `Assert( !out_start,  "Control - No Start" );
            `Assert( !out_stop,   "Control - No Stop" );
            `Assert( !out_data,   "Control - No Data" );
            `Assert( !out_valid,  "Control - No Valid" );

            total_transfer = 10;

            count_in = 0;
            count_out = 0;

            count = 0;
            count_limit = 100;

            out_ready = 0;
            in_valid = 0;

            while ( ( count < count_limit ) && ( ( count_in < total_transfer ) || ( count_out < total_transfer ) ) ) begin

                in_ready_latched = in_ready;

                i_clock;

                if ( ( in_valid == 0 ) && ( count_in < total_transfer ) && ( ( count % 2 ) == 0 ) ) begin
                    in_valid = 1;
                    in_data = count_in;
                    in_start = ( count_in == 0 );
                    in_stop = ( count_in == total_transfer - 1 );
                end

                if (  in_ready_latched && in_valid ) begin
                    in_valid = 0;
                    in_data = 0;
                    in_start = 0;
                    in_stop = 0;
                    `InfoDo $display( "                C In %-0d", count_in );
                    count_in = count_in + 1;
                end

                if ( out_valid )
                    out_ready = ( ( count % 4 ) == 0 );

                if ( out_ready && out_valid ) begin
                    count_out = count_out + 1;
                    `InfoDo $display( "                            C Out C %-0d (%-0d)", out_data, count_out );
                end


                count = count + 1;

            end

            in_valid = 0;

            i_clock;
            i_clock;
            i_clock;

            `AssertEqual( count_in, total_transfer, "In" );
            `AssertEqual( count_out, total_transfer, "Out" );

            `Assert( !out_start,  "Control - No Start" );
            `Assert( !out_stop,   "Control - No Stop" );
            `Assert( !out_data,   "Control - No Data" );
            `Assert( !out_valid,  "Control - No Valid" );

        end
    endtask







    localparam [`IS_w-1:0] IS_BAYER_LG = `IS( 0, 0, 48, 48, 0, 1, `IS_FORMAT_BAYER, 10, 0, 0, 0, 0 );
    localparam [`IS_w-1:0] IS_BAYER_SM = `IS( 0, 0, 8, 8, 0, 1, `IS_FORMAT_BAYER, 10, 0, 0, 0, 0 );
    localparam [`IS_w-1:0] IS_RGB8     = `IS( 0, 0, 32, 32, 0, 1, `IS_FORMAT_RGB,    8, 8, 8, 0, 0 );

    image_debayer_instance #( .IS(IS_BAYER_SM) ) ib_bayer_sm( 2'H0 );
    image_debayer_instance #( .IS(IS_BAYER_LG) ) ib_bayer_lg( 2'H1 );

    initial begin
        $display( "Image Debayer Tests %s", `__FILE__ );

        `Info( "    Data Check" );

        `Info( "    Data In Spec" );
        `InfoDo $display( "        IS_IN                %x",  IS_IN );
        `InfoDo $display( "            IS_IN.X          %d", `IS_X( IS_IN ) );
        `InfoDo $display( "            IS_IN.Y          %d", `IS_Y( IS_IN ) );
        `InfoDo $display( "            IS_IN.Width      %d", `IS_WIDTH( IS_IN ) );
        `InfoDo $display( "            IS_IN.Height     %d", `IS_HEIGHT( IS_IN ) );
        `InfoDo $display( "            IS_IN.C0Width    %d", `IS_C0_WIDTH( IS_IN ) );
        `InfoDo $display( "            IS_IN.C1Width    %d", `IS_C1_WIDTH( IS_IN ) );
        `InfoDo $display( "            IS_IN.C2Width    %d", `IS_C2_WIDTH( IS_IN ) );
        `InfoDo $display( "            IS_IN.AlphaWidth %d", `IS_ALPHA_WIDTH( IS_IN ) );
        `InfoDo $display( "            IS_IN.ZWidth     %d", `IS_Z_WIDTH( IS_IN ) );
        `InfoDo $display( "            IS_IN.DataWidth  %d", `IS_DATA_WIDTH( IS_IN ) );
        `InfoDo $display( "            IS_IN.PixelCount %d", `IS_PIXEL_COUNT( IS_IN ) );

        `Info( "    Data Out Spec" );
        `InfoDo $display( "        IS_OUT                %x",  IS_OUT );
        `InfoDo $display( "            IS_OUT.X          %d", `IS_X( IS_OUT ) );
        `InfoDo $display( "            IS_OUT.Y          %d", `IS_Y( IS_OUT ) );
        `InfoDo $display( "            IS_OUT.Width      %d", `IS_WIDTH( IS_OUT ) );
        `InfoDo $display( "            IS_OUT.Height     %d", `IS_HEIGHT( IS_OUT ) );
        `InfoDo $display( "            IS_OUT.C0Width    %d", `IS_C0_WIDTH( IS_OUT ) );
        `InfoDo $display( "            IS_OUT.C1Width    %d", `IS_C1_WIDTH( IS_OUT ) );
        `InfoDo $display( "            IS_OUT.C2Width    %d", `IS_C2_WIDTH( IS_OUT ) );
        `InfoDo $display( "            IS_OUT.AlphaWidth %d", `IS_ALPHA_WIDTH( IS_OUT ) );
        `InfoDo $display( "            IS_OUT.ZWidth     %d", `IS_Z_WIDTH( IS_OUT ) );
        `InfoDo $display( "            IS_OUT.DataWidth  %d", `IS_DATA_WIDTH( IS_OUT ) );
        `InfoDo $display( "            IS_OUT.PixelCount %d", `IS_PIXEL_COUNT( IS_OUT ) );

        i_clock;
        i_reset;
        i_clock;

        test_init;
        test_idle;

        i_clock;
        i_clock;
        i_clock;
        i_clock;

        test_throughput_interleaved( 0, 0 );

        i_clock;
        i_clock;
        i_clock;
        i_clock;

        `AssertSummary

        $finish;
    end

endmodule
module image_debayer_tb();


    parameter Output=`OutputDebug;



    initial begin
      $dumpfile("image_debayer_tb.vcd");
      $dumpvars( 1, image_debayer_tb );
      $dumpvars( 1, image_debayer_tb.idebayer );
    end

    `AssertSetup






    `Realtime


    `Clock10MHz

    task i_init;
        begin
        end
    endtask

    task  i_clock;
        begin
            #2
            @( posedge clock );

            #2
            ;
        end
    endtask

    reg  reset;

    task  i_reset;
        begin
            reset = 1;
            i_clock;
            `Info( "    Reset");
            reset = 0;
            i_clock;
        end
    endtask





    localparam [`IS_w-1:0] IS_IN = `IS( 0, 0, 8, 8, 0, 1, `IS_FORMAT_BAYER, 10, 0, 0, 0, 0 );

    localparam InImageDataWidth =  `I_w( IS_IN );

    localparam InWidth       = `IS_WIDTH( IS_IN );
    localparam InHeight      = `IS_HEIGHT( IS_IN );

    localparam InPixelCount  = `IS_PIXEL_COUNT( IS_IN );

    localparam InWidthWidth  = `IS_WIDTH_WIDTH( IS_IN );
    localparam InHeightWidth = `IS_HEIGHT_WIDTH( IS_IN );
    localparam InDataWidth   = `IS_DATA_WIDTH( IS_IN );

    localparam InC0Width =     `IS_C0_WIDTH( IS_IN );
    localparam InC1Width =     `IS_C1_WIDTH( IS_IN );
    localparam InC2Width =     `IS_C2_WIDTH( IS_IN );
    localparam InAlphaWidth =  `IS_ALPHA_WIDTH( IS_IN );
    localparam InZWidth =      `IS_Z_WIDTH( IS_IN );

    localparam [`IS_w-1:0] IS_OUT = `IS( 0, 0, 8, 8, 0, 1, `IS_FORMAT_RGB, 8, 8, 8, 0, 0 );

    localparam OutImageDataWidth =  `I_w( IS_OUT );

    localparam OutWidth       = `IS_WIDTH( IS_OUT );
    localparam OutHeight      = `IS_HEIGHT( IS_OUT );

    localparam OutPixelCount  = `IS_PIXEL_COUNT( IS_OUT );

    localparam OutWidthWidth  = `IS_WIDTH_WIDTH( IS_OUT );
    localparam OutHeightWidth = `IS_HEIGHT_WIDTH( IS_OUT );
    localparam OutDataWidth   = `IS_DATA_WIDTH( IS_OUT );

    localparam OutC0Width =     `IS_C0_WIDTH( IS_OUT );
    localparam OutC1Width =     `IS_C1_WIDTH( IS_OUT );
    localparam OutC2Width =     `IS_C2_WIDTH( IS_OUT );
    localparam OutAlphaWidth =  `IS_ALPHA_WIDTH( IS_OUT );
    localparam OutZWidth =      `IS_Z_WIDTH( IS_OUT );

    wire [InImageDataWidth-1:0] image_in;

    reg                    in_start;
    reg                    in_stop;
    reg  [InDataWidth-1:0] in_data;
    reg                    in_valid;
    reg                    in_error;
    wire                   in_ready;
    wire                   in_request;
    wire                   in_cancel;

    assign `I_Start( IS_IN, image_in ) = in_start;
    assign `I_Stop(  IS_IN, image_in ) = in_stop;
    assign `I_Data(  IS_IN, image_in ) = in_data;
    assign `I_Error( IS_IN, image_in ) = in_error;
    assign `I_Valid( IS_IN, image_in ) = in_valid;
    assign in_request = `I_Request( IS_IN, image_in );
    assign in_cancel  = `I_Cancel(  IS_IN, image_in );
    assign in_ready   = `I_Ready(   IS_IN, image_in );

    wire [OutImageDataWidth-1:0] image_out;

    wire                    out_start;
    wire                    out_stop;
    wire [OutDataWidth-1:0] out_data;
    wire                    out_valid;
    wire                    out_error;
    reg                     out_ready;
    reg                     out_request;
    reg                     out_cancel;

    assign out_start   = `I_Start(   IS_OUT, image_out );
    assign out_stop    = `I_Stop(    IS_OUT, image_out );
    assign out_data    = `I_Data(    IS_OUT, image_out );
    assign out_error   = `I_Error(   IS_OUT, image_out );
    assign out_valid   = `I_Valid(   IS_OUT, image_out );
    assign `I_Request( IS_OUT, image_out ) = out_request;
    assign `I_Cancel(  IS_OUT, image_out ) = out_cancel;
    assign `I_Ready(   IS_OUT, image_out ) = out_ready;





    image_debayer #(
            .InIS( IS_IN ),
            .OutIS( IS_OUT )
    ) idebayer (
            .clock( clock ),
            .reset( reset ),

            .image_in( image_in ),
            .image_out( image_out )
        );

    task test_init;
        begin
            in_start = 0;
            in_stop = 0;
            in_data = 0;
            in_valid = 0;
            in_error = 0;
            out_ready = 1;
            out_request = 0;
            out_cancel = 0;
        end
    endtask

    task test_idle;
        begin
            `Info( "        Checking Idle" );
            `Assert( !in_request, "Idle - no request" );
            `Assert( !in_cancel, "Idle - no cancel" );
            `Assert( !out_start, "Idle - no start" );
            `Assert( !out_stop, "Idle - no stop" );
            `Assert( !out_valid, "Idle - no valid" );
        end
    endtask

    task test_control;
        begin
            `Info( "        Checking Control" );

            i_clock;

            `Assert( !in_request, "Pre Control - No Request" );
            `Assert( !in_cancel,  "Pre Control - No Cancel" );

            i_clock;

            out_request = 1;

            i_clock;

            `Assert( in_request, "Control - Request" );
            `Assert( !in_cancel, "Control - No Cancel" );

            out_request = 0;

            i_clock;

            `Assert( !in_request, "Control - No Request" );
            `Assert( !in_cancel,  "Control - No Cancel" );

            i_clock;

            out_cancel = 1;

            i_clock;

            `Assert( !in_request, "Control - No Request" );
            `Assert( in_cancel,   "Control - Cancel" );

            out_cancel = 0;

            i_clock;

            `Assert( !in_request, "Control - No Request" );
            `Assert( !in_cancel,  "Control - No Cancel" );
        end
    endtask

    integer count;
    integer count_limit;
    integer out_i;
    integer data_check;

    task test_non_start_blocking;
        begin
            `Info( "        Testing Non Start Blocking" );

            count = 0;
            while ( count < 10 ) begin

                in_data = 1;
                in_valid = 1;

                `Assert( !out_valid, "No characters without a start" );
                count = count + 1;

                i_clock;
            end

            in_data = 0;
            in_valid = 0;

            i_clock;

        end
    endtask


    task test_throughput( input reg in_pauses, input reg out_pauses );
        begin
            `InfoDo $display( "        Checking Throughput (In Pauses %d Out Pauses %d)", in_pauses, out_pauses );

            i_clock;

            `Assert( !out_start,  "Control - No Start" );
            `Assert( !out_stop,   "Control - No Stop" );
            `Assert( !out_data,   "Control - No Data" );
            `Assert( !out_valid,  "Control - No Valid" );

            out_ready = 1;

            count = 0;
            while( count < InPixelCount ) begin

                `InfoDo $display( "            C%-0d", count );

                if ( in_pauses && ( count % 10 == 0 ) ) begin

                    in_valid = 0;
                    i_clock;
                    `Assert( ( !count || !out_valid ),  "In Pause - No Out Valid" );
                    i_clock;
                    `Assert( ( !count || !out_valid ),  "In Pause - No Out Valid" );
                    i_clock;
                    `Assert( ( !count || !out_valid ),  "In Pause - No Out Valid" );
                    i_clock;

                end

                in_start = ( count == 0 );
                in_stop = ( count == ( InPixelCount - 1 ) );
                in_data = count;
                in_valid = 1;

                while ( !in_ready )
                    i_clock;

                if ( out_pauses && ( count > 0 ) && ( count % 5 == 0 ) ) begin

                    out_ready = 0;
                    i_clock;
                    in_valid = 0;

                    `Assert( out_valid,  "Out Pause - Out Valid" );
                    i_clock;
                    `Assert( !in_ready,  "Out Pause - No In Ready" );
                    `Assert( out_valid,  "Out Pause - Out Valid" );
                    i_clock;
                    `Assert( !in_ready,  "Out Pause - No In Ready" );
                    `Assert( out_valid,  "Out Pause - Out Valid" );
                    i_clock;
                    out_ready = 1;
                    i_clock;
                    in_valid = 0;

                end else begin

                    i_clock;

                    `Assert( out_valid,  "Control - Valid" );

                end

                `AssertEqual( in_start, out_start,  "Control - Start" );
                `AssertEqual( in_stop,  out_stop,   "Control - Stop" );

                count = count + 1;

            end

            in_start = 0;
            in_stop = 0;
            in_valid = 0;

            i_clock;

            `Assert( !out_start,  "Control - No Start" );
            `Assert( !out_stop,   "Control - No Stop" );
            `Assert( !out_data,   "Control - No Data" );
            `Assert( !out_valid,  "Control - No Valid" );

        end
    endtask

    integer count_in;
    integer count_out;
    integer total_transfer;
    reg in_ready_latched;

    task test_throughput_interleaved( input reg in_pauses, input reg out_pauses );
        begin
            `InfoDo $display( "        Checking Interleaved Throughput (In Pauses %d Out Pauses %d)", in_pauses, out_pauses );

            i_clock;

            `Assert( !out_start,  "Control - No Start" );
            `Assert( !out_stop,   "Control - No Stop" );
            `Assert( !out_data,   "Control - No Data" );
            `Assert( !out_valid,  "Control - No Valid" );

            total_transfer = 10;

            count_in = 0;
            count_out = 0;

            count = 0;
            count_limit = 100;

            out_ready = 0;
            in_valid = 0;

            while ( ( count < count_limit ) && ( ( count_in < total_transfer ) || ( count_out < total_transfer ) ) ) begin

                in_ready_latched = in_ready;

                i_clock;

                if ( ( in_valid == 0 ) && ( count_in < total_transfer ) && ( ( count % 2 ) == 0 ) ) begin
                    in_valid = 1;
                    in_data = count_in;
                    in_start = ( count_in == 0 );
                    in_stop = ( count_in == total_transfer - 1 );
                end

                if (  in_ready_latched && in_valid ) begin
                    in_valid = 0;
                    in_data = 0;
                    in_start = 0;
                    in_stop = 0;
                    `InfoDo $display( "                C In %-0d", count_in );
                    count_in = count_in + 1;
                end

                if ( out_valid )
                    out_ready = ( ( count % 4 ) == 0 );

                if ( out_ready && out_valid ) begin
                    count_out = count_out + 1;
                    `InfoDo $display( "                            C Out C %-0d (%-0d)", out_data, count_out );
                end


                count = count + 1;

            end

            in_valid = 0;

            i_clock;
            i_clock;
            i_clock;

            `AssertEqual( count_in, total_transfer, "In" );
            `AssertEqual( count_out, total_transfer, "Out" );

            `Assert( !out_start,  "Control - No Start" );
            `Assert( !out_stop,   "Control - No Stop" );
            `Assert( !out_data,   "Control - No Data" );
            `Assert( !out_valid,  "Control - No Valid" );

        end
    endtask







    localparam [`IS_w-1:0] IS_BAYER_LG = `IS( 0, 0, 48, 48, 0, 1, `IS_FORMAT_BAYER, 10, 0, 0, 0, 0 );
    localparam [`IS_w-1:0] IS_BAYER_SM = `IS( 0, 0, 8, 8, 0, 1, `IS_FORMAT_BAYER, 10, 0, 0, 0, 0 );
    localparam [`IS_w-1:0] IS_RGB8     = `IS( 0, 0, 32, 32, 0, 1, `IS_FORMAT_RGB,    8, 8, 8, 0, 0 );

    image_debayer_instance #( .IS(IS_BAYER_SM) ) ib_bayer_sm( 2'H0 );
    image_debayer_instance #( .IS(IS_BAYER_LG) ) ib_bayer_lg( 2'H1 );

    initial begin
        $display( "Image Debayer Tests %s", `__FILE__ );

        `Info( "    Data Check" );

        `Info( "    Data In Spec" );
        `InfoDo $display( "        IS_IN                %x",  IS_IN );
        `InfoDo $display( "            IS_IN.X          %d", `IS_X( IS_IN ) );
        `InfoDo $display( "            IS_IN.Y          %d", `IS_Y( IS_IN ) );
        `InfoDo $display( "            IS_IN.Width      %d", `IS_WIDTH( IS_IN ) );
        `InfoDo $display( "            IS_IN.Height     %d", `IS_HEIGHT( IS_IN ) );
        `InfoDo $display( "            IS_IN.C0Width    %d", `IS_C0_WIDTH( IS_IN ) );
        `InfoDo $display( "            IS_IN.C1Width    %d", `IS_C1_WIDTH( IS_IN ) );
        `InfoDo $display( "            IS_IN.C2Width    %d", `IS_C2_WIDTH( IS_IN ) );
        `InfoDo $display( "            IS_IN.AlphaWidth %d", `IS_ALPHA_WIDTH( IS_IN ) );
        `InfoDo $display( "            IS_IN.ZWidth     %d", `IS_Z_WIDTH( IS_IN ) );
        `InfoDo $display( "            IS_IN.DataWidth  %d", `IS_DATA_WIDTH( IS_IN ) );
        `InfoDo $display( "            IS_IN.PixelCount %d", `IS_PIXEL_COUNT( IS_IN ) );

        `Info( "    Data Out Spec" );
        `InfoDo $display( "        IS_OUT                %x",  IS_OUT );
        `InfoDo $display( "            IS_OUT.X          %d", `IS_X( IS_OUT ) );
        `InfoDo $display( "            IS_OUT.Y          %d", `IS_Y( IS_OUT ) );
        `InfoDo $display( "            IS_OUT.Width      %d", `IS_WIDTH( IS_OUT ) );
        `InfoDo $display( "            IS_OUT.Height     %d", `IS_HEIGHT( IS_OUT ) );
        `InfoDo $display( "            IS_OUT.C0Width    %d", `IS_C0_WIDTH( IS_OUT ) );
        `InfoDo $display( "            IS_OUT.C1Width    %d", `IS_C1_WIDTH( IS_OUT ) );
        `InfoDo $display( "            IS_OUT.C2Width    %d", `IS_C2_WIDTH( IS_OUT ) );
        `InfoDo $display( "            IS_OUT.AlphaWidth %d", `IS_ALPHA_WIDTH( IS_OUT ) );
        `InfoDo $display( "            IS_OUT.ZWidth     %d", `IS_Z_WIDTH( IS_OUT ) );
        `InfoDo $display( "            IS_OUT.DataWidth  %d", `IS_DATA_WIDTH( IS_OUT ) );
        `InfoDo $display( "            IS_OUT.PixelCount %d", `IS_PIXEL_COUNT( IS_OUT ) );

        i_clock;
        i_reset;
        i_clock;

        test_init;
        test_idle;

        i_clock;
        i_clock;
        i_clock;
        i_clock;

        test_throughput_interleaved( 0, 0 );

        i_clock;
        i_clock;
        i_clock;
        i_clock;

        `AssertSummary

        $finish;
    end

endmodule