diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2024-11-22 15:46:27 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2024-11-22 15:46:27 +0100 |
commit | d45cca6f447c9a72bc9eaeb9d861fa6fcff9e597 (patch) | |
tree | 0c21382f22bf3c9696915a69317048df63c432ac /src | |
parent | 8cabf783285d4bba1c87152f1c8044160dca8fe1 (diff) | |
download | dabmod-d45cca6f447c9a72bc9eaeb9d861fa6fcff9e597.tar.gz dabmod-d45cca6f447c9a72bc9eaeb9d861fa6fcff9e597.tar.bz2 dabmod-d45cca6f447c9a72bc9eaeb9d861fa6fcff9e597.zip |
Remove FFT accelerator config
Diffstat (limited to 'src')
-rw-r--r-- | src/OfdmGenerator.cpp | 140 | ||||
-rw-r--r-- | src/OfdmGenerator.h | 11 |
2 files changed, 17 insertions, 134 deletions
diff --git a/src/OfdmGenerator.cpp b/src/OfdmGenerator.cpp index 558ec1b..38648c9 100644 --- a/src/OfdmGenerator.cpp +++ b/src/OfdmGenerator.cpp @@ -579,150 +579,30 @@ int OfdmGeneratorFixed::process(Buffer* const dataIn, Buffer* dataOut) } #ifdef HAVE_DEXTER -#include <gpiod.h> - -#define CHIP_PATH "/dev/gpiochip0" -#define LINE_FWD_INV 0 -#define LINE_CONFIG_TDATA_VALID 31 - -// GPIO mapping on write: -// bit 31 config_tdata_tvalid -// bit 30 resets the latches in the xfft_wrapper -// bits 15..0 are 1:1 xfft `config_tdata` -// `GPIO[0] = FWD_INV` according to Vivado - -static struct gpiod_line_request * -request_output_lines(const char *chip_path, const unsigned int *offsets, - enum gpiod_line_value *values, unsigned int num_lines, - const char *consumer) -{ - struct gpiod_request_config *rconfig = NULL; - struct gpiod_line_request *request = NULL; - struct gpiod_line_settings *settings; - struct gpiod_line_config *lconfig; - struct gpiod_chip *chip; - unsigned int i; - int ret; - - chip = gpiod_chip_open(chip_path); - if (!chip) - return NULL; - - settings = gpiod_line_settings_new(); - if (!settings) - goto close_chip; - - gpiod_line_settings_set_direction(settings, - GPIOD_LINE_DIRECTION_OUTPUT); - - lconfig = gpiod_line_config_new(); - if (!lconfig) - goto free_settings; - - for (i = 0; i < num_lines; i++) { - ret = gpiod_line_config_add_line_settings(lconfig, &offsets[i], - 1, settings); - if (ret) - goto free_line_config; - } - gpiod_line_config_set_output_values(lconfig, values, num_lines); - - if (consumer) { - rconfig = gpiod_request_config_new(); - if (!rconfig) - goto free_line_config; - - gpiod_request_config_set_consumer(rconfig, consumer); - } - - request = gpiod_chip_request_lines(chip, rconfig, lconfig); - - gpiod_request_config_free(rconfig); - -free_line_config: - gpiod_line_config_free(lconfig); - -free_settings: - gpiod_line_settings_free(settings); - -close_chip: - gpiod_chip_close(chip); - - return request; -} - -// The GPIO is connected to the config AXI bus of the xfft block. -// 15..0 is the config data; 31 is tvalid -void set_fft_accelerator_config(bool inverse) -{ - constexpr size_t NUM_LINES = 2; - unsigned int line_offsets[NUM_LINES]; - enum gpiod_line_value values[NUM_LINES]; - - line_offsets[0] = LINE_CONFIG_TDATA_VALID; - values[0] = GPIOD_LINE_VALUE_INACTIVE; - - line_offsets[1] = LINE_FWD_INV; - values[1] = inverse ? GPIOD_LINE_VALUE_INACTIVE : GPIOD_LINE_VALUE_ACTIVE; - - struct gpiod_line_request *request; - - request = request_output_lines(CHIP_PATH, line_offsets, values, NUM_LINES, "fft-config"); - if (!request) { - fprintf(stderr, "failed to request line: %s\n", strerror(errno)); - throw std::runtime_error("Request GPIO lines error"); - } - - usleep(100000); - - values[0] = GPIOD_LINE_VALUE_ACTIVE; - gpiod_line_request_set_values(request, values); - - usleep(100000); - - values[0] = GPIOD_LINE_VALUE_INACTIVE; - gpiod_line_request_set_values(request, values); - - gpiod_line_request_release(request); -} - - OfdmGeneratorDEXTER::OfdmGeneratorDEXTER(size_t nbSymbols, size_t nbCarriers, - size_t spacing, - bool inverse) : + size_t spacing) : ModCodec(), myNbSymbols(nbSymbols), myNbCarriers(nbCarriers), mySpacing(spacing) { - PDEBUG("OfdmGeneratorDEXTER::OfdmGeneratorDEXTER(%zu, %zu, %zu, %s) @ %p\n", - nbSymbols, nbCarriers, spacing, inverse ? "true" : "false", this); + PDEBUG("OfdmGeneratorDEXTER::OfdmGeneratorDEXTER(%zu, %zu, %zu) @ %p\n", + nbSymbols, nbCarriers, spacing, this); etiLog.level(info) << "Using DEXTER FFT Accelerator for fixed-point transform"; - set_fft_accelerator_config(inverse); - if (nbCarriers > spacing) { throw std::runtime_error("OfdmGenerator nbCarriers > spacing!"); } - if (inverse) { - myPosDst = (nbCarriers & 1 ? 0 : 1); - myPosSrc = 0; - myPosSize = (nbCarriers + 1) / 2; - myNegDst = spacing - (nbCarriers / 2); - myNegSrc = (nbCarriers + 1) / 2; - myNegSize = nbCarriers / 2; - } - else { - myPosDst = (nbCarriers & 1 ? 0 : 1); - myPosSrc = nbCarriers / 2; - myPosSize = (nbCarriers + 1) / 2; - myNegDst = spacing - (nbCarriers / 2); - myNegSrc = 0; - myNegSize = nbCarriers / 2; - } + myPosDst = (nbCarriers & 1 ? 0 : 1); + myPosSrc = 0; + myPosSize = (nbCarriers + 1) / 2; + myNegDst = spacing - (nbCarriers / 2); + myNegSrc = (nbCarriers + 1) / 2; + myNegSize = nbCarriers / 2; + myZeroDst = myPosDst + myPosSize; myZeroSize = myNegDst - myZeroDst; diff --git a/src/OfdmGenerator.h b/src/OfdmGenerator.h index 56e3cb2..475b2a4 100644 --- a/src/OfdmGenerator.h +++ b/src/OfdmGenerator.h @@ -35,9 +35,13 @@ #include "PAPRStats.h" #include "kiss_fft.h" -#include <fftw3.h> #include <cstddef> #include <atomic> +#include <fftw3.h> + +#ifdef HAVE_DEXTER +# include <iio.h> +#endif // Complex Float uses FFTW class OfdmGeneratorCF32 : public ModCodec, public RemoteControllable @@ -139,15 +143,14 @@ class OfdmGeneratorFixed : public ModCodec }; #ifdef HAVE_DEXTER -#include "iio.h" // The PrecisionWave DEXTER device contains an FFT accelerator in FPGA +// It only does inverse FFTs class OfdmGeneratorDEXTER : public ModCodec { public: OfdmGeneratorDEXTER(size_t nbSymbols, size_t nbCarriers, - size_t spacing, - bool inverse = true); + size_t spacing); virtual ~OfdmGeneratorDEXTER(); OfdmGeneratorDEXTER(const OfdmGeneratorDEXTER&) = delete; OfdmGeneratorDEXTER& operator=(const OfdmGeneratorDEXTER&) = delete; |