summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-06-18 18:16:02 +0300
committerHarald Welte <laforge@gnumonks.org>2017-07-10 23:42:02 +0200
commit1389e86d116509884b0e5ee3421fe7683afcab9b (patch)
tree52ef42f5f49ac3ae52e687cbc7207426fd11e075 /include
parent548e3712009f68f801be806884d848b47c30dced (diff)
Add pseudo-random bit sequence generator to libosmcoore
These PRBS sequences are specified in ITU-T O.150. They are typically used as test data to be transmitted for BER (bit error rate) testing. Change-Id: I227b6a6e86a251460ecb816afa9a7439d5fb94d1
Diffstat (limited to 'include')
-rw-r--r--include/Makefile.am1
-rw-r--r--include/osmocom/core/prbs.h25
2 files changed, 26 insertions, 0 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
index e0c1a2bd..4e92d553 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -31,6 +31,7 @@ nobase_include_HEADERS = \
osmocom/core/macaddr.h \
osmocom/core/msgb.h \
osmocom/core/panic.h \
+ osmocom/core/prbs.h \
osmocom/core/prim.h \
osmocom/core/process.h \
osmocom/core/rate_ctr.h \
diff --git a/include/osmocom/core/prbs.h b/include/osmocom/core/prbs.h
new file mode 100644
index 00000000..aaca17d9
--- /dev/null
+++ b/include/osmocom/core/prbs.h
@@ -0,0 +1,25 @@
+#pragma once
+#include <stdint.h>
+#include <osmocom/core/bits.h>
+
+/*! \brief definition of a PRBS sequence */
+struct osmo_prbs {
+ const char *name; /*!< human-readable name */
+ unsigned int len; /*!< length in bits */
+ uint64_t coeff; /*!< coefficients */
+};
+
+/*! \brief state of a given PRBS sequence generator */
+struct osmo_prbs_state {
+ const struct osmo_prbs *prbs;
+ uint64_t state;
+};
+
+extern const struct osmo_prbs osmo_prbs7;
+extern const struct osmo_prbs osmo_prbs9;
+extern const struct osmo_prbs osmo_prbs11;
+extern const struct osmo_prbs osmo_prbs15;
+
+void osmo_prbs_state_init(struct osmo_prbs_state *st, const struct osmo_prbs *prbs);
+ubit_t osmo_prbs_get_ubit(struct osmo_prbs_state *state);
+int osmo_prbs_get_ubits(ubit_t *out, unsigned int out_len, struct osmo_prbs_state *state);