Skip to content

Commit

Permalink
improve performance by a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
marenz2569 committed Jan 25, 2024
1 parent feba058 commit 5c9bed1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 26 deletions.
4 changes: 4 additions & 0 deletions include/fixed_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ template <typename T, int MaxLen, typename Container = std::deque<T>> class Fixe
Container queue{};

public:
using const_iterator = typename Container::const_iterator;
using const_reverse_iterator = typename Container::const_reverse_iterator;
using const_reference = typename Container::const_reference;

FixedQueue() {
for (auto i = 0; i < MaxLen; i++) {
T default_value{};
Expand Down
4 changes: 3 additions & 1 deletion include/iq_stream_decoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class IQStreamDecoder {
void upperMacWorker();

std::complex<float> hard_decision(std::complex<float> symbol);
std::vector<uint8_t> symbols_to_bitstream(std::vector<std::complex<float>> const& stream);

template <class iterator_type>
static void symbols_to_bitstream(iterator_type it, std::vector<uint8_t>& bits, std::size_t len);

void abs_convolve_same_length(const QueueT& queueA, const std::size_t offsetA, const std::complex<float>* itb,
const std::size_t len, float* res);
Expand Down
52 changes: 27 additions & 25 deletions src/iq_stream_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ std::complex<float> IQStreamDecoder::hard_decision(std::complex<float> symbol) {
}
}

std::vector<uint8_t> IQStreamDecoder::symbols_to_bitstream(std::vector<std::complex<float>> const& stream) {
std::vector<uint8_t> bits;

for (auto it = stream.begin(); it != stream.end(); it++) {
template <class iterator_type>
void IQStreamDecoder::symbols_to_bitstream(iterator_type it, std::vector<uint8_t>& bits, std::size_t len) {
for (auto i = 0; i < len; ++it, ++i) {

auto real = it->real();
auto imag = it->imag();
Expand All @@ -97,8 +96,6 @@ std::vector<uint8_t> IQStreamDecoder::symbols_to_bitstream(std::vector<std::comp
}
}
}

return bits;
}

void IQStreamDecoder::abs_convolve_same_length(const QueueT& queueA, const std::size_t offsetA,
Expand Down Expand Up @@ -143,43 +140,48 @@ void IQStreamDecoder::process_complex(std::complex<float> symbol) noexcept {
abs_convolve_same_length(symbol_buffer_hard_decision_, 44, training_seq_x_reversed_conj_.data(),
training_seq_x_reversed_conj_.size(), &detectedX);

// use actual signal for further processing
auto start = symbol_buffer_.cbegin();

if (detectedX >= SEQUENCE_DETECTION_THRESHOLD) {
// std::cout << "Potential CUB found" << std::endl;

auto end = start;
std::advance(end, 103);
auto len = 103;

std::vector<uint8_t> bits;
bits.reserve(len * 2);

symbols_to_bitstream(symbol_buffer_.cbegin(), bits, len);

auto corrected = channel_estimation({start, end}, training_seq_x_reversed_conj_);
auto bitstream = symbols_to_bitstream(corrected);
threadPool_->queueWork(std::bind(&LowerMac::process, lower_mac_, bitstream, BurstType::ControlUplinkBurst));
threadPool_->queueWork(std::bind(&LowerMac::process, lower_mac_, bits, BurstType::ControlUplinkBurst));
}

if (detectedP >= SEQUENCE_DETECTION_THRESHOLD) {
// std::cout << "Potential NUB_Split found" << std::endl;

auto end = start;
std::advance(end, 231);
auto len = 231;

auto corrected = channel_estimation({start, end}, training_seq_p_reversed_conj_);
threadPool_->queueWork(std::bind(&LowerMac::process, lower_mac_, symbols_to_bitstream(corrected),
BurstType::NormalUplinkBurstSplit));
std::vector<uint8_t> bits;
bits.reserve(len * 2);

symbols_to_bitstream(symbol_buffer_.cbegin(), bits, len);

threadPool_->queueWork(std::bind(&LowerMac::process, lower_mac_, bits, BurstType::NormalUplinkBurstSplit));
}

if (detectedN >= SEQUENCE_DETECTION_THRESHOLD) {
// std::cout << "Potential NUB found" << std::endl;

auto end = start;
std::advance(end, 231);
auto len = 231;

std::vector<uint8_t> bits;
bits.reserve(len * 2);

symbols_to_bitstream(symbol_buffer_.cbegin(), bits, len);

auto corrected = channel_estimation({start, end}, training_seq_n_reversed_conj_);
threadPool_->queueWork(std::bind(&LowerMac::process, lower_mac_, symbols_to_bitstream(corrected),
BurstType::NormalUplinkBurst));
threadPool_->queueWork(std::bind(&LowerMac::process, lower_mac_, bits, BurstType::NormalUplinkBurst));
}
} else {
auto bits = symbols_to_bitstream({symbol});
std::vector<std::complex<float>> stream = {symbol};
std::vector<uint8_t> bits;
symbols_to_bitstream(stream.cbegin(), bits, 1);
for (auto it = bits.begin(); it != bits.end(); ++it) {
bit_stream_decoder_->process_bit(*it);
}
Expand Down

0 comments on commit 5c9bed1

Please sign in to comment.