/* Compute DCT for data_input
 * @param data_input : input data to compute DCT on
 * @param data_input_size: specifies the size of data_input
 * @param data_output : result after computing DCT on data_input
 */
void compute_dct(const svOpenArrayHandle data_input, int data_input_size,
		double data_output[AMIQ_DSP_ALGORITHMS_NOF_POINTS]) {

	// Will hold the data input samples
	int *data_input_to_oct;

	// Will hold the real data input samples
	double *data_output_real_to_oct;

	// Initialize inputs array
	// Store the input values
	data_input_to_oct = (int *) svGetArrayPtr(data_input);

	// Create the output array
	data_output_real_to_oct = new double[data_input_size];

	// Initialize output arrays
	for (int i = 0; i < AMIQ_DSP_ALGORITHMS_NOF_POINTS; i++) {
		data_output_real_to_oct[i] = 0;
	}

	// Call to C++ function compute_dct_oct, that in turn will call the Octave one
	compute_dct_oct(data_input_to_oct, data_input_size,
			data_output_real_to_oct);

	// Copy the computed results into the output arrays
	for (int i = 0; i < data_input_size; i++) {
		data_output[i] = data_output_real_to_oct[i];
	}
}
示例#2
0
//function for calculating absaloute value of a complex array
void  syn_calc_abs(int size, const svOpenArrayHandle complex_arry_real, const svOpenArrayHandle complex_arry_im)
{
  int i;
  double  * c_arry_re_ptr;
  double  * c_arry_im_ptr;

  c_arry_re_ptr  = (double  *)svGetArrayPtr(complex_arry_real);
  c_arry_im_ptr  = (double  *)svGetArrayPtr(complex_arry_im);

  for(i=0;i<size;i++) {
    //  printf("[syn_calc_abs - C] i : %d\tre : %f\t",i,c_arry_re_ptr[i]);

    //abs vaure is stored in real part
    c_arry_re_ptr[i] = sqrt((c_arry_re_ptr[i] * c_arry_re_ptr[i]) + (c_arry_im_ptr[i] * c_arry_im_ptr[i]));

    //  printf("im : %f\t abs : %f\n",c_arry_im_ptr[i],c_arry_re_ptr[i]);
  }

  return;
}
/* Compute in Octave FIR function for data_input using the coef elements as coefficients
 * @param data_input : input data to compute FIR on
 * @param coef       : input coefficients used to compute FIR
 * @param data_input_size : specifies the size of data_input
 * @param data_output    : result after computing FIR on data_input
 */
void compute_fir(const svOpenArrayHandle data_input,
		const svOpenArrayHandle coef, int data_input_size,
		const svOpenArrayHandle data_output) {

	// Will hold the data input samples
	int *data_input_to_oct;

	// Will hold the coef samples
	int *coef_to_oct;

	// Will hold the data output samples
	int *data_output_to_oct;

	// Initialize inputs array
	// Store the input values
	data_input_to_oct = (int *) svGetArrayPtr(data_input);
	coef_to_oct = (int *) svGetArrayPtr(coef);
	data_output_to_oct = (int *) svGetArrayPtr(data_output);

	// Call to C++ function compute_fir_oct, that in turn will call the Octave one
	compute_fir_oct(data_input_to_oct, coef_to_oct, data_input_size,
			data_output_to_oct);
}
/* Compute in Octave Convolution for data_input1 and data_input2
 * @param data_input1 : input data1 to compute Convolution on
 * @param data_input2 : input data2 to compute Convolution on
 * @param data_input_size1 : specifies the size of data_input1
 * @param data_input_size2 : specifies the size of data_input2
 * @param data_output : result after computing Convolution on data_input
 */
void compute_conv(const svOpenArrayHandle data_input1,
		const svOpenArrayHandle data_input2, int input_data_size1,
		int input_data_size2, const svOpenArrayHandle data_output) {

	// Will hold the data input1 samples
	int *data_input_to_oct1;

	// Will hold the data input2 samples
	int *data_input_to_oct2;

	// Will hold the data output samples
	int *data_output_to_oct;

	// Initialize inputs array
	// Store the input values
	data_input_to_oct1 = (int *) svGetArrayPtr(data_input1);
	data_input_to_oct2 = (int *) svGetArrayPtr(data_input2);
	data_output_to_oct = (int *) svGetArrayPtr(data_output);

	// Call to C++ function compute_conv_oct, that in turn will call the Octave one
	compute_conv_oct(data_input_to_oct1, data_input_to_oct2, input_data_size1,
			input_data_size2, data_output_to_oct);
}
示例#5
0
/*
 *  Trasaction is added to scoreboard table implemented as list in C language. 
 */
void c_addToTable(const svOpenArrayHandle inTrans){

	TListNode* newList = malloc(sizeof(TListNode));
	newList->size = svSize(inTrans, 1);
	newList->data = malloc(newList->size);
	memcpy(newList->data, svGetArrayPtr(inTrans), newList->size);
	newList->next = NULL;

	if (scoreboard_front == NULL){	
    // list is empty
		newList->prev = NULL;
		scoreboard_front = newList;
		scoreboard_end = newList;
		added++; 
	}
	else{
		newList->prev = scoreboard_end;
		scoreboard_end->next = newList;
		scoreboard_end = newList;
		added++;
	}
}
示例#6
0
/*
 *  Transaction is removed from scoreboard table after comparation. If any 
 *  discrepancy occures, error message is printed on screen and verification
 *  stops.  
 */
int c_removeFromTable(const svOpenArrayHandle outTrans){
  unsigned int len;       // length of received data
  unsigned char *auxPkt;  // pointer to received data
  
  len = svSize(outTrans, 1);
  auxPkt = (unsigned char*) svGetArrayPtr(outTrans);
  
	if (scoreboard_front == NULL){
	  printf("Scoreboard empty!!!!!!!!!!!!!\n");
		return EXIT_FAILURE;
	}
	else{
	  TListNode* node = scoreboard_front;
	  scoreboard_front = node->next;

		if (scoreboard_front == NULL){
		  scoreboard_end = NULL;
		}
		else{
		  scoreboard_front->prev = NULL;
		}

		if (len != node->size){
		  printf("Size doesn't match!!!!!!!!!!!!!\n");
			return EXIT_FAILURE;
		}
		else{
		  if (memcmp(node->data, auxPkt, len)){
			  printf("Data don't match!!!!!!!!!!!!!\n");
			  return EXIT_FAILURE;
		  }
		}
    free(node);
    removed++;
	}
  return EXIT_SUCCESS;
}