[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 02/07: digital: wip: more progress
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 02/07: digital: wip: more progress |
Date: |
Wed, 22 Apr 2015 03:12:51 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 5f16e9dc71b3ee1b609279294a27cc0ed85dba22
Author: Sean Nowlan <address@hidden>
Date: Fri Apr 17 19:01:10 2015 -0400
digital: wip: more progress
---
.../include/gnuradio/digital/burst_shaper_XX.h.t | 10 +--
gr-digital/lib/burst_shaper_XX_impl.cc.t | 76 +++++++++++++++++++---
gr-digital/lib/burst_shaper_XX_impl.h.t | 32 +++++----
3 files changed, 93 insertions(+), 25 deletions(-)
diff --git a/gr-digital/include/gnuradio/digital/burst_shaper_XX.h.t
b/gr-digital/include/gnuradio/digital/burst_shaper_XX.h.t
index d527428..6825155 100644
--- a/gr-digital/include/gnuradio/digital/burst_shaper_XX.h.t
+++ b/gr-digital/include/gnuradio/digital/burst_shaper_XX.h.t
@@ -81,7 +81,7 @@ namespace gr {
* \param length_tag_name: the name of the tagged stream length
* tag key.
*/
- static sptr make(const std::vector<@I_TYPE@> &taps,
+ static sptr make(const std::vector<@O_TYPE@> &taps,
int pre_padding=0, int post_padding=0,
bool insert_phasing=false,
const std::string &length_tag_name="packet_len");
@@ -89,24 +89,24 @@ namespace gr {
/*!
* Returns the amount of zero padding inserted before each burst.
*/
- virtual unsigned int pre_padding() const = 0;
+ virtual int pre_padding() const = 0;
/*!
* Returns the amount of zero padding inserted after each burst.
*/
- virtual unsigned int post_padding() const = 0;
+ virtual int post_padding() const = 0;
/*!
* Returns the total amount of zero padding and phasing symbols
* inserted before each burst.
*/
- virtual unsigned int prefix_length() const = 0;
+ virtual int prefix_length() const = 0;
/*!
* Returns the total amount of zero padding and phasing symbols
* inserted after each burst.
*/
- virtual unsigned int suffix_length() const = 0;
+ virtual int suffix_length() const = 0;
};
} // namespace digital
diff --git a/gr-digital/lib/burst_shaper_XX_impl.cc.t
b/gr-digital/lib/burst_shaper_XX_impl.cc.t
index eb7338a..cdbc7ce 100644
--- a/gr-digital/lib/burst_shaper_XX_impl.cc.t
+++ b/gr-digital/lib/burst_shaper_XX_impl.cc.t
@@ -50,17 +50,29 @@ namespace gr {
: gr::block("@BASE_NAME@",
gr::io_signature::make(1, 1, sizeof(@I_TYPE@)),
gr::io_signature::make(1, 1, sizeof(@O_TYPE@))),
- d_upflank(taps.begin(), taps.begin() + taps.size()/2 + taps.size()%2),
- d_downflank(taps.begin() + taps.size()/2, taps.end()),
+ d_up_flank(taps.begin(), taps.begin() + taps.size()/2 + taps.size()%2),
+ d_down_flank(taps.begin() + taps.size()/2, taps.end()),
d_nprepad(pre_padding),
d_npostpad(post_padding),
d_insert_phasing(insert_phasing),
d_length_tag_key(pmt::string_to_symbol(length_tag_name)),
d_state(STATE_WAITING)
{
- if(d_insert_phasing)
- for(unsigned int i = 0; i < d_upflank.size(); i++)
- d_phasing.push_back(i%2 ? @I_TYPE@(1.0f) : @I_TYPE@(-1.0f));
+ assert(d_up_flank.size() == d_down_flank.size());
+
+ d_up_phasing.resize(d_up_flank.size());
+ d_down_phasing.resize(d_up_flank.size());
+ if(d_insert_phasing) {
+ @I_TYPE@ symbol;
+ for(unsigned int i = 0; i < d_up_flank.size(); i++) {
+ symbol = (i%2) ? @I_TYPE@(1.0f) : @I_TYPE@(-1.0f);
+ d_up_phasing.push_back(symbol * d_up_flank[i]);
+ d_down_phasing.push_back(symbol * d_down_flank[i]);
+ }
+ }
+
+ set_relative_rate(1.0);
+ set_tag_propagation_policy(TPP_DONT);
}
@IMPL_NAME@::address@hidden@()
@@ -84,33 +96,79 @@ namespace gr {
int nwritten = 0;
int nread = 0;
- int curr_tag_index = 0;
- int nprocess = 0;
+ int nstart = 0;
+ int nstop = 0;
+ int nremaining = 0;
+ int nprocessed = 0;
+ uint64_t curr_tag_index = nitems_read(0);
std::vector<tag_t> tags;
get_tags_in_window(tags, 0, 0, ninput_items[0]);
std::sort(tags.begin(), tags.end(), tag_t::offset_compare);
- //TODO: figure out what to do with tag gaps - should probably just drop
while((nwritten < noutput_items) && (nread < ninput_items[0])) {
+ nremaining = noutput_items - nwritten;
switch(d_state) {
case(STATE_WAITING):
+ curr_tag_index = tags[0].offset;
+ d_nremaining = pmt::to_long(tags[0].value) +
+ prefix_length() + suffix_length();
+ nprocessed += (int)curr_tag_index; // drop orphaned
samples
+ add_length_tag(nwritten);
+ enter_prepad();
+ break;
+
case(STATE_PREPAD):
std::memset(out, 0x00, nprocess * sizeof(@O_TYPE@));
+ break;
+
case(STATE_RAMPUP):
+ nprocess = std::min(
+ if(d_insert_phasing) {
+
+ }
+ break;
+
case(STATE_COPY):
std::memcpy(out, in, nprocess * sizeof(@O_TYPE@));
+ break;
+
case(STATE_RAMPDOWN):
+ break;
+
case(STATE_POSTPAD):
std::memset(out, 0x00, nprocess * sizeof(@O_TYPE@));
+ break;
+
+ default:
+ throw std::runtime_error("burst_shaper: invalid state
reached");
}
}
- consume_each (noutput_items);
+ consume_each (nconsumed);
// Tell runtime system how many output items we produced.
return noutput_items;
}
+ void
+ @IMPL_NAME@::add_length_tag(int offset)
+ {
+ add_item_tag(0, nitems_written(0) + offset, d_length_tag_key,
+ pmt::from_long(d_nremaining),
+ pmt::string_to_symbol(name()));
+ }
+
+ void
+ @IMPL_NAME@::propagate_tags(std::vector<tag_t> &tags, int offset)
+ {
+ // FIXME: need to handle offsets correctly
+ std::vector<tag_t>::iterator tag;
+ for(tag = tags.begin(); tag != tags.end(); tag++) {
+ tag_t new_tag = *tag;
+ new_tag.offset = nitems_written(0) + offset;
+ add_item_tag(0, new_tag);
+ }
+ }
} /* namespace digital */
} /* namespace gr */
diff --git a/gr-digital/lib/burst_shaper_XX_impl.h.t
b/gr-digital/lib/burst_shaper_XX_impl.h.t
index c36a3ad..66b5e24 100644
--- a/gr-digital/lib/burst_shaper_XX_impl.h.t
+++ b/gr-digital/lib/burst_shaper_XX_impl.h.t
@@ -37,18 +37,28 @@ namespace gr {
STATE_COPY, STATE_RAMPDOWN, STATE_POSTPAD};
private:
- const std::vector<@I_TYPE@> d_upflank;
- const std::vector<@I_TYPE@> d_downflank;
+ const std::vector<@O_TYPE@> d_up_flank;
+ const std::vector<@O_TYPE@> d_down_flank;
const int d_nprepad;
const int d_npostpad;
const bool d_insert_phasing;
const pmt::pmt_t d_length_tag_key;
- std::vector<@I_TYPE@> d_phasing;
- int d_remaining;
+ std::vector<@O_TYPE@> d_up_phasing;
+ std::vector<@O_TYPE@> d_down_phasing;
+ uint64_t d_nremaining;
state_t d_state;
+ void enter_waiting() { d_state = STATE_WAITING; }
+ void enter_prepad() { d_state = STATE_PREPAD; }
+ void enter_rampup() { d_state = STATE_RAMPUP; }
+ void enter_copy() { d_state = STATE_COPY; }
+ void enter_rampdown() { d_state = STATE_RAMPDOWN; }
+ void enter_postpad() { d_state = STATE_POSTPAD; }
+ void add_length_tag(int offset);
+ void propagate_tag(tag_t &tag, int offset);
+
public:
- @IMPL_NAME@(const std::vector<@I_TYPE@> &taps, int pre_padding,
+ @IMPL_NAME@(const std::vector<@O_TYPE@> &taps, int pre_padding,
int post_padding, bool insert_phasing,
const std::string &length_tag_name);
address@hidden@();
@@ -60,12 +70,12 @@ namespace gr {
gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
- unsigned int pre_padding() const { return d_nprepad; }
- unsigned int post_padding() const { return d_npostpad; }
- unsigned int prefix_length() const { return d_nprepad +
- d_upflank.size(); }
- unsigned int suffix_length() const { return d_npostpad +
- d_downflank.size(); }
+ int pre_padding() const { return d_nprepad; }
+ int post_padding() const { return d_npostpad; }
+ int prefix_length() const { return d_nprepad +
+ d_up_flank.size(); }
+ int suffix_length() const { return d_npostpad +
+ d_down_flank.size(); }
};
} // namespace digital
- [Commit-gnuradio] [gnuradio] branch master updated (fdfece1 -> d8a491f), git, 2015/04/21
- [Commit-gnuradio] [gnuradio] 05/07: digital: install burst shaper block example GRC, git, 2015/04/21
- [Commit-gnuradio] [gnuradio] 06/07: Merge branch 'maint', git, 2015/04/21
- [Commit-gnuradio] [gnuradio] 07/07: Merge remote-tracking branch 'nowls/burst_shaping', git, 2015/04/21
- [Commit-gnuradio] [gnuradio] 02/07: digital: wip: more progress,
git <=
- [Commit-gnuradio] [gnuradio] 01/07: digital: wip: burst shaper compiles and installs, git, 2015/04/21
- [Commit-gnuradio] [gnuradio] 04/07: digital: added GRC example for burst shaper blocks, git, 2015/04/21
- [Commit-gnuradio] [gnuradio] 03/07: digital: burst_shaper block passes meaningful QA tests, git, 2015/04/21