1 #include "Beam_Former.h"
3 /************************************************************************************/
5 void Beam_Former_init(DOLProcess * p)
8 for (i=0; i<NUMBER_OF_RANGE_BINS; i++)
10 p->local->Vector_Product[i].real = 0.0;
11 p->local->Vector_Product[i].imag = 0.0;
13 // p->local->sample_counter = 0;
14 p->local->pulse_counter = 0;
15 p->local->n_iterations = 0;
17 p->local->range_counter=0;
19 p->local->excount = 0;
23 /************************************************************************************/
25 int Beam_Former_fire(DOLProcess * p)
29 ComplexNumber samples[NUMBER_OF_ANTENNA_ELEMENTS];
30 ComplexNumber weights[NUMBER_OF_ANTENNA_ELEMENTS];
32 // Read arrays from ports
33 DOL_read((void*)PORT_DATA_IN, &samples, NUMBER_OF_ANTENNA_ELEMENTS*sizeof(ComplexNumber), p);
34 DOL_read((void*)PORT_WEIGHT_IN, &weights, NUMBER_OF_ANTENNA_ELEMENTS*sizeof(ComplexNumber), p);
36 // Multiply and accumulate elementwise
38 for (i=0; i<NUMBER_OF_ANTENNA_ELEMENTS; i++)
40 /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
41 multiply_and_accumulate(&samples[i], &weights[i], p);
44 // This is not needed anymore
45 //p->local->sample_counter = p->local->sample_counter + 1;
46 p->local->range_counter = p->local->range_counter+1;
48 if (p->local->range_counter == NUMBER_OF_RANGE_BINS) // When we have enought data
50 DOL_write((void*)PORT_DATA_OUT, &(p->local->Vector_Product[0]), NUMBER_OF_RANGE_BINS*sizeof(ComplexNumber), p); // Send the data
52 // Reset the Vector Product vector
54 for (i=0; i<NUMBER_OF_RANGE_BINS; i++)
56 p->local->Vector_Product[i].real = 0.0;
57 p->local->Vector_Product[i].imag = 0.0;
60 // This is not necessary anymore
61 // p->local->sample_counter = 0;
63 // Reset the range_counter
64 p->local->range_counter=0;
66 p->local->pulse_counter = p->local->pulse_counter + 1;
69 if (p->local->pulse_counter == NUMBER_OF_PULSES)
71 p->local->n_iterations = p->local->n_iterations + 1;
72 p->local->pulse_counter = 0;
76 if (p->local->n_iterations == NUMBER_OF_ITERATIONS)
78 printf("\n\n:: Beam_former process finished ::\n\n");
79 // printf("\ttotal number of executions: %d",p->local->excount);
87 /************************************************************************************/
89 void multiply_and_accumulate(ComplexNumber * next_sample, ComplexNumber * next_weight, DOLProcess * p)
93 temp.real = (next_sample->real * next_weight->real - next_sample->imag * next_weight->imag);
94 temp.imag = (next_sample->real * next_weight->imag + next_sample->imag * next_weight->real);
95 // Notice the change! every time we save into next range element of Vector_Product
96 p->local->Vector_Product[p->local->range_counter].real = p->local->Vector_Product[p->local->range_counter].real + temp.real;
97 p->local->Vector_Product[p->local->range_counter].imag = p->local->Vector_Product[p->local->range_counter].imag + temp.imag;