module: ofdm_ifft
description:  outputs inverse fft of input
parameters: int num_channels
inputs: Vector vec_qam_i, Vector vec_qam_q, double clk_frame
outputs:  Vector vec_ifft_i, Vector vec_ifft_q
static_variables:
classes: EdgeDetect clk_frame_edge()
set_output_vector_lengths:
  vec_ifft_i=num_channels
  vec_ifft_q=num_channels
init:
  int power_of_two;
  power_of_two = 2;
  while (power_of_two <= num_channels)
     {
      if (num_channels % power_of_two != 0)
         break;
      power_of_two = power_of_two << 1;
     }
   if (power_of_two < num_channels)
      {
          printf("error in 'ofdm_ifft':  num_channels must equal 2^n\n");
          printf("   where n is an integer\n");
          printf("   ->  in this case, num_channels = %d\n",num_channels);
          exit(1);
      }
  if (vec_qam_i.get_length() != num_channels ||
      vec_qam_q.get_length() != num_channels)
      {
       printf("error in 'ofdm_ifft':  input qam vectors must have length\n");
       printf("  equal to 'num_channels' ( = %d in this case)\n",
                 num_channels);
       printf("  in this case, length of vec_qam_i = %d\n",
                    vec_qam_i.get_length());
       printf("  and length of vec_qam_q = %d\n",
                    vec_qam_q.get_length());
       printf("  num_channels = %d\n",num_channels);
       exit(1);
      }
code:
  if (clk_frame_edge.inp(clk_frame))
     {
      ifft(vec_qam_i,vec_qam_q,vec_ifft_i,vec_ifft_q);
     }
