6 * Returns a random integer in the range between lower_bound and
7 * upper_bound, where the bounding values are included in the interval.
9 int getRandomNumber(int lower_bound, int upper_bound)
11 return (rand() % (upper_bound - lower_bound + 1)) + lower_bound;
15 void generator_init(DOLProcess *p)
17 ; //nothing to be done here
21 int generator_fire(DOLProcess *p)
23 CREATEPORTVAR(output_port);
25 srand(0); //initialize random number generator
27 //generate input coefficients and write them to output ports
28 for (p->local->index = 0;
29 p->local->index < NUMBER_OF_FFT_POINTS;
31 p->local->coeffs[p->local->index].real = (float)getRandomNumber(-9, 9);
32 p->local->coeffs[p->local->index].imag = (float)getRandomNumber(-9, 9);
34 CREATEPORT(output_port, PORT_INPUT_COEFFICIENTS, 1,
35 p->local->index, NUMBER_OF_FFT_POINTS);
36 printf("%15s: Write to input_coefficients_%d: %9f + j * %9f\n",
37 "input_generator", p->local->index,
38 p->local->coeffs[p->local->index].real,
39 p->local->coeffs[p->local->index].imag);
40 DOL_write((void*)output_port, &(p->local->coeffs[p->local->index]),
41 sizeof(ComplexNumber), p);