diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-10-29 22:09:13 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-10-29 22:09:13 +0200 |
commit | e7ad2e1fab9c51189fdc8b4f2d81f625da9dd422 (patch) | |
tree | eba50066116cb21fae751f7d7b2a9c10c05e2585 /src/prbs.h | |
parent | 471e7ee279d633a7b48e73ece42677574a74ad39 (diff) | |
download | dabmux-e7ad2e1fab9c51189fdc8b4f2d81f625da9dd422.tar.gz dabmux-e7ad2e1fab9c51189fdc8b4f2d81f625da9dd422.tar.bz2 dabmux-e7ad2e1fab9c51189fdc8b4f2d81f625da9dd422.zip |
Modernise PRBS generator and remove code for cmd line parser
Diffstat (limited to 'src/prbs.h')
-rw-r--r-- | src/prbs.h | 74 |
1 files changed, 42 insertions, 32 deletions
@@ -19,43 +19,53 @@ along with ODR-DabMux. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef _PRBS -#define _PRBS +#pragma once + +#include <stdint.h> +#include <stdlib.h> #ifdef HAVE_CONFIG_H # include "config.h" #endif +class PrbsGenerator { + public: + void setup(long polynomial); -#ifdef __cplusplus -extern "C" { // } -#endif + uint8_t step(void); -typedef struct { - // table of matrix products used to update a 32-bit PRBS generator - unsigned long prbs_table [4] [256]; - // table of weights for 8-bit bytes - unsigned char weight[256]; - // PRBS polynomial generator - unsigned long polynomial; - // PRBS generator polarity mask - unsigned char polarity_mask; - // PRBS accumulator - unsigned long accum; -} prbs_data; - - -unsigned long parity_check(unsigned long prbs_accum); -void gen_prbs_table(void* args); -unsigned long update_prbs(void* args); -void gen_weight_table(void* args); -unsigned long error_count(void* args, unsigned char *rx_data, - int rx_data_length); -void gen_sequence(void* args, unsigned char *tx_data, int tx_data_length, - unsigned long polynomial); - -#ifdef __cplusplus -} -#endif + void rewind(void); + + private: + /* Generate a table of matrix products to update a 32-bit PRBS + * generator. */ + void gen_prbs_table(void); + + /* Update a 32-bit PRBS generator eight bits at a time. */ + unsigned long update_prbs(void); + + /* Generate the weight table. */ + void gen_weight_table(void); + + /* Count the number of errors in a block of received data. */ + size_t error_count( + unsigned char *rx_data, + int rx_data_length); + + void gen_sequence( + unsigned char *tx_data, + int tx_data_length, + unsigned long polynomial); + + // table of matrix products used to update a 32-bit PRBS generator + unsigned long prbs_table [4] [256]; + // table of weights for 8-bit bytes + unsigned char weight[256]; + // PRBS polynomial generator + unsigned long polynomial; + // PRBS generator polarity mask + unsigned char polarity_mask; + // PRBS accumulator + unsigned long accum; +}; -#endif // _PRBS |