howto_interp_gscrambler_cc.cc


※上記の広告は60日以上更新のないWIKIに表示されています。更新することで広告が下部へ移動します。

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <howto_interp_gscrambler_cc.h>
#include <gr_io_signature.h>
#include <stdexcept>
#include <iostream>

howto_interp_gscrambler_cc_sptr howto_make_interp_gscrambler_cc (unsigned interpolation, int degree, int mask, int seed)
{
  return howto_interp_gscrambler_cc_sptr (new howto_interp_gscrambler_cc (interpolation, degree, mask, seed));
}


howto_interp_gscrambler_cc::howto_interp_gscrambler_cc (unsigned interpolation, int degree, int mask, int seed)
  : gr_sync_interpolator ("interp_fir_filter_ccf",
			  gr_make_io_signature (1, 1, sizeof (gr_complex)),
			  gr_make_io_signature (1, 1, sizeof (gr_complex)),
			  interpolation)
{
  if (interpolation == 0)
    throw std::out_of_range ("interpolation must be > 0");
  d_len = (unsigned int)((1ULL << degree)-1);
  if (mask == 0)
    mask = gri_glfsr::glfsr_mask(degree);
  d_reference = new gri_glfsr(mask, seed);
}


howto_interp_gscrambler_cc::~howto_interp_gscrambler_cc ()
{
  delete d_reference;
}

int howto_interp_gscrambler_cc::work (int noutput_items,
	   gr_vector_const_void_star &input_items,
	   gr_vector_void_star &output_items)
{
  const gr_complex *in = (const gr_complex *) input_items[0];
  gr_complex *out = (gr_complex *) output_items[0];
  int ntaps = interpolation (); // as same as d_len
  int ni = noutput_items / interpolation ();
  for (int i = 0; i < ni; i++){
    for (int nt = 0; nt < ntaps; nt++){
    	d_pn = 2.0*d_reference->next_bit()-1.0; // no conditionals
    	*out++ = *in * d_pn;
    }
    in++;
  }

  return noutput_items;
}