From f34c5f13316b6b75533e23430c8e3640ee5c360d Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Fri, 17 Jun 2022 07:50:51 +0000 Subject: [PATCH] - Farrow is a Processor::Block git-svn-id: http://moon:8086/svn/software/trunk/libsrc/cpp@1012 b431acfa-c32f-4a4a-93f1-934dc6c82436 --- radio/interpolation/Farrow.hpp | 57 +++++++++++++++++----------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/radio/interpolation/Farrow.hpp b/radio/interpolation/Farrow.hpp index 6943d61..c5489ca 100644 --- a/radio/interpolation/Farrow.hpp +++ b/radio/interpolation/Farrow.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -22,7 +23,7 @@ namespace Interpolation // [unknown date], Fred Harris, Signal Processing ChairCommunication Systems and Signal Processing Institute // College of Engineering, San Diego State University, San Diego, CA 92182-0190 USA // -------------------------------------------------------------- -class Farrow +class Farrow : public Processor::Block { typedef struct _ml_farrow_coef_hdr_t { @@ -31,8 +32,10 @@ class Farrow } ml_farrow_coef_hdr_t; public: - Farrow(uint32_t M=0, uint32_t N=0) - : m_fir(N) + Farrow(TimingGenerator &timingGenerator, uint32_t M=0, uint32_t N=0) + : Processor::Block(1, 1) + , m_timingGenerator(timingGenerator) + , m_fir(N) , m_M(M) , m_N(N) , m_w(0) @@ -40,8 +43,7 @@ public: , m_coeff(N, M) , m_b(M) , m_h(M) - , m_bufferIn(8*1024) - , m_bufferOut(8*1024) + , m_buf_in(8*1024) { init(M, N); } @@ -59,35 +61,38 @@ public: m_coeff.resize(N, M); m_b.resize(M); m_h.resize(M); -// m_bufferIn.fill(ComplexScalar(0,0)); -// m_bufferOut.fill(ComplexScalar(0,0)); +// m_buf_in.fill(ComplexScalar(0,0)); } size_t feed(CVec const &x, uint32_t size=1) { - return m_bufferIn.write(x.data(), size); + return m_buf_in.write(x.data(), size); } size_t feed(ComplexScalar const *x, uint32_t size=1) { - return m_bufferIn.write(x, size); + return m_buf_in.write(x, size); } - void process(TimingGenerator &timingGenerator) + void process() { - while(true) - { - size_t adv = timingGenerator.getAdv(); - radio_float_t mu = timingGenerator.getMu(); + // Get output buffer + auto buf_out = dynamic_cast*>(buffer_out()); - if (m_bufferIn.len() < adv) + // Process input + while(buf_out->free()) + { + size_t adv = m_timingGenerator.getAdv(); + radio_float_t mu = m_timingGenerator.getMu(); + + if (m_buf_in.len() < adv) { break; } if (adv != 0) { - m_fir.feed(m_bufferIn, adv); + m_fir.feed(m_buf_in, adv); // Partial filter responses for (int i=0; i < m_M; i++) @@ -95,12 +100,13 @@ public: m_h[i] = m_fir.processReal(column(m_coeff, i)); } } + // Combine ComplexScalar yout = horner(mu); - m_bufferOut.write(&yout, 1); - - timingGenerator.process(yout); + buf_out->write(&yout, 1); + // Process timing generator + m_timingGenerator.process(yout); } } @@ -146,17 +152,13 @@ public: } - Processor::Buffer& getInputBuffer() + Processor::IBuffer* buffer_in(size_t index=0) override { - return m_bufferIn; + return &m_buf_in; } - Processor::Buffer& getOutputBuffer() - { - return m_bufferOut; - } - private: + TimingGenerator &m_timingGenerator; FirComplex m_fir; uint32_t m_M; uint32_t m_N; @@ -165,8 +167,7 @@ private: RMat m_coeff; CVec m_b; CVec m_h; - Processor::Buffer m_bufferIn; - Processor::Buffer m_bufferOut; + Processor::Buffer m_buf_in; ComplexScalar horner(RealScalar mu) {