`timescale 1 ns/1 ps
package test_pkg;

 // function sin and cos, C function, imported into simulation enviroment
 // import "DPI-C" pure function real sin (input real rTheta);
 // import "DPI-C" pure function real cos (input real rTheta);

  // verbose parameter for verification: -1 -> no report
  //                                      0 -> report error in received data
  //                                      1 -> print out received & expected data
  //                                      2 -> print all debug messages
  parameter c_VERBOSE = 0;

  // use complex/real data on input/output
  localparam c_COMPLEX_EN  = 0;   // 0 - real
                                  // 1 - complex
  localparam c_DEBUG = 0;
  // design parameters
  localparam c_DATA_WIDTH  = 12;  // bit size of input/output data
  localparam c_STAGE_COUNT = 6;   // stage count = log2(c_FFT_SIZE);
  localparam c_FFT_SIZE    = 2**c_STAGE_COUNT;  // FFT input/output samples
  localparam c_TOLERANCE = 3.0/(2.0**real'(c_DATA_WIDTH-1-c_STAGE_COUNT));
  // clock period
  localparam c_CLK_PER               = 100ns;
  localparam c_DATA_EN_AFTER_CLK_PER = 10;

  // data type definition
  typedef logic [c_DATA_WIDTH-1 : 0] t_DATA;
  typedef logic [c_DATA_WIDTH-1 : 0] t_DATA_ARRAY [c_FFT_SIZE - 1 : 0];

  // complex numbers type
  typedef struct {real r,i;} t_COMPLEX;

 // 
  function real conv_bit2real(input t_DATA data_logic);
   real data_real;
  // if negative value
   if (data_logic[c_DATA_WIDTH - 1] == 1'b1)
    data_real = real'(data_logic) - real'(2**c_DATA_WIDTH);
   else
    data_real = real'(data_logic);
   conv_bit2real = data_real/(2.0**real'(c_DATA_WIDTH-1-c_STAGE_COUNT));
  endfunction : conv_bit2real


endpackage : test_pkg