This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Vadim Yanitskiy gerrit-no-reply at lists.osmocom.orgHello Harald Welte, Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/829
to look at the new patch set (#7).
utils/conv_gen.py: improve output formatting
To keep the generated tables readable, line with should be limited.
So, now there are the following limitations:
- _print_term(): up to 12 numbers per line,
- _print_puncture(): up to 12 numbers per line,
- _print_x(): up to 4 blocks per line.
Change-Id: I95256c4ad402a3c088bdb6c5a5cda8b17c31881c
---
M src/gsm/Makefile.am
M utils/conv_gen.py
2 files changed, 34 insertions(+), 5 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/29/829/7
diff --git a/src/gsm/Makefile.am b/src/gsm/Makefile.am
index d60e60e..3877f78 100644
--- a/src/gsm/Makefile.am
+++ b/src/gsm/Makefile.am
@@ -35,3 +35,5 @@
# Convolutional codes generation
gsm0503_conv.c:
$(AM_V_GEN)python2 $(top_srcdir)/utils/conv_gen.py
+
+CLEANFILES = gsm0503_conv.c
diff --git a/utils/conv_gen.py b/utils/conv_gen.py
index 38ea63b..4b42378 100644
--- a/utils/conv_gen.py
+++ b/utils/conv_gen.py
@@ -129,17 +129,23 @@
return ns, nb
def _print_term(self, fi, num_states, pack = False):
+ items = []
d = []
+
for state in range(num_states):
if pack:
x = pack(self.next_term_output(state))
else:
x = self.next_term_state(state)
- d.append("%d, " % x)
- print >>fi, "\t%s" % ''.join(d)
+ items.append(x)
+
+ # Up to 12 numbers should be placed per line
+ print_formatted(items, "%3d, ", 12, fi)
def _print_x(self, fi, num_states, pack = False):
+ items = []
+
for state in range(num_states):
if pack:
x0 = pack(self.next_output(state, 0))
@@ -148,7 +154,14 @@
x0 = self.next_state(state, 0)
x1 = self.next_state(state, 1)
- print >>fi, "\t{ %2d, %2d }," % (x0, x1)
+ items.append((x0, x1))
+
+ # Up to 4 blocks should be placed per line
+ print_formatted(items, "{ %2d, %2d }, ", 4, fi)
+
+ def _print_puncture(self, fi):
+ # Up to 12 numbers should be placed per line
+ print_formatted(self.puncture, "%3d, ", 12, fi)
def gen_tables(self, pref, fi):
pack = lambda n: \
@@ -175,8 +188,7 @@
if len(self.puncture):
print >>fi, "\nstatic const int %s_puncture[] = {" % self.name
- for p in self.puncture:
- print >>fi, "\t%d," % p
+ self._print_puncture(fi)
print >>fi, "};"
# Write description as a multi-line comment
@@ -207,6 +219,21 @@
fn_xor = lambda x, y: x ^ y
return reduce(fn_xor, [(x >> n) & 1 for n in range(nb)])
+def print_formatted(items, format, count, fi):
+ counter = 0
+
+ # Print initial indent
+ fi.write("\t")
+
+ for item in items:
+ if counter > 0 and counter % count == 0:
+ fi.write("\n\t")
+
+ fi.write(format % item)
+ counter += 1
+
+ fi.write("\n")
+
# Polynomials according to 3GPP TS 05.03 Annex B
G0 = poly(0, 3, 4)
G1 = poly(0, 1, 3, 4)
--
To view, visit https://gerrit.osmocom.org/829
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I95256c4ad402a3c088bdb6c5a5cda8b17c31881c
Gerrit-PatchSet: 7
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>