/*******************************************************************************
Copyright(c) 2000 - 2006 Analog Devices. All Rights Reserved.

By using this module you agree to the terms of the Analog Devices License
Agreement for DSP Software. 

********************************************************************************
File Name       : Test_conv2d3x3_spl.c
Description     : This function tests _conv2d3x3_spl with input size of 16x 16 
                  and finds cycle count for the same.
                1. Test1 - Random test with output not overflowing i/p = 16 x 16
*******************************************************************************/
#include <conv2d3x3_spl.h>
#include <stdio.h>

#include "SDK-cycle_count.h"

extern void _conv2d3x3_spl(fract16 in[], short row, short col, fract16 mask[], 
                           fract16 out[]);

int error_flag = 0;
void (*f1)();
int cycle_count[10];

void main (void)
{
    int row, col, error;
    volatile int i;

    f1 = (void(*)()) _conv2d3x3_spl;    // Function Pointer

// *************************************************************
// Test1 - Random test with output not overflowing i/p = 16 x 16
// *************************************************************
    row = 16, col = 16; 
        
    for(i=0; i<row*col; i++)    in[i] = in_16[i];
    for(i=0; i<9; i++)          mask[i] = mask_16[i];
    for(i=0; i<row*col; i++)    out[i] = 1000;

    cycle_count[0] = Compute_Cycle_Count((unsigned char *)in, row, col, (int *)mask, (unsigned char *)out, 0);


    for(i=0; i<row*col; i++)
    {
        error = out[i] - out_16[i];
        if (abs(error) > MAX_PERMISSIBLE_ERROR)
        {    
            error_flag = error_flag | 1;
        }
    }
    #ifdef PRINTF_SUPPORT
        if(error_flag & 1)
            printf("Test Case 1 failed\n");
        else
            printf("Test Case 1 passed\n");
    #endif
    
    printf("cycle_count[0]=%d\n",cycle_count[0]);
    
}

