Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and style correction #3

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions grc/pfb_channelizer_tap_update.xml

This file was deleted.

Binary file removed include/pfb_channelizer/chanmux.h.gch
Binary file not shown.
Binary file removed include/pfb_channelizer/chanmux_block_ctrl.hpp.gch
Binary file not shown.
Binary file removed include/pfb_channelizer/poly_channelizer.h.gch
Binary file not shown.
28 changes: 2 additions & 26 deletions lib/chanmux_block_ctrl_impl.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
* Copyright 2017 <+YOU OR YOUR COMPANY+>.
* Copyright 2017-2018 Ettus Research
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -119,7 +119,7 @@ class chanmux_block_ctrl_impl : public chanmux_block_ctrl
sr_write(SR_RELOAD, boost::uint32_t(taps_fi[i]));
printf("tap[%d] = %d\n", (int) i, (int) boost::uint32_t(taps_fi[i]));
}
sr_write(SR_RELOAD_TLAST, boost::uint32_t(taps_fi.back()));
sr_write(SR_RELOAD_TLAST, boost::uint32_t(taps_fi.back()));
printf("final tap = %d\n", (int) boost::uint32_t(taps_fi.back()));
printf("set_taps() done\n");
}
Expand All @@ -146,7 +146,6 @@ class chanmux_block_ctrl_impl : public chanmux_block_ctrl
}
}


int
nextpow2(const int value)
{
Expand Down Expand Up @@ -212,7 +211,6 @@ class chanmux_block_ctrl_impl : public chanmux_block_ctrl
}

int N = A_vals.size();
// idx = np.arange(N / 2)

for (int i=0; i < N / 2; i++)
{
Expand All @@ -227,9 +225,6 @@ class chanmux_block_ctrl_impl : public chanmux_block_ctrl
{
A_vals[i] = std::pow(A_vals[i], exponent);
}
// cast A as complex.
// gr_complex *A_complex = new gr_complex;
// volk_32f_x2_interleave_32fc(A_complex, &A_vals[0], q_a, A_vals.size());

int fil_size = (int) A_vals.size();
gr::fft::fft_complex *d_fwdfft = new gr::fft::fft_complex(fil_size, false, 1);
Expand All @@ -243,7 +238,6 @@ class chanmux_block_ctrl_impl : public chanmux_block_ctrl
{
temp_grc = (gr_complex) A_vals[j];
A_comp.push_back(temp_grc);
// printf("A_comp[%d] = %f + j%f;\n", j, temp_grc.real(), temp_grc.imag());
}

// copy A values into fft input buffer
Expand All @@ -254,7 +248,6 @@ class chanmux_block_ctrl_impl : public chanmux_block_ctrl
gr_complex *b = d_fwdfft->get_outbuf();
gr_complex *b_copy;

// memcpy(b_copy, b, fft_size);
// perform shift
int shift_pt = fil_size >> 1;
float sum_b = 0.;
Expand All @@ -271,19 +264,12 @@ class chanmux_block_ctrl_impl : public chanmux_block_ctrl
{
ret_val[i] = ret_val[i] / sum_b;
}
// take real part of b.
//

// b = np.fft.ifft(A)
// b = (np.fft.fftshift(b)).real
// b /= np.sum(b)
delete d_fwdfft;
}

void
gen_fixed_filter(const gr_vector_float& taps, const int fft_size, const int desired_msb, gr_vector_int& output_vector)
{
// float max_coeff_val = (2. **(qvec_coef[0] - 1) - 1) * (2. ** -self.qvec_coef[1])
float max_coeff_val = (std::pow(2., (float) qvec_coef[0] - 1.) - 1.) * std::pow(2., (float)-qvec_coef[1]);
int max_input = (int) std::pow(2., (float) qvec[0] - 1.) - 1;

Expand Down Expand Up @@ -333,14 +319,10 @@ class chanmux_block_ctrl_impl : public chanmux_block_ctrl
s_gain = std::max_element(path_gain.begin(), path_gain.end());
// // compute noise and signal gain.
int gain_msb = nextpow2(*s_gain);
//
// gain_msb = self.nextpow2(s_gain)
int max_coef_val = (int) std::pow(2., (float) gain_msb - 1.);
float in_use = (float) *s_gain / (float) max_coef_val;
// // print(np.max(s_gain), np.max(max_input))
int int_max_value = *s_gain * max_input;
int num_bits = ret_num_bitsS(int_max_value);
// // print(num_bits)
int msb = num_bits - 1;
if (in_use <= .9)
{
Expand All @@ -356,7 +338,6 @@ class chanmux_block_ctrl_impl : public chanmux_block_ctrl
}
}
}
//
if (desired_msb < msb)
{
int diff = msb - desired_msb;
Expand All @@ -371,10 +352,6 @@ class chanmux_block_ctrl_impl : public chanmux_block_ctrl

// reshape poly_fi into single vector with padding.
int pad = max_fft_size - fft_size;
// // print("msb = {}".format(msb))
// // taps_fi = np.reshape(poly_fil, (1, -1), order='F')
// poly_fil = poly_fil.astype(np.int32)
//
for (int j=0; j < taps_per_phase; j++)
{
for (int i=0; i < fft_size; i++)
Expand All @@ -390,7 +367,6 @@ class chanmux_block_ctrl_impl : public chanmux_block_ctrl
printf("output_vector[i] = %d\n", output_vector[i]);
}
}

};

UHD_RFNOC_BLOCK_REGISTER(chanmux_block_ctrl,"chanmux");
40 changes: 17 additions & 23 deletions lib/chanmux_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ namespace gr {
* The private constructor
*/
chanmux_impl::chanmux_impl(
const gr::ettus::device3::sptr &dev,
const int block_select,
const int device_select
const gr::ettus::device3::sptr &dev,
const int block_select,
const int device_select
)
: gr::ettus::rfnoc_block("chanmux"),
gr::ettus::rfnoc_block_impl(
Expand All @@ -71,27 +71,21 @@ namespace gr {
{
}

void
chanmux_impl::set_block_size(const int fft_size)
{
gr::thread::scoped_lock guard(d_mutex);
get_block_ctrl_throw< ::uhd::rfnoc::chanmux_block_ctrl>()-> set_fft_size(fft_size);

void
chanmux_impl::set_block_size(const int fft_size)
{
gr::thread::scoped_lock guard(d_mutex);
get_block_ctrl_throw< ::uhd::rfnoc::chanmux_block_ctrl>()-> set_fft_size(fft_size);

// read back to ensure HW and SW are in sync.
d_fft_size = get_block_ctrl_throw< ::uhd::rfnoc::chanmux_block_ctrl >()->get_fft_size();
// now always pulling blocks of 256 samples.

}


void
chanmux_impl::get_block_size()
{
d_fft_size = get_block_ctrl_throw< ::uhd::rfnoc::chanmux_block_ctrl >()-> get_fft_size();
}


// read back to ensure HW and SW are in sync.
d_fft_size = get_block_ctrl_throw< ::uhd::rfnoc::chanmux_block_ctrl >()->get_fft_size();
// now always pulling blocks of 256 samples.
}

void
chanmux_impl::get_block_size()
{
d_fft_size = get_block_ctrl_throw< ::uhd::rfnoc::chanmux_block_ctrl >()-> get_fft_size();
}
} /* namespace pfb_channelizer */
} /* namespace gr */
3 changes: 0 additions & 3 deletions lib/chanmux_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,13 @@ namespace gr {
private:
size_t d_fft_size;
gr::thread::mutex d_mutex; // mutex to protect set/work access
// int nextpow2(unsigned int i);

public:
chanmux_impl(const gr::ettus::device3::sptr &dev, const int block_select, const int device_select);
~chanmux_impl();

void set_block_size(const int fft_size);
void get_block_size();
// Where all the action really happens
// void forecast (int noutput_items, gr_vector_int &ninput_items_required);
};

} // namespace pfb_channelizer
Expand Down
2 changes: 1 addition & 1 deletion lib/poly_channelizer_impl.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
* Copyright 2017 <+YOU OR YOUR COMPANY+>.
* Copyright 2017-2018 Ettus Research
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
157 changes: 0 additions & 157 deletions lib/poly_channelizer_impl.cc.orig

This file was deleted.

Loading