module: ofdm_bit_source
description:  creates bits from bernoulli generator for each ofdm frame
parameters:
inputs: double clk_data, double clk_frame, IntVector vec_bit_settings 
outputs:  int out
static_variables: int clk_count, int frame_length, int frame_flag
classes: Rand data("bernoulli"), EdgeDetect clk_data_edge(),
         EdgeDetect clk_frame_edge()
init:
  out = 0;
  clk_count = 0;
  frame_length = 0;
  frame_flag = 0;
  int i;
  for (i = 0; i < vec_bit_settings.get_length(); i++)
       frame_length += vec_bit_settings.get_elem(i);
code:
  int i;
    if (clk_frame_edge.inp(clk_frame))
     {
      if (frame_flag == 1)
      {
        frame_flag = 0;
        if (clk_count != frame_length)
         {
          printf("error in 'ofdm_bit_source' module\n");
          printf("  clk_count != frame_length\n");
          printf("  -> in this case, clk_count = %d, frame_length = %d\n",
                clk_count, frame_length);
          exit(1);
         }
      clk_count = 0;
      frame_length = 0;
      for (i = 0; i < vec_bit_settings.get_length(); i++)
          frame_length += vec_bit_settings.get_elem(i);
     }
    } 
  if (clk_data_edge.inp(clk_data))
   {
        frame_flag=1;
        if (clk_count < frame_length)
            {
            out = data.inp() > 0.0 ? 1 : 0;
            clk_count++;
            }
        else
            {
               out = 0;
            }
    }
