[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r5123 - gnuradio/branches/developers/n4hy/ofdm/gnuradi
From: |
trondeau |
Subject: |
[Commit-gnuradio] r5123 - gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general |
Date: |
Thu, 26 Apr 2007 13:02:02 -0600 (MDT) |
Author: trondeau
Date: 2007-04-26 13:02:01 -0600 (Thu, 26 Apr 2007)
New Revision: 5123
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_stream_mux.cc
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_stream_mux.h
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_stream_mux.i
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_stream_mux.lo
Modified:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/Makefile.am
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/general.i
Log:
adding stream MUX block. Takes N streams with a list or tuple to specify the
number of items per stream, all of the same size
Modified:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/Makefile.am
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/Makefile.am
2007-04-26 19:00:49 UTC (rev 5122)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/Makefile.am
2007-04-26 19:02:01 UTC (rev 5123)
@@ -130,6 +130,7 @@
gr_skiphead.cc \
gr_squelch_base_cc.cc \
gr_squelch_base_ff.cc \
+ gr_stream_mux.cc \
gr_stream_to_streams.cc \
gr_stream_to_vector.cc \
gr_streams_to_stream.cc \
@@ -267,6 +268,7 @@
gr_skiphead.h \
gr_squelch_base_cc.h \
gr_squelch_base_ff.h \
+ gr_stream_mux.h \
gr_stream_to_streams.h \
gr_stream_to_vector.h \
gr_streams_to_stream.h \
@@ -401,6 +403,7 @@
gr_skiphead.i \
gr_squelch_base_cc.i \
gr_squelch_base_ff.i \
+ gr_stream_mux.i \
gr_stream_to_streams.i \
gr_stream_to_vector.i \
gr_streams_to_stream.i \
Modified:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/general.i
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/general.i
2007-04-26 19:00:49 UTC (rev 5122)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/general.i
2007-04-26 19:02:01 UTC (rev 5123)
@@ -69,6 +69,7 @@
#include <gr_fake_channel_coder_pp.h>
#include <gr_throttle.h>
#include <gr_mpsk_receiver_cc.h>
+#include <gr_stream_mux.h>
#include <gr_stream_to_streams.h>
#include <gr_streams_to_stream.h>
#include <gr_streams_to_vector.h>
@@ -169,6 +170,7 @@
%include "gr_fake_channel_coder_pp.i"
%include "gr_throttle.i"
%include "gr_mpsk_receiver_cc.i"
+%include "gr_stream_mux.i"
%include "gr_stream_to_streams.i"
%include "gr_streams_to_stream.i"
%include "gr_streams_to_vector.i"
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_stream_mux.cc
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_stream_mux.cc
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_stream_mux.cc
2007-04-26 19:02:01 UTC (rev 5123)
@@ -0,0 +1,192 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gr_stream_mux.h>
+#include <gr_io_signature.h>
+
+#define VERBOSE 0
+
+gr_stream_mux_sptr
+gr_make_stream_mux (size_t itemsize, const std::vector<int> &lengths)
+{
+ return gr_stream_mux_sptr (new gr_stream_mux (itemsize, lengths));
+}
+
+gr_stream_mux::gr_stream_mux (size_t itemsize, const std::vector<int> &lengths)
+ : gr_block ("stream_mux",
+ gr_make_io_signature (1, -1, itemsize),
+ gr_make_io_signature (1, 1, itemsize)),
+ d_itemsize(itemsize),
+ d_stream(0),
+ d_residual(0),
+ d_lengths(lengths)
+{
+}
+
+gr_stream_mux::~gr_stream_mux(void)
+{
+}
+
+void
+gr_stream_mux::forecast (int noutput_items, gr_vector_int
&ninput_items_required)
+{
+ unsigned ninputs = ninput_items_required.size ();
+ for (unsigned i = 0; i < ninputs; i++)
+ ninput_items_required[i] = 0;
+}
+
+
+int
+gr_stream_mux::general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+
+ char *out = (char *) output_items[0];
+ const char *in;
+
+ int acc = 0;
+ int N=0;
+ int M=0;
+ std::vector<int> consume_vector(d_lengths.size(), 0);
+
+ #if VERBOSE
+ printf("mux: nouput_items: %d d_stream: %d\n", noutput_items, d_stream);
+ for(int i = 0; i < d_lengths.size(); i++)
+ printf("\tninput_items[%d]: %d\n", i, ninput_items[i]);
+ #endif
+
+ in = (const char *) input_items[d_stream];
+
+ if(d_residual) {
+ #if VERBOSE
+ printf("Cleaning up residual bytes (%d) from stream %d\n", d_residual,
d_stream);
+ #endif
+
+ // get the number of items available in input stream up to the
+ // num items required
+ N=std::min(d_residual, ninput_items[d_stream]);
+
+ // get the number of items we can put into the output buffer
+ M=std::min(N, noutput_items);
+
+ // copy the items to the output buff
+ memcpy(out, in, M*d_itemsize);
+
+ // increment the output accumulator
+ acc += M;
+
+ // keep track of items consumed
+ consume_vector[d_stream]=M;
+
+ // keep track if there are residual items left from the input stream
+ d_residual -= M;
+
+ #if VERBOSE
+ printf("Stream: %d (%x) Wrote: %d bytes Output has: %d bytes
residual: %d bytes\n",
+ d_stream, in, M, acc, d_residual);
+ #endif
+
+ // if no residual items, we're done with this input stream for
+ // this round
+ if (!d_residual) {
+ if(d_stream == d_lengths.size() - 1) {
+ d_stream=0; // wrap stream pointer
+ }
+ else {
+ d_stream++; // or increment the stream pointer
+ }
+ #if VERBOSE
+ printf("Going to next stream: %d\n", d_stream);
+ #endif
+ in = ((const char *) (input_items[d_stream])) +
d_itemsize*consume_vector[d_stream];
+ }
+ }
+
+ if(!d_residual) {
+ while (acc<noutput_items){
+ // get the number of items available in input stream up to the
+ // num items required
+ N=std::min(d_lengths[d_stream], ninput_items[d_stream]);
+
+ // get the number of items we can put into the output buffer
+ M=std::min(N, noutput_items-acc);
+
+ // copy the items to the output buff
+ memcpy(out+acc*d_itemsize,in,M*d_itemsize);
+
+ // increment the output accumulator
+ acc += M;
+
+ // keep track of items consumed
+ consume_vector[d_stream]+=M;
+
+ // keep track if there are residual items left from the input stream
+ d_residual=d_lengths[d_stream] - M;
+
+ #if VERBOSE
+ printf("Stream: %d (%x) Wrote: %d bytes Output has: %d bytes
residual: %d bytes\n",
+ d_stream, in, M, acc, d_residual);
+ #endif
+
+ // if no residual items, we're done with this input stream for
+ // this round
+ if (!d_residual) {
+ if(d_stream == d_lengths.size() - 1) {
+ d_stream=0; // wrap stream pointer
+ }
+ else {
+ d_stream++; // or increment the stream pointer
+ }
+ #if VERBOSE
+ printf("Going to next stream: %d\n", d_stream);
+ #endif
+
+ // get next stream pointer
+ in = ((const char *) (input_items[d_stream])) +
d_itemsize*consume_vector[d_stream];
+ }
+ else{
+ break;
+ }
+ }
+ }
+
+ for (unsigned int j=0;j<d_lengths.size();j++){
+ consume(j,consume_vector[j]);
+
+ #if VERBOSE
+ printf("consuming: %d on stream: %d\n", consume_vector[j], j);
+ #endif
+ }
+
+ #if VERBOSE
+ printf("mux: returning: %d\n\n", acc);
+ #endif
+
+ return acc;
+
+}
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_stream_mux.h
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_stream_mux.h
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_stream_mux.h
2007-04-26 19:02:01 UTC (rev 5123)
@@ -0,0 +1,71 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef INCLUDED_GR_STREAM_MUX_H
+#define INCLUDED_GR_STREAM_MUX_H
+
+
+#include <gr_block.h>
+#include <gr_frame.h>
+#include <vector>
+
+class gr_stream_mux;
+typedef boost::shared_ptr<gr_stream_mux> gr_stream_mux_sptr;
+
+gr_stream_mux_sptr
+gr_make_stream_mux (size_t itemsize, const std::vector<int> &lengths);
+/*!
+ * \brief take desired numbers of certain signals from multiple inputs and put
the siganls
+ * consecutively in the output vector. Each input are a serial of int
variables, same as the
+ * output, suitable for adding preamble of the ofdm signal used in an ofdm
+ * modulator.
+ */
+
+class gr_stream_mux : public gr_block
+{
+ friend gr_stream_mux_sptr
+ gr_make_stream_mux (size_t itemsize, const std::vector<int> &lengths);
+
+ protected:
+ gr_stream_mux (size_t itemsize, const std::vector<int> &lengths);
+ private:
+ size_t d_itemsize;
+ unsigned int d_stream;
+ int d_residual;
+ int d_times;
+ int d_unconsume;
+ //gr_vector_int d_unconsume;
+ gr_vector_int d_lengths;
+ public:
+ ~gr_stream_mux(void);
+
+ void forecast (int noutput_items, gr_vector_int &ninput_items_required);
+
+ int general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+};
+
+
+#endif
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_stream_mux.i
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_stream_mux.i
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_stream_mux.i
2007-04-26 19:02:01 UTC (rev 5123)
@@ -0,0 +1,42 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006 Free Software Foundation, Inc.
+ *
+ * This file is part of GNU Radio
+ *
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * GNU Radio is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU Radio; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <vector>
+
+GR_SWIG_BLOCK_MAGIC(gr,stream_mux)
+
+gr_stream_mux_sptr
+gr_make_stream_mux (size_t itemsize,
+ const std::vector<int> &lengths);
+
+class gr_stream_mux : public gr_block
+{
+ protected:
+ gr_make_stream_mux (size_t itemsize,
+ const std::vector<int> &lengths);
+
+ public:
+ int general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
Added:
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_stream_mux.lo
===================================================================
---
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_stream_mux.lo
(rev 0)
+++
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_stream_mux.lo
2007-04-26 19:02:01 UTC (rev 5123)
@@ -0,0 +1,12 @@
+# gr_stream_mux.lo - a libtool object file
+# Generated by ltmain.sh - GNU libtool 1.5.22 Debian 1.5.22-4 (1.1220.2.365
2005/12/18 22:14:06)
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object='.libs/gr_stream_mux.o'
+
+# Name of the non-PIC object.
+non_pic_object=none
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r5123 - gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general,
trondeau <=