[PATCH 1/2] Add concolutional code generator for *CCH
From: Max <msuraev@sysmocom.de> Move convolutional code for *CCH channels from test to public API because it's useful not only for testing. --- include/Makefile.am | 1 + include/osmocom/core/conv.h | 2 +- include/osmocom/core/conv_gen.h | 46 +++++++++++++++++++++++++++++++ src/Makefile.am | 4 +-- src/conv_xcch_gen.c | 61 +++++++++++++++++++++++++++++++++++++++++ tests/conv/conv_test.c | 31 ++------------------- 6 files changed, 114 insertions(+), 31 deletions(-) create mode 100644 include/osmocom/core/conv_gen.h create mode 100644 src/conv_xcch_gen.c diff --git a/include/Makefile.am b/include/Makefile.am index 0e5ed74..7c10a72 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -9,6 +9,7 @@ nobase_include_HEADERS = \ osmocom/core/bitvec.h \ osmocom/core/bitcomp.h \ osmocom/core/conv.h \ + osmocom/core/conv_gen.h \ osmocom/core/crc16.h \ osmocom/core/crc16gen.h \ osmocom/core/crc32gen.h \ diff --git a/include/osmocom/core/conv.h b/include/osmocom/core/conv.h index e7f6bd6..42807fa 100644 --- a/include/osmocom/core/conv.h +++ b/include/osmocom/core/conv.h @@ -139,5 +139,5 @@ int osmo_conv_decode_get_output(struct osmo_conv_decoder *decoder, int osmo_conv_decode(const struct osmo_conv_code *code, const sbit_t *input, ubit_t *output); - +#include <osmocom/core/conv_gen.h> /*! @} */ diff --git a/include/osmocom/core/conv_gen.h b/include/osmocom/core/conv_gen.h new file mode 100644 index 0000000..e4f1b65 --- /dev/null +++ b/include/osmocom/core/conv_gen.h @@ -0,0 +1,46 @@ +/* + * conv_gen.h + * + * Copyright (C) 2016 sysmocom s.f.m.c. GmbH + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#pragma once + +extern const uint8_t osmo_conv_gsm0503_xcch_output[][2]; +extern const uint8_t osmo_conv_gsm0503_xcch_state[][2]; + +/*! \file conv_gen.h + * Osmocom convolutional encoder/decoder for xCCH channels, see 3GPP TS 05.03 + */ + +/*! \brief structure describing convolutional code xCCH + * + * Non-recursive code, flushed, not punctured code. + * Generator polynomials: + * G0 = 1 + D3 + D4 + * G1 = 1 + D + D3 + D4 + */ +static const struct osmo_conv_code osmo_conv_gsm0503_xcch = { + .N = 2, + .K = 5, + .len = 224, + .term = CONV_TERM_FLUSH, + .next_output = osmo_conv_gsm0503_xcch_output, + .next_state = osmo_conv_gsm0503_xcch_state, +}; diff --git a/src/Makefile.am b/src/Makefile.am index 45a77e3..2555ff8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -10,14 +10,14 @@ lib_LTLIBRARIES = libosmocore.la libosmocore_la_LIBADD = $(BACKTRACE_LIB) $(TALLOC_LIBS) libosmocore_la_SOURCES = timer.c select.c signal.c msgb.c bits.c \ bitvec.c bitcomp.c statistics.c \ - write_queue.c utils.c socket.c \ + conv_xcch_gen.c write_queue.c utils.c socket.c \ logging.c logging_syslog.c rate_ctr.c \ gsmtap_util.c crc16.c panic.c backtrace.c \ conv.c application.c rbtree.c strrb.c \ loggingrb.c crc8gen.c crc16gen.c crc32gen.c crc64gen.c \ macaddr.c stat_item.c stats.c stats_statsd.c prim.c -BUILT_SOURCES = crc8gen.c crc16gen.c crc32gen.c crc64gen.c +BUILT_SOURCES = crc8gen.c crc16gen.c crc32gen.c crc64gen.c conv_xcch_gen.c if ENABLE_PLUGIN libosmocore_la_SOURCES += plugin.c diff --git a/src/conv_xcch_gen.c b/src/conv_xcch_gen.c new file mode 100644 index 0000000..b948e7b --- /dev/null +++ b/src/conv_xcch_gen.c @@ -0,0 +1,61 @@ +/* + * conv_xcch_gen.c + * + * Copyright (C) 2016 sysmocom s.f.m.c. GmbH + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include <stdint.h> + +const uint8_t osmo_conv_gsm0503_xcch_output[][2] = { + { 0, 3 }, + { 3, 0 }, + { 3, 0 }, + { 0, 3 }, + { 0, 3 }, + { 3, 0 }, + { 3, 0 }, + { 0, 3 }, + { 1, 2 }, + { 2, 1 }, + { 2, 1 }, + { 1, 2 }, + { 1, 2 }, + { 2, 1 }, + { 2, 1 }, + { 1, 2 }, +}; + +const uint8_t osmo_conv_gsm0503_xcch_state[][2] = { + { 0, 8 }, + { 0, 8 }, + { 1, 9 }, + { 1, 9 }, + { 2, 10 }, + { 2, 10 }, + { 3, 11 }, + { 3, 11 }, + { 4, 12 }, + { 4, 12 }, + { 5, 13 }, + { 5, 13 }, + { 6, 14 }, + { 6, 14 }, + { 7, 15 }, + { 7, 15 }, +}; diff --git a/tests/conv/conv_test.c b/tests/conv/conv_test.c index de62f23..baebdbe 100644 --- a/tests/conv/conv_test.c +++ b/tests/conv/conv_test.c @@ -15,31 +15,6 @@ /* Test codes */ /* ------------------------------------------------------------------------ */ -/* GSM xCCH -> Non-recursive code, flushed, not punctured */ -static const uint8_t conv_gsm_xcch_next_output[][2] = { - { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, - { 3, 0 }, { 2, 1 }, { 3, 0 }, { 2, 1 }, - { 3, 0 }, { 2, 1 }, { 3, 0 }, { 2, 1 }, - { 0, 3 }, { 1, 2 }, { 0, 3 }, { 1, 2 }, -}; - -static const uint8_t conv_gsm_xcch_next_state[][2] = { - { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 }, - { 8, 9 }, { 10, 11 }, { 12, 13 }, { 14, 15 }, - { 0, 1 }, { 2, 3 }, { 4, 5 }, { 6, 7 }, - { 8, 9 }, { 10, 11 }, { 12, 13 }, { 14, 15 }, -}; - -static const struct osmo_conv_code conv_gsm_xcch = { - .N = 2, - .K = 5, - .len = 224, - .term = CONV_TERM_FLUSH, - .next_output = conv_gsm_xcch_next_output, - .next_state = conv_gsm_xcch_next_state, -}; - - /* GSM TCH/AFS 7.95 -> Recursive code, flushed, with puncturing */ static const uint8_t conv_gsm_tch_afs_7_95_next_output[][2] = { { 0, 7 }, { 3, 4 }, { 2, 5 }, { 1, 6 }, @@ -227,8 +202,8 @@ static const struct osmo_conv_code conv_trunc = { .K = 5, .len = 224, .term = CONV_TERM_TRUNCATION, - .next_output = conv_gsm_xcch_next_output, - .next_state = conv_gsm_xcch_next_state, + .next_output = osmo_conv_gsm0503_xcch_output, + .next_state = osmo_conv_gsm0503_xcch_state, }; @@ -249,7 +224,7 @@ struct conv_test_vector { static const struct conv_test_vector tests[] = { { .name = "GSM xCCH (non-recursive, flushed, not punctured)", - .code = &conv_gsm_xcch, + .code = &osmo_conv_gsm0503_xcch, .in_len = 224, .out_len = 456, .has_vec = 1, -- 2.8.1
From: Max <msuraev@sysmocom.de> --- include/osmocom/core/conv_gen.h | 26 ++++++++++++++++++++ src/Makefile.am | 2 +- src/conv_csx_gen.c | 53 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 src/conv_csx_gen.c diff --git a/include/osmocom/core/conv_gen.h b/include/osmocom/core/conv_gen.h index e4f1b65..eb8668e 100644 --- a/include/osmocom/core/conv_gen.h +++ b/include/osmocom/core/conv_gen.h @@ -44,3 +44,29 @@ static const struct osmo_conv_code osmo_conv_gsm0503_xcch = { .next_output = osmo_conv_gsm0503_xcch_output, .next_state = osmo_conv_gsm0503_xcch_state, }; + +extern const int osmo_conv_gsm0503_cs2_puncture[]; + +/*! \brief structure describing convolutional code CS2 + */ +static const struct osmo_conv_code osmo_conv_gsm0503_cs2 = { + .N = 2, + .K = 5, + .len = 290, + .next_output = osmo_conv_gsm0503_xcch_output, + .next_state = osmo_conv_gsm0503_xcch_state, + .puncture = osmo_conv_gsm0503_cs2_puncture +}; + +extern const int osmo_conv_gsm0503_cs3_puncture[]; + +/*! \brief structure describing convolutional code CS2 + */ +static const struct osmo_conv_code osmo_conv_gsm0503_cs3 = { + .N = 2, + .K = 5, + .len = 334, + .next_output = osmo_conv_gsm0503_xcch_output, + .next_state = osmo_conv_gsm0503_xcch_state, + .puncture = osmo_conv_gsm0503_cs3_puncture +}; diff --git a/src/Makefile.am b/src/Makefile.am index 2555ff8..fceb931 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,7 +13,7 @@ libosmocore_la_SOURCES = timer.c select.c signal.c msgb.c bits.c \ conv_xcch_gen.c write_queue.c utils.c socket.c \ logging.c logging_syslog.c rate_ctr.c \ gsmtap_util.c crc16.c panic.c backtrace.c \ - conv.c application.c rbtree.c strrb.c \ + conv.c application.c conv_csx_gen.c rbtree.c strrb.c \ loggingrb.c crc8gen.c crc16gen.c crc32gen.c crc64gen.c \ macaddr.c stat_item.c stats.c stats_statsd.c prim.c diff --git a/src/conv_csx_gen.c b/src/conv_csx_gen.c new file mode 100644 index 0000000..a1ef7a8 --- /dev/null +++ b/src/conv_csx_gen.c @@ -0,0 +1,53 @@ +/* + * conv_xcch_gen.c + * + * Copyright (C) 2016 sysmocom s.f.m.c. GmbH + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +const int osmo_conv_gsm0503_cs2_puncture[] = { + 15, 19, 23, 27, 31, 35, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79, 83, 91, + 95, 99, 103, 107, 111, 115, 119, 123, 127, 131, 139, 143, 147, 151, 155, + 159, 163, 167, 171, 175, 179, 187, 191, 195, 199, 203, 207, 211, 215, + 219, 223, 227, 235, 239, 243, 247, 251, 255, 259, 263, 267, 271, 275, + 283, 287, 291, 295, 299, 303, 307, 311, 315, 319, 323, 331, 335, 339, + 343, 347, 351, 355, 359, 363, 367, 371, 379, 383, 387, 391, 395, 399, + 403, 407, 411, 415, 419, 427, 431, 435, 439, 443, 447, 451, 455, 459, + 463, 467, 475, 479, 483, 487, 491, 495, 499, 503, 507, 511, 515, 523, + 527, 531, 535, 539, 543, 547, 551, 555, 559, 563, 571, 575, 579, 583, + 587, -1 +}; + +const int osmo_conv_gsm0503_cs3_puncture[] = { + 15, 17, 21, 23, 27, 29, 33, 35, 39, 41, 45, 47, 51, 53, 57, 59, 63, 65, + 69, 71, 75, 77, 81, 83, 87, 89, 93, 95, 99, 101, 105, 107, 111, 113, + 117, 119, 123, 125, 129, 131, 135, 137, 141, 143, 147, 149, 153, 155, + 159, 161, 165, 167, 171, 173, 177, 179, 183, 185, 189, 191, 195, 197, + 201, 203, 207, 209, 213, 215, 219, 221, 225, 227, 231, 233, 237, 239, + 243, 245, 249, 251, 255, 257, 261, 263, 267, 269, 273, 275, 279, 281, + 285, 287, 291, 293, 297, 299, 303, 305, 309, 311, 315, 317, 321, 323, + 327, 329, 333, 335, 339, 341, 345, 347, 351, 353, 357, 359, 363, 365, + 369, 371, 375, 377, 381, 383, 387, 389, 393, 395, 399, 401, 405, 407, + 411, 413, 417, 419, 423, 425, 429, 431, 435, 437, 441, 443, 447, 449, + 453, 455, 459, 461, 465, 467, 471, 473, 477, 479, 483, 485, 489, 491, + 495, 497, 501, 503, 507, 509, 513, 515, 519, 521, 525, 527, 531, 533, + 537, 539, 543, 545, 549, 551, 555, 557, 561, 563, 567, 569, 573, 575, + 579, 581, 585, 587, 591, 593, 597, 599, 603, 605, 609, 611, 615, 617, + 621, 623, 627, 629, 633, 635, 639, 641, 645, 647, 651, 653, 657, 659, + 663, 665, 669, 671, -1 +}; -- 2.8.1
On Wed, Apr 6, 2016 at 1:05 PM, <msuraev@sysmocom.de> wrote:
From: Max <msuraev@sysmocom.de>
Move convolutional code for *CCH channels from test to public API because it's useful not only for testing.
Those code are for GSM, I'd say they need to go in libosmogsm. Cheers, Sylvain
participants (2)
-
msuraev@sysmocom.de -
Sylvain Munaut