diff --git a/radio/Makefile b/radio/Makefile index 4964ac1..c2e27da 100644 --- a/radio/Makefile +++ b/radio/Makefile @@ -1,23 +1,30 @@ -include ../config.mk +include ./config.mk -SRCDIR := . -OBJS := real.o cpx.o ringbuf.o equalizer.o interpolation.o agc.o nco.o statistics.o symbol.o synchronization.o Frame.o Symbolizer.o Formatter.o Scrambler.o +NAME := Radio -LIB := $(BUILD_DIR)/libradio.a +CXX_SRCS := $(LIBSRC_PATH)/cpp/radio/Formatter.cpp +CXX_SRCS += $(LIBSRC_PATH)/cpp/radio/Symbolizer.cpp +CXX_SRCS += $(LIBSRC_PATH)/cpp/radio/Scrambler.cpp +CXX_SRCS += $(LIBSRC_PATH)/cpp/radio/Frame.cpp +CXX_SRCS += $(LIBSRC_PATH)/cpp/radio/interpolation/Interpolator.cpp +CXX_SRCS += $(LIBSRC_PATH)/cpp/radio/interpolation/Farrow.cpp +CXX_SRCS += $(LIBSRC_PATH)/cpp/radio/interpolation/PolyPhase.cpp +CXX_SRCS += $(LIBSRC_PATH)/cpp/radio/interpolation/UpSampler.cpp +CXX_SRCS += $(LIBSRC_PATH)/cpp/radio/interpolation/DownSampler.cpp -INCLUDES := . .. -DEFINES := radio_float_t=float fir_float_t=float +GCC_SRCS := $(LIBSRC_PATH)/radio/real.c +GCC_SRCS += $(LIBSRC_PATH)/radio/cpx.c +GCC_SRCS += $(LIBSRC_PATH)/radio/ringbuf.c +GCC_SRCS += $(LIBSRC_PATH)/radio/equalizer.c +GCC_SRCS += $(LIBSRC_PATH)/radio/interpolation.c +GCC_SRCS += $(LIBSRC_PATH)/radio/agc.c +GCC_SRCS += $(LIBSRC_PATH)/radio/nco.c +GCC_SRCS += $(LIBSRC_PATH)/radio/statistics.c +GCC_SRCS += $(LIBSRC_PATH)/radio/symbol.c +GCC_SRCS += $(LIBSRC_PATH)/radio/synchronization.c -all : $(LIB) - -$(LIB) : $(OBJS) - $(AR) -r $(LIB) $(OBJS) - -clean: - rm -f *.o - rm -f *.a - -.PHONY: clean - -include ../compile.mk +INCLUDES += -I $(LIBSRC_PATH) -I $(BLAZE_PATH) +DEFINES += -Dradio_float_t=float -Dfir_float_t=float +CXXFLAGS += -std=c++20 +include $(MAKE_HOME)/compile.mk diff --git a/radio/config.mk b/radio/config.mk new file mode 100644 index 0000000..05d2be2 --- /dev/null +++ b/radio/config.mk @@ -0,0 +1,6 @@ +MAKE_HOME ?= /home/jens/work/software/make +CONFIG ?= debug +BUILD_DIR ?= ./build/${CONFIG} + +LIBSRC_PATH ?= $(realpath ../../../libsrc) +BLAZE_PATH ?= $(realpath ../../../extlib/blaze) diff --git a/radio/interpolation/Farrow.hpp b/radio/interpolation/Farrow.hpp index 0ee09f8..b4a3f3d 100644 --- a/radio/interpolation/Farrow.hpp +++ b/radio/interpolation/Farrow.hpp @@ -5,6 +5,8 @@ #include #include +#include +#include namespace Radio { @@ -37,6 +39,8 @@ public: , m_b(M) , m_h(M) , m_fifo(N) + , m_bufferIn(1024) + , m_bufferOut(1024) { init(M, N); } @@ -56,6 +60,8 @@ public: m_h.resize(M); m_fifo.resize(N); m_fifo = ComplexScalar(0,0); +// m_bufferIn.fill(ComplexScalar(0,0)); +// m_bufferOut.fill(ComplexScalar(0,0)); } void feed(ComplexScalar const &x, uint32_t push) @@ -64,11 +70,60 @@ public: m_fifo[m_w] = x; } + ComplexScalar process(ComplexScalar const &xin, RealScalar dmu) + { + size_t adv = m_interpolator.process(dmu); + m_bufferIn.write(&xin, 1); + + if (adv) + { + ComplexScalar xout; + m_bufferIn.read(&xout, 1); + FirComplex::feed(xout); + } + + + // Partial filter responses + for (int i=0; i < m_M; i++) + { + m_h[i] = FirComplex::processReal(column(m_coeff, i)); + } + + // Combine + ComplexScalar yout = horner(m_interpolator.getMu()); + m_bufferOut.write(&yout, 1); + + return yout; + } + ComplexScalar process(RealScalar mu, uint32_t pop) { uint32_t i, r; int32_t j; + if (pop and m_bufferIn.len() == 0) + { + return ComplexScalar(0,0); + } + + for (int n=0; n < m_bufferIn.len(); n++) + { + ComplexScalar x; + m_bufferIn.read(&x, 1); + FirComplex::feed(x); + + // Partial filter responses + for (i=0; i < m_M; i++) + { + m_h[i] = FirComplex::processReal(column(m_coeff, i)); + } + + // Combine + ComplexScalar y = horner(mu); + m_bufferOut.write(&y, 1); + } + +#if 0 m_r = (m_r + pop) % m_N; if (pop) @@ -85,15 +140,7 @@ public: m_state[j--] = m_fifo[r++]; } } - - // Partial filter responses - for (i=0; i < m_M; i++) - { - m_h[i] = FirComplex::processReal(column(m_coeff, i)); - } - - // Combine - return horner(mu); +#endif } void load(const char *pFilename) @@ -138,6 +185,11 @@ public: } + Processor::Buffer& getOutputBuffer() + { + return m_bufferOut; + } + private: uint32_t m_M; uint32_t m_N; @@ -147,7 +199,10 @@ private: CVec m_b; CVec m_h; CVec m_fifo; - + Processor::Buffer m_bufferIn; + Processor::Buffer m_bufferOut; + Interpolator m_interpolator; + ComplexScalar horner(RealScalar mu) { uint32_t i; @@ -160,7 +215,7 @@ private: return m_b[m_M-1]; } - + }; } // Radio::Interpolation diff --git a/radio/tests/interpolation/farrow/Makefile b/radio/tests/interpolation/farrow/Makefile new file mode 100644 index 0000000..b0a7de5 --- /dev/null +++ b/radio/tests/interpolation/farrow/Makefile @@ -0,0 +1,26 @@ +include ./config.mk + +DEFINES := -Dradio_float_t=float -Dfir_float_t=float +CXXFLAGS_release := -O3 -flto +CFLAGS_release := -O3 -flto +LDFLAGS_release := -O3 -flto +TARGET_ARCH := -march=native +CXXFLAGS += -std=c++20 + +LIBS := -lstdc++ -lm -lpthread -lrt +LDFLAGS += $(TARGET_ARCH) $(LIBDIR) +DEFINES += -DPROCESSOR_BUFFER_USE_EXCEPTIONS +INCLUDES += -I $(BLAZE_PATH) + +all: app +app: objects link + +.PHONY: Radio + +objects: Radio + +Radio: + @$(MAKE) -C $(LIBSRC_PATH)/cpp/radio + + +include $(MAKE_HOME)/link.mk diff --git a/radio/tests/interpolation/farrow/config.mk b/radio/tests/interpolation/farrow/config.mk new file mode 100644 index 0000000..81884d6 --- /dev/null +++ b/radio/tests/interpolation/farrow/config.mk @@ -0,0 +1,10 @@ +MAKE_HOME ?= /home/jens/work/software/make +CONFIG ?= debug +TARGET ?= farrow_test +BUILD_DIR ?= $(shell pwd)/build/${CONFIG} +MAKEFLAGS += --no-print-directory + +LIBSRC_PATH ?= $(realpath ../../../../../../libsrc) +BLAZE_PATH ?= $(realpath ../../../../../../extlib/blaze) + +export \ No newline at end of file diff --git a/radio/tests/interpolation/farrow/main.cpp b/radio/tests/interpolation/farrow/main.cpp new file mode 100644 index 0000000..e6b9bb0 --- /dev/null +++ b/radio/tests/interpolation/farrow/main.cpp @@ -0,0 +1,6 @@ + + +int main() +{ + +} \ No newline at end of file