mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-09-12 08:06:34 -04:00
27 lines
439 B
C++
27 lines
439 B
C++
// Copyright 2020 modemm17 LLC.
|
|
|
|
#pragma once
|
|
|
|
#include <bit>
|
|
#include <cstdint>
|
|
#include <cstddef>
|
|
|
|
#include "Util.h"
|
|
|
|
namespace modemm17
|
|
{
|
|
|
|
inline constexpr uint32_t convolve_bit(uint32_t poly, uint32_t memory)
|
|
{
|
|
return popcount(poly & memory) & 1;
|
|
}
|
|
|
|
template <size_t K, size_t k = 1>
|
|
inline constexpr uint32_t update_memory(uint32_t memory, uint32_t input)
|
|
{
|
|
return (memory << k | input) & ((1 << (K + 1)) - 1);
|
|
}
|
|
|
|
|
|
} // modemm17
|