blob: 1ecb550ad7f032d29f358ff0e4db39f1ec77ea80 [file] [log] [blame]
Holger Hans Peter Freyther3a96d282016-04-29 21:24:48 +02001#!/usr/bin/python2
Harald Welteeea18a62016-04-29 15:18:35 +02002
3mod_license = """
4/*
5 * Copyright (C) 2011-2016 Sylvain Munaut <tnt@246tNt.com>
6 * Copyright (C) 2016 sysmocom s.f.m.c. GmbH
7 *
8 * All Rights Reserved
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 */
24"""
25
26import sys, os, math
Vadim Yanitskiyf9c2c562016-11-01 22:19:28 +070027from functools import reduce
Harald Welteeea18a62016-04-29 15:18:35 +020028
29class ConvolutionalCode(object):
30
Vadim Yanitskiye31cf802016-09-07 21:51:25 +070031 def __init__(self, block_len, polys, name,
Vadim Yanitskiya6b52162016-09-08 22:06:07 +070032 description = None, puncture = [], term_type = None):
Harald Welteeea18a62016-04-29 15:18:35 +020033 # Save simple params
34 self.block_len = block_len
35 self.k = 1
36 self.puncture = puncture
37 self.rate_inv = len(polys)
Vadim Yanitskiya6b52162016-09-08 22:06:07 +070038 self.term_type = term_type
Harald Welteeea18a62016-04-29 15:18:35 +020039
40 # Infos
41 self.name = name
42 self.description = description
43
Vadim Yanitskiy84fc2ce2016-09-08 20:30:36 +070044 # Handle polynomials (and check for recursion)
Harald Welteeea18a62016-04-29 15:18:35 +020045 self.polys = [(1, 1) if x[0] == x[1] else x for x in polys]
46
47 # Determine the polynomial degree
48 for (x, y) in polys:
49 self.k = max(self.k, int(math.floor(math.log(max(x, y), 2))))
50 self.k = self.k + 1
51
52 self.poly_divider = 1
53 rp = [x[1] for x in self.polys if x[1] != 1]
54 if rp:
55 if not all([x == rp[0] for x in rp]):
Vadim Yanitskiy84fc2ce2016-09-08 20:30:36 +070056 raise ValueError("Bad polynomials: "
57 "Can't have multiple different divider polynomials!")
Vadim Yanitskiye31cf802016-09-07 21:51:25 +070058
Harald Welteeea18a62016-04-29 15:18:35 +020059 if not all([x[0] == 1 for x in polys if x[1] == 1]):
Vadim Yanitskiy84fc2ce2016-09-08 20:30:36 +070060 raise ValueError("Bad polynomials: "
Vadim Yanitskiye31cf802016-09-07 21:51:25 +070061 "Can't have a '1' divider with a non '1' dividend "
62 "in a recursive code")
63
Harald Welteeea18a62016-04-29 15:18:35 +020064 self.poly_divider = rp[0]
65
66 @property
67 def recursive(self):
68 return self.poly_divider != 1
69
70 @property
71 def _state_mask(self):
72 return (1 << (self.k - 1)) - 1
73
74 def next_state(self, state, bit):
75 nb = combine(
76 (state << 1) | bit,
77 self.poly_divider,
78 self.k,
79 )
80 return ((state << 1) | nb) & self._state_mask
81
82 def next_term_state(self, state):
83 return (state << 1) & self._state_mask
84
85 def next_output(self, state, bit, ns = None):
86 # Next state bit
87 if ns is None:
88 ns = self.next_state(state, bit)
89
90 src = (ns & 1) | (state << 1)
91
Vadim Yanitskiy84fc2ce2016-09-08 20:30:36 +070092 # Scan polynomials
Harald Welteeea18a62016-04-29 15:18:35 +020093 rv = []
94 for p_n, p_d in self.polys:
95 if self.recursive and p_d == 1:
Vadim Yanitskiye31cf802016-09-07 21:51:25 +070096 # No choice ... (systematic output in recursive case)
97 o = bit
Harald Welteeea18a62016-04-29 15:18:35 +020098 else:
99 o = combine(src, p_n, self.k)
100 rv.append(o)
101
102 return rv
103
104 def next_term_output(self, state, ns = None):
105 # Next state bit
106 if ns is None:
107 ns = self.next_term_state(state)
108
109 src = (ns & 1) | (state << 1)
110
Vadim Yanitskiy84fc2ce2016-09-08 20:30:36 +0700111 # Scan polynomials
Harald Welteeea18a62016-04-29 15:18:35 +0200112 rv = []
113 for p_n, p_d in self.polys:
114 if self.recursive and p_d == 1:
115 # Systematic output are replaced when in 'termination' mode
116 o = combine(src, self.poly_divider, self.k)
117 else:
118 o = combine(src, p_n, self.k)
119 rv.append(o)
120
121 return rv
122
123 def next(self, state, bit):
124 ns = self.next_state(state, bit)
125 nb = self.next_output(state, bit, ns = ns)
126 return ns, nb
127
128 def next_term(self, state):
129 ns = self.next_term_state(state)
130 nb = self.next_term_output(state, ns = ns)
131 return ns, nb
132
Vadim Yanitskiye31cf802016-09-07 21:51:25 +0700133 def _print_term(self, fi, num_states, pack = False):
Vadim Yanitskiy6908fa72016-09-07 22:34:53 +0700134 items = []
135
Harald Welteeea18a62016-04-29 15:18:35 +0200136 for state in range(num_states):
Vadim Yanitskiye31cf802016-09-07 21:51:25 +0700137 if pack:
138 x = pack(self.next_term_output(state))
139 else:
140 x = self.next_term_state(state)
141
Vadim Yanitskiy6908fa72016-09-07 22:34:53 +0700142 items.append(x)
143
144 # Up to 12 numbers should be placed per line
145 print_formatted(items, "%3d, ", 12, fi)
Harald Welteeea18a62016-04-29 15:18:35 +0200146
147 def _print_x(self, fi, num_states, pack = False):
Vadim Yanitskiy6908fa72016-09-07 22:34:53 +0700148 items = []
149
Harald Welteeea18a62016-04-29 15:18:35 +0200150 for state in range(num_states):
Vadim Yanitskiye31cf802016-09-07 21:51:25 +0700151 if pack:
152 x0 = pack(self.next_output(state, 0))
153 x1 = pack(self.next_output(state, 1))
154 else:
155 x0 = self.next_state(state, 0)
156 x1 = self.next_state(state, 1)
157
Vadim Yanitskiy6908fa72016-09-07 22:34:53 +0700158 items.append((x0, x1))
159
160 # Up to 4 blocks should be placed per line
161 print_formatted(items, "{ %2d, %2d }, ", 4, fi)
162
163 def _print_puncture(self, fi):
164 # Up to 12 numbers should be placed per line
165 print_formatted(self.puncture, "%3d, ", 12, fi)
Harald Welteeea18a62016-04-29 15:18:35 +0200166
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700167 def print_state_and_output(self, fi):
Vadim Yanitskiye31cf802016-09-07 21:51:25 +0700168 pack = lambda n: \
169 sum([x << (self.rate_inv - i - 1) for i, x in enumerate(n)])
Harald Welteeea18a62016-04-29 15:18:35 +0200170 num_states = 1 << (self.k - 1)
Vadim Yanitskiye31cf802016-09-07 21:51:25 +0700171
Vadim Yanitskiy45ebc522016-10-27 02:19:37 +0700172 fi.write("static const uint8_t %s_state[][2] = {\n" % self.name)
Harald Welteeea18a62016-04-29 15:18:35 +0200173 self._print_x(fi, num_states)
Vadim Yanitskiy45ebc522016-10-27 02:19:37 +0700174 fi.write("};\n\n")
175
176 fi.write("static const uint8_t %s_output[][2] = {\n" % self.name)
Harald Welteeea18a62016-04-29 15:18:35 +0200177 self._print_x(fi, num_states, pack)
Vadim Yanitskiy45ebc522016-10-27 02:19:37 +0700178 fi.write("};\n\n")
Harald Welteeea18a62016-04-29 15:18:35 +0200179
180 if self.recursive:
Vadim Yanitskiy45ebc522016-10-27 02:19:37 +0700181 fi.write("static const uint8_t %s_term_state[] = {\n" % self.name)
Harald Welteeea18a62016-04-29 15:18:35 +0200182 self._print_term(fi, num_states)
Vadim Yanitskiy45ebc522016-10-27 02:19:37 +0700183 fi.write("};\n\n")
Vadim Yanitskiye31cf802016-09-07 21:51:25 +0700184
Vadim Yanitskiy45ebc522016-10-27 02:19:37 +0700185 fi.write("static const uint8_t %s_term_output[] = {\n" % self.name)
Harald Welteeea18a62016-04-29 15:18:35 +0200186 self._print_term(fi, num_states, pack)
Vadim Yanitskiy45ebc522016-10-27 02:19:37 +0700187 fi.write("};\n\n")
Harald Welteeea18a62016-04-29 15:18:35 +0200188
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700189 def gen_tables(self, pref, fi, shared_tables = None):
190 # Do not print shared tables
191 if shared_tables is None:
192 self.print_state_and_output(fi)
193 table_pref = self.name
194 else:
195 table_pref = shared_tables
196
Harald Welteeea18a62016-04-29 15:18:35 +0200197 if len(self.puncture):
Vadim Yanitskiy45ebc522016-10-27 02:19:37 +0700198 fi.write("static const int %s_puncture[] = {\n" % self.name)
Vadim Yanitskiy6908fa72016-09-07 22:34:53 +0700199 self._print_puncture(fi)
Vadim Yanitskiy45ebc522016-10-27 02:19:37 +0700200 fi.write("};\n\n")
Harald Welteeea18a62016-04-29 15:18:35 +0200201
Vadim Yanitskiye31cf802016-09-07 21:51:25 +0700202 # Write description as a multi-line comment
203 if self.description is not None:
Vadim Yanitskiy45ebc522016-10-27 02:19:37 +0700204 fi.write("/**\n")
Vadim Yanitskiye31cf802016-09-07 21:51:25 +0700205 for line in self.description:
Vadim Yanitskiy45ebc522016-10-27 02:19:37 +0700206 fi.write(" * %s\n" % line)
207 fi.write(" */\n")
Vadim Yanitskiye31cf802016-09-07 21:51:25 +0700208
209 # Print a final convolutional code definition
Vadim Yanitskiy45ebc522016-10-27 02:19:37 +0700210 fi.write("const struct osmo_conv_code %s_%s = {\n" % (pref, self.name))
211 fi.write("\t.N = %d,\n" % self.rate_inv)
212 fi.write("\t.K = %d,\n" % self.k)
213 fi.write("\t.len = %d,\n" % self.block_len)
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700214 fi.write("\t.next_output = %s_output,\n" % table_pref)
215 fi.write("\t.next_state = %s_state,\n" % table_pref)
Vadim Yanitskiy45ebc522016-10-27 02:19:37 +0700216
Vadim Yanitskiya6b52162016-09-08 22:06:07 +0700217 if self.term_type is not None:
Vadim Yanitskiy45ebc522016-10-27 02:19:37 +0700218 fi.write("\t.term = %s,\n" % self.term_type)
219
Harald Welteeea18a62016-04-29 15:18:35 +0200220 if self.recursive:
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700221 fi.write("\t.next_term_output = %s_term_output,\n" % table_pref)
222 fi.write("\t.next_term_state = %s_term_state,\n" % table_pref)
Vadim Yanitskiy45ebc522016-10-27 02:19:37 +0700223
Harald Welteeea18a62016-04-29 15:18:35 +0200224 if len(self.puncture):
Vadim Yanitskiy45ebc522016-10-27 02:19:37 +0700225 fi.write("\t.puncture = %s_puncture,\n" % self.name)
226 fi.write("};\n\n")
Harald Welteeea18a62016-04-29 15:18:35 +0200227
228poly = lambda *args: sum([(1 << x) for x in args])
229
230def combine(src, sel, nb):
231 x = src & sel
232 fn_xor = lambda x, y: x ^ y
233 return reduce(fn_xor, [(x >> n) & 1 for n in range(nb)])
234
Vadim Yanitskiy6908fa72016-09-07 22:34:53 +0700235def print_formatted(items, format, count, fi):
236 counter = 0
237
238 # Print initial indent
239 fi.write("\t")
240
241 for item in items:
242 if counter > 0 and counter % count == 0:
243 fi.write("\n\t")
244
245 fi.write(format % item)
246 counter += 1
247
248 fi.write("\n")
249
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700250def print_shared(fi):
251 for (name, polys) in shared_polys.items():
252 # HACK
253 code = ConvolutionalCode(0, polys, name = name)
254 code.print_state_and_output(fi)
255
Harald Welteeea18a62016-04-29 15:18:35 +0200256# Polynomials according to 3GPP TS 05.03 Annex B
257G0 = poly(0, 3, 4)
258G1 = poly(0, 1, 3, 4)
259G2 = poly(0, 2, 4)
260G3 = poly(0, 1, 2, 3, 4)
261G4 = poly(0, 2, 3, 5, 6)
262G5 = poly(0, 1, 4, 6)
263G6 = poly(0, 1, 2, 3, 4, 6)
264G7 = poly(0, 1, 2, 3, 6)
265
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700266shared_polys = {
267 "xcch" : [
268 ( G0, 1 ),
269 ( G1, 1 ),
270 ],
271 "mcs" : [
272 ( G4, 1 ),
273 ( G7, 1 ),
274 ( G5, 1 ),
275 ],
276}
Vadim Yanitskiya6b52162016-09-08 22:06:07 +0700277
Vadim Yanitskiyd2d97602016-09-07 22:18:10 +0700278conv_codes = [
279 # xCCH definition
280 ConvolutionalCode(
281 224,
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700282 shared_polys["xcch"],
Vadim Yanitskiyd2d97602016-09-07 22:18:10 +0700283 name = "xcch",
284 description = [
285 "xCCH convolutional code:",
286 "228 bits blocks, rate 1/2, k = 5",
287 "G0 = 1 + D3 + D4",
288 "G1 = 1 + D + D3 + D4",
289 ]
290 ),
Harald Welteeea18a62016-04-29 15:18:35 +0200291
Vadim Yanitskiyf3d38c42016-09-07 23:09:49 +0700292 # RACH definition
293 ConvolutionalCode(
294 14,
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700295 shared_polys["xcch"],
Vadim Yanitskiyf3d38c42016-09-07 23:09:49 +0700296 name = "rach",
297 description = ["RACH convolutional code"]
298 ),
299
300 # SCH definition
301 ConvolutionalCode(
302 35,
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700303 shared_polys["xcch"],
Vadim Yanitskiyf3d38c42016-09-07 23:09:49 +0700304 name = "sch",
305 description = ["SCH convolutional code"]
306 ),
307
Vadim Yanitskiyd2d97602016-09-07 22:18:10 +0700308 # CS2 definition
309 ConvolutionalCode(
310 290,
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700311 shared_polys["xcch"],
Vadim Yanitskiyd2d97602016-09-07 22:18:10 +0700312 puncture = [
313 15, 19, 23, 27, 31, 35, 43, 47, 51, 55, 59, 63, 67, 71,
314 75, 79, 83, 91, 95, 99, 103, 107, 111, 115, 119, 123, 127, 131,
315 139, 143, 147, 151, 155, 159, 163, 167, 171, 175, 179, 187, 191, 195,
316 199, 203, 207, 211, 215, 219, 223, 227, 235, 239, 243, 247, 251, 255,
317 259, 263, 267, 271, 275, 283, 287, 291, 295, 299, 303, 307, 311, 315,
318 319, 323, 331, 335, 339, 343, 347, 351, 355, 359, 363, 367, 371, 379,
319 383, 387, 391, 395, 399, 403, 407, 411, 415, 419, 427, 431, 435, 439,
320 443, 447, 451, 455, 459, 463, 467, 475, 479, 483, 487, 491, 495, 499,
321 503, 507, 511, 515, 523, 527, 531, 535, 539, 543, 547, 551, 555, 559,
322 563, 571, 575, 579, 583, 587, -1
323 ],
324 name = "cs2",
325 description = [
326 "CS2 convolutional code:",
327 "G0 = 1 + D3 + D4",
328 "G1 = 1 + D + D3 + D4",
329 ]
330 ),
Harald Welteeea18a62016-04-29 15:18:35 +0200331
Vadim Yanitskiyd2d97602016-09-07 22:18:10 +0700332 # CS3 definition
333 ConvolutionalCode(
334 334,
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700335 shared_polys["xcch"],
Vadim Yanitskiyd2d97602016-09-07 22:18:10 +0700336 puncture = [
337 15, 17, 21, 23, 27, 29, 33, 35, 39, 41, 45, 47, 51, 53,
338 57, 59, 63, 65, 69, 71, 75, 77, 81, 83, 87, 89, 93, 95,
339 99, 101, 105, 107, 111, 113, 117, 119, 123, 125, 129, 131, 135, 137,
340 141, 143, 147, 149, 153, 155, 159, 161, 165, 167, 171, 173, 177, 179,
341 183, 185, 189, 191, 195, 197, 201, 203, 207, 209, 213, 215, 219, 221,
342 225, 227, 231, 233, 237, 239, 243, 245, 249, 251, 255, 257, 261, 263,
343 267, 269, 273, 275, 279, 281, 285, 287, 291, 293, 297, 299, 303, 305,
344 309, 311, 315, 317, 321, 323, 327, 329, 333, 335, 339, 341, 345, 347,
345 351, 353, 357, 359, 363, 365, 369, 371, 375, 377, 381, 383, 387, 389,
346 393, 395, 399, 401, 405, 407, 411, 413, 417, 419, 423, 425, 429, 431,
347 435, 437, 441, 443, 447, 449, 453, 455, 459, 461, 465, 467, 471, 473,
348 477, 479, 483, 485, 489, 491, 495, 497, 501, 503, 507, 509, 513, 515,
349 519, 521, 525, 527, 531, 533, 537, 539, 543, 545, 549, 551, 555, 557,
350 561, 563, 567, 569, 573, 575, 579, 581, 585, 587, 591, 593, 597, 599,
351 603, 605, 609, 611, 615, 617, 621, 623, 627, 629, 633, 635, 639, 641,
352 645, 647, 651, 653, 657, 659, 663, 665, 669, 671, -1
353 ],
354 name = "cs3",
355 description = [
356 "CS3 convolutional code:",
357 "G0 = 1 + D3 + D4",
358 "G1 = 1 + D + D3 + D4",
359 ]
360 ),
Harald Welteeea18a62016-04-29 15:18:35 +0200361
Vadim Yanitskiyd2d97602016-09-07 22:18:10 +0700362 # TCH_AFS_12_2 definition
363 ConvolutionalCode(
364 250,
365 [
366 ( 1, 1 ),
367 ( G1, G0 ),
368 ],
369 puncture = [
370 321, 325, 329, 333, 337, 341, 345, 349, 353, 357, 361, 363,
371 365, 369, 373, 377, 379, 381, 385, 389, 393, 395, 397, 401,
372 405, 409, 411, 413, 417, 421, 425, 427, 429, 433, 437, 441,
373 443, 445, 449, 453, 457, 459, 461, 465, 469, 473, 475, 477,
374 481, 485, 489, 491, 493, 495, 497, 499, 501, 503, 505, 507,
375 -1
376 ],
377 name = 'tch_afs_12_2',
378 description = [
379 "TCH/AFS 12.2 kbits convolutional code:",
380 "250 bits block, rate 1/2, punctured",
381 "G0/G0 = 1",
382 "G1/G0 = 1 + D + D3 + D4 / 1 + D3 + D4",
383 ]
384 ),
Harald Welteeea18a62016-04-29 15:18:35 +0200385
Vadim Yanitskiyd2d97602016-09-07 22:18:10 +0700386 # TCH_AFS_10_2 definition
387 ConvolutionalCode(
388 210,
389 [
390 ( G1, G3 ),
391 ( G2, G3 ),
392 ( 1, 1 ),
393 ],
394 puncture = [
395 1, 4, 7, 10, 16, 19, 22, 28, 31, 34, 40, 43,
396 46, 52, 55, 58, 64, 67, 70, 76, 79, 82, 88, 91,
397 94, 100, 103, 106, 112, 115, 118, 124, 127, 130, 136, 139,
398 142, 148, 151, 154, 160, 163, 166, 172, 175, 178, 184, 187,
399 190, 196, 199, 202, 208, 211, 214, 220, 223, 226, 232, 235,
400 238, 244, 247, 250, 256, 259, 262, 268, 271, 274, 280, 283,
401 286, 292, 295, 298, 304, 307, 310, 316, 319, 322, 325, 328,
402 331, 334, 337, 340, 343, 346, 349, 352, 355, 358, 361, 364,
403 367, 370, 373, 376, 379, 382, 385, 388, 391, 394, 397, 400,
404 403, 406, 409, 412, 415, 418, 421, 424, 427, 430, 433, 436,
405 439, 442, 445, 448, 451, 454, 457, 460, 463, 466, 469, 472,
406 475, 478, 481, 484, 487, 490, 493, 496, 499, 502, 505, 508,
407 511, 514, 517, 520, 523, 526, 529, 532, 535, 538, 541, 544,
408 547, 550, 553, 556, 559, 562, 565, 568, 571, 574, 577, 580,
409 583, 586, 589, 592, 595, 598, 601, 604, 607, 609, 610, 613,
410 616, 619, 621, 622, 625, 627, 628, 631, 633, 634, 636, 637,
411 639, 640, -1
412 ],
413 name = 'tch_afs_10_2',
414 description = [
415 "TCH/AFS 10.2 kbits convolutional code:",
416 "G1/G3 = 1 + D + D3 + D4 / 1 + D + D2 + D3 + D4",
417 "G2/G3 = 1 + D2 + D4 / 1 + D + D2 + D3 + D4",
418 "G3/G3 = 1",
419 ]
420 ),
Harald Welteeea18a62016-04-29 15:18:35 +0200421
Vadim Yanitskiyd2d97602016-09-07 22:18:10 +0700422 # TCH_AFS_7_95 definition
423 ConvolutionalCode(
424 165,
425 [
426 ( 1, 1 ),
427 ( G5, G4 ),
428 ( G6, G4 ),
429 ],
430 puncture = [
431 1, 2, 4, 5, 8, 22, 70, 118, 166, 214, 262, 310,
432 317, 319, 325, 332, 334, 341, 343, 349, 356, 358, 365, 367,
433 373, 380, 382, 385, 389, 391, 397, 404, 406, 409, 413, 415,
434 421, 428, 430, 433, 437, 439, 445, 452, 454, 457, 461, 463,
435 469, 476, 478, 481, 485, 487, 490, 493, 500, 502, 503, 505,
436 506, 508, 509, 511, 512, -1
437 ],
438 name = 'tch_afs_7_95',
439 description = [
440 "TCH/AFS 7.95 kbits convolutional code:",
441 "G4/G4 = 1",
442 "G5/G4 = 1 + D + D4 + D6 / 1 + D2 + D3 + D5 + D6",
443 "G6/G4 = 1 + D + D2 + D3 + D4 + D6 / 1 + D2 + D3 + D5 + D6",
444 ]
445 ),
Harald Welteeea18a62016-04-29 15:18:35 +0200446
Vadim Yanitskiyd2d97602016-09-07 22:18:10 +0700447 # TCH_AFS_7_4 definition
448 ConvolutionalCode(
449 154,
450 [
451 ( G1, G3 ),
452 ( G2, G3 ),
453 ( 1, 1 ),
454 ],
455 puncture = [
456 0, 355, 361, 367, 373, 379, 385, 391, 397, 403, 409, 415,
457 421, 427, 433, 439, 445, 451, 457, 460, 463, 466, 468, 469,
458 471, 472, -1
459 ],
460 name = 'tch_afs_7_4',
461 description = [
462 "TCH/AFS 7.4 kbits convolutional code:",
463 "G1/G3 = 1 + D + D3 + D4 / 1 + D + D2 + D3 + D4",
464 "G2/G3 = 1 + D2 + D4 / 1 + D + D2 + D3 + D4",
465 "G3/G3 = 1",
466 ]
467 ),
Harald Welteeea18a62016-04-29 15:18:35 +0200468
Vadim Yanitskiyd2d97602016-09-07 22:18:10 +0700469 # TCH_AFS_6_7 definition
470 ConvolutionalCode(
471 140,
472 [
473 ( G1, G3 ),
474 ( G2, G3 ),
475 ( 1, 1 ),
476 ( 1, 1 ),
477 ],
478 puncture = [
479 1, 3, 7, 11, 15, 27, 39, 55, 67, 79, 95, 107,
480 119, 135, 147, 159, 175, 187, 199, 215, 227, 239, 255, 267,
481 279, 287, 291, 295, 299, 303, 307, 311, 315, 319, 323, 327,
482 331, 335, 339, 343, 347, 351, 355, 359, 363, 367, 369, 371,
483 375, 377, 379, 383, 385, 387, 391, 393, 395, 399, 401, 403,
484 407, 409, 411, 415, 417, 419, 423, 425, 427, 431, 433, 435,
485 439, 441, 443, 447, 449, 451, 455, 457, 459, 463, 465, 467,
486 471, 473, 475, 479, 481, 483, 487, 489, 491, 495, 497, 499,
487 503, 505, 507, 511, 513, 515, 519, 521, 523, 527, 529, 531,
488 535, 537, 539, 543, 545, 547, 549, 551, 553, 555, 557, 559,
489 561, 563, 565, 567, 569, 571, 573, 575, -1
490 ],
491 name = 'tch_afs_6_7',
492 description = [
493 "TCH/AFS 6.7 kbits convolutional code:",
494 "G1/G3 = 1 + D + D3 + D4 / 1 + D + D2 + D3 + D4",
495 "G2/G3 = 1 + D2 + D4 / 1 + D + D2 + D3 + D4",
496 "G3/G3 = 1",
497 "G3/G3 = 1",
498 ]
499 ),
Harald Welteeea18a62016-04-29 15:18:35 +0200500
Vadim Yanitskiyd2d97602016-09-07 22:18:10 +0700501 # TCH_AFS_5_9 definition
502 ConvolutionalCode(
503 124,
504 [
505 ( G4, G6 ),
506 ( G5, G6 ),
507 ( 1, 1),
508 ( 1, 1),
509 ],
510 puncture = [
511 0, 1, 3, 5, 7, 11, 15, 31, 47, 63, 79, 95,
512 111, 127, 143, 159, 175, 191, 207, 223, 239, 255, 271, 287,
513 303, 319, 327, 331, 335, 343, 347, 351, 359, 363, 367, 375,
514 379, 383, 391, 395, 399, 407, 411, 415, 423, 427, 431, 439,
515 443, 447, 455, 459, 463, 467, 471, 475, 479, 483, 487, 491,
516 495, 499, 503, 507, 509, 511, 512, 513, 515, 516, 517, 519,
517 -1
518 ],
519 name = 'tch_afs_5_9',
520 description = [
521 "TCH/AFS 5.9 kbits convolutional code:",
522 "124 bits",
523 "G4/G6 = 1 + D2 + D3 + D5 + D6 / 1 + D + D2 + D3 + D4 + D6",
524 "G5/G6 = 1 + D + D4 + D6 / 1 + D + D2 + D3 + D4 + D6",
525 "G6/G6 = 1",
526 "G6/G6 = 1",
527 ]
528 ),
Harald Welteeea18a62016-04-29 15:18:35 +0200529
Vadim Yanitskiyd2d97602016-09-07 22:18:10 +0700530 # TCH_AFS_5_15 definition
531 ConvolutionalCode(
532 109,
533 [
534 ( G1, G3 ),
535 ( G1, G3 ),
536 ( G2, G3 ),
537 ( 1, 1 ),
538 ( 1, 1 ),
539 ],
540 puncture = [
541 0, 4, 5, 9, 10, 14, 15, 20, 25, 30, 35, 40,
542 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160,
543 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280,
544 290, 300, 310, 315, 320, 325, 330, 334, 335, 340, 344, 345,
545 350, 354, 355, 360, 364, 365, 370, 374, 375, 380, 384, 385,
546 390, 394, 395, 400, 404, 405, 410, 414, 415, 420, 424, 425,
547 430, 434, 435, 440, 444, 445, 450, 454, 455, 460, 464, 465,
548 470, 474, 475, 480, 484, 485, 490, 494, 495, 500, 504, 505,
549 510, 514, 515, 520, 524, 525, 529, 530, 534, 535, 539, 540,
550 544, 545, 549, 550, 554, 555, 559, 560, 564, -1
551 ],
552 name = 'tch_afs_5_15',
553 description = [
554 "TCH/AFS 5.15 kbits convolutional code:",
555 "G1/G3 = 1 + D + D3 + D4 / 1 + D + D2 + D3 + D4",
556 "G1/G3 = 1 + D + D3 + D4 / 1 + D + D2 + D3 + D4",
557 "G2/G3 = 1 + D2 + D4 / 1 + D + D2 + D3 + D4",
558 "G3/G3 = 1",
559 "G3/G3 = 1",
560 ]
561 ),
Harald Welteeea18a62016-04-29 15:18:35 +0200562
Vadim Yanitskiyd2d97602016-09-07 22:18:10 +0700563 # TCH_AFS_4_75 definition
564 ConvolutionalCode(
565 101,
566 [
567 ( G4, G6 ),
568 ( G4, G6 ),
569 ( G5, G6 ),
570 ( 1, 1 ),
571 ( 1, 1 ),
572 ],
573 puncture = [
574 0, 1, 2, 4, 5, 7, 9, 15, 25, 35, 45, 55,
575 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175,
576 185, 195, 205, 215, 225, 235, 245, 255, 265, 275, 285, 295,
577 305, 315, 325, 335, 345, 355, 365, 375, 385, 395, 400, 405,
578 410, 415, 420, 425, 430, 435, 440, 445, 450, 455, 459, 460,
579 465, 470, 475, 479, 480, 485, 490, 495, 499, 500, 505, 509,
580 510, 515, 517, 519, 520, 522, 524, 525, 526, 527, 529, 530,
581 531, 532, 534, -1
582 ],
583 name = 'tch_afs_4_75',
584 description = [
585 "TCH/AFS 4.75 kbits convolutional code:",
586 "G4/G6 = 1 + D2 + D3 + D5 + D6 / 1 + D + D2 + D3 + D4 + D6",
587 "G4/G6 = 1 + D2 + D3 + D5 + D6 / 1 + D + D2 + D3 + D4 + D6",
588 "G5/G6 = 1 + D + D4 + D6 / 1 + D + D2 + D3 + D4 + D6",
589 "G6/G6 = 1",
590 "G6/G6 = 1",
591 ]
Vadim Yanitskiyf3d38c42016-09-07 23:09:49 +0700592 ),
593
594 # TCH_FR definition
595 ConvolutionalCode(
596 185,
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700597 shared_polys["xcch"],
Vadim Yanitskiyf3d38c42016-09-07 23:09:49 +0700598 name = "tch_fr",
599 description = ["TCH/F convolutional code"]
600 ),
601
602 # TCH_HR definition
603 ConvolutionalCode(
604 98,
605 [
606 ( G4, 1 ),
607 ( G5, 1 ),
608 ( G6, 1 ),
609 ],
610 puncture = [
611 1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34,
612 37, 40, 43, 46, 49, 52, 55, 58, 61, 64, 67, 70,
613 73, 76, 79, 82, 85, 88, 91, 94, 97, 100, 103, 106,
614 109, 112, 115, 118, 121, 124, 127, 130, 133, 136, 139, 142,
615 145, 148, 151, 154, 157, 160, 163, 166, 169, 172, 175, 178,
616 181, 184, 187, 190, 193, 196, 199, 202, 205, 208, 211, 214,
617 217, 220, 223, 226, 229, 232, 235, 238, 241, 244, 247, 250,
618 253, 256, 259, 262, 265, 268, 271, 274, 277, 280, 283, 295,
619 298, 301, 304, 307, 310, -1,
620 ],
621 name = "tch_hr",
622 description = ["TCH/H convolutional code"]
623 ),
624
625 # TCH_AHS_7_95 definition
626 ConvolutionalCode(
627 129,
628 [
629 ( 1, 1 ),
630 ( G1, G0 ),
631 ],
632 puncture = [
633 1, 3, 5, 7, 11, 15, 19, 23, 27, 31, 35, 43,
634 47, 51, 55, 59, 63, 67, 71, 79, 83, 87, 91, 95,
635 99, 103, 107, 115, 119, 123, 127, 131, 135, 139, 143, 151,
636 155, 159, 163, 167, 171, 175, 177, 179, 183, 185, 187, 191,
637 193, 195, 197, 199, 203, 205, 207, 211, 213, 215, 219, 221,
638 223, 227, 229, 231, 233, 235, 239, 241, 243, 247, 249, 251,
639 255, 257, 259, 261, 263, 265, -1,
640 ],
641 name = "tch_ahs_7_95",
642 description = ["TCH/AHS 7.95 kbits convolutional code"]
643 ),
644
645 # TCH_AHS_7_4 definition
646 ConvolutionalCode(
647 126,
648 [
649 ( 1, 1 ),
650 ( G1, G0 ),
651 ],
652 puncture = [
653 1, 3, 7, 11, 19, 23, 27, 35, 39, 43, 51, 55,
654 59, 67, 71, 75, 83, 87, 91, 99, 103, 107, 115, 119,
655 123, 131, 135, 139, 143, 147, 151, 155, 159, 163, 167, 171,
656 175, 179, 183, 187, 191, 195, 199, 203, 207, 211, 215, 219,
657 221, 223, 227, 229, 231, 235, 237, 239, 243, 245, 247, 251,
658 253, 255, 257, 259, -1,
659 ],
660 name = "tch_ahs_7_4",
661 description = ["TCH/AHS 7.4 kbits convolutional code"]
662 ),
663
664 # TCH_AHS_6_7 definition
665 ConvolutionalCode(
666 116,
667 [
668 ( 1, 1 ),
669 ( G1, G0 ),
670 ],
671 puncture = [
672 1, 3, 9, 19, 29, 39, 49, 59, 69, 79, 89, 99,
673 109, 119, 129, 139, 149, 159, 167, 169, 177, 179, 187, 189,
674 197, 199, 203, 207, 209, 213, 217, 219, 223, 227, 229, 231,
675 233, 235, 237, 239, -1,
676 ],
677 name = "tch_ahs_6_7",
678 description = ["TCH/AHS 6.7 kbits convolutional code"]
679 ),
680
681 # TCH_AHS_5_9 definition
682 ConvolutionalCode(
683 108,
684 [
685 ( 1, 1 ),
686 ( G1, G0 ),
687 ],
688 puncture = [
689 1, 15, 71, 127, 139, 151, 163, 175, 187, 195, 203, 211,
690 215, 219, 221, 223, -1,
691 ],
692 name = "tch_ahs_5_9",
693 description = ["TCH/AHS 5.9 kbits convolutional code"]
694 ),
695
696 # TCH_AHS_5_15 definition
697 ConvolutionalCode(
698 97,
699 [
700 ( G1, G3 ),
701 ( G2, G3 ),
702 ( 1, 1 ),
703 ],
704 puncture = [
705 0, 1, 3, 4, 6, 9, 12, 15, 18, 21, 27, 33,
706 39, 45, 51, 54, 57, 63, 69, 75, 81, 87, 90, 93,
707 99, 105, 111, 117, 123, 126, 129, 135, 141, 147, 153, 159,
708 162, 165, 168, 171, 174, 177, 180, 183, 186, 189, 192, 195,
709 198, 201, 204, 207, 210, 213, 216, 219, 222, 225, 228, 231,
710 234, 237, 240, 243, 244, 246, 249, 252, 255, 256, 258, 261,
711 264, 267, 268, 270, 273, 276, 279, 280, 282, 285, 288, 289,
712 291, 294, 295, 297, 298, 300, 301, -1,
713 ],
714 name = "tch_ahs_5_15",
715 description = ["TCH/AHS 5.15 kbits convolutional code"]
716 ),
717
718 # TCH_AHS_4_75 definition
719 ConvolutionalCode(
720 89,
721 [
722 ( 1, 1 ),
723 ( G5, G4 ),
724 ( G6, G4 ),
725 ],
726 puncture = [
727 1, 2, 4, 5, 7, 8, 10, 13, 16, 22, 28, 34,
728 40, 46, 52, 58, 64, 70, 76, 82, 88, 94, 100, 106,
729 112, 118, 124, 130, 136, 142, 148, 151, 154, 160, 163, 166,
730 172, 175, 178, 184, 187, 190, 196, 199, 202, 208, 211, 214,
731 220, 223, 226, 232, 235, 238, 241, 244, 247, 250, 253, 256,
732 259, 262, 265, 268, 271, 274, 275, 277, 278, 280, 281, 283,
733 284, -1,
734 ],
735 name = "tch_ahs_4_75",
736 description = ["TCH/AHS 4.75 kbits convolutional code"]
737 ),
Vadim Yanitskiya6b52162016-09-08 22:06:07 +0700738
739 # EDGE MCS1_DL_HDR definition
740 ConvolutionalCode(
741 36,
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700742 shared_polys["mcs"],
Vadim Yanitskiya6b52162016-09-08 22:06:07 +0700743 name = "mcs1_dl_hdr",
744 term_type = "CONV_TERM_TAIL_BITING",
745 description = [
746 "EDGE MCS-1 DL header convolutional code:",
747 "42 bits blocks, rate 1/3, k = 7",
748 "G4 = 1 + D2 + D3 + D5 + D6",
749 "G7 = 1 + D + D2 + D3 + D6",
750 "G5 = 1 + D + D4 + D6"
751 ]
752 ),
753
754 # EDGE MCS1_UL_HDR definition
755 ConvolutionalCode(
756 39,
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700757 shared_polys["mcs"],
Vadim Yanitskiya6b52162016-09-08 22:06:07 +0700758 name = "mcs1_ul_hdr",
759 term_type = "CONV_TERM_TAIL_BITING",
760 description = [
761 "EDGE MCS-1 UL header convolutional code:",
762 "45 bits blocks, rate 1/3, k = 7",
763 "G4 = 1 + D2 + D3 + D5 + D6",
764 "G7 = 1 + D + D2 + D3 + D6",
765 "G5 = 1 + D + D4 + D6"
766 ]
767 ),
768
769 # EDGE MCS1 definition
770 ConvolutionalCode(
771 190,
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700772 shared_polys["mcs"],
Vadim Yanitskiya6b52162016-09-08 22:06:07 +0700773 name = "mcs1",
774 description = [
775 "EDGE MCS-1 data convolutional code:",
776 "196 bits blocks, rate 1/3, k = 7",
777 "G4 = 1 + D2 + D3 + D5 + D6",
778 "G7 = 1 + D + D2 + D3 + D6",
779 "G5 = 1 + D + D4 + D6"
780 ]
781 ),
782
783 # EDGE MCS2 definition
784 ConvolutionalCode(
785 238,
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700786 shared_polys["mcs"],
Vadim Yanitskiya6b52162016-09-08 22:06:07 +0700787 name = "mcs2",
788 description = [
789 "EDGE MCS-2 data convolutional code:",
790 "244 bits blocks, rate 1/3, k = 7",
791 "G4 = 1 + D2 + D3 + D5 + D6",
792 "G7 = 1 + D + D2 + D3 + D6",
793 "G5 = 1 + D + D4 + D6"
794 ]
795 ),
796
797 # EDGE MCS3 definition
798 ConvolutionalCode(
799 310,
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700800 shared_polys["mcs"],
Vadim Yanitskiya6b52162016-09-08 22:06:07 +0700801 name = "mcs3",
802 description = [
803 "EDGE MCS-3 data convolutional code:",
804 "316 bits blocks, rate 1/3, k = 7",
805 "G4 = 1 + D2 + D3 + D5 + D6",
806 "G7 = 1 + D + D2 + D3 + D6",
807 "G5 = 1 + D + D4 + D6"
808 ]
809 ),
810
811 # EDGE MCS4 definition
812 ConvolutionalCode(
813 366,
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700814 shared_polys["mcs"],
Vadim Yanitskiya6b52162016-09-08 22:06:07 +0700815 name = "mcs4",
816 description = [
817 "EDGE MCS-4 data convolutional code:",
818 "372 bits blocks, rate 1/3, k = 7",
819 "G4 = 1 + D2 + D3 + D5 + D6",
820 "G7 = 1 + D + D2 + D3 + D6",
821 "G5 = 1 + D + D4 + D6"
822 ]
823 ),
824
825 # EDGE MCS5_DL_HDR definition
826 ConvolutionalCode(
827 33,
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700828 shared_polys["mcs"],
Vadim Yanitskiya6b52162016-09-08 22:06:07 +0700829 name = "mcs5_dl_hdr",
830 term_type = "CONV_TERM_TAIL_BITING",
831 description = [
832 "EDGE MCS-5 DL header convolutional code:",
833 "39 bits blocks, rate 1/3, k = 7",
834 "G4 = 1 + D2 + D3 + D5 + D6",
835 "G7 = 1 + D + D2 + D3 + D6",
836 "G5 = 1 + D + D4 + D6"
837 ]
838 ),
839
840 # EDGE MCS5_UL_HDR definition
841 ConvolutionalCode(
842 45,
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700843 shared_polys["mcs"],
Vadim Yanitskiya6b52162016-09-08 22:06:07 +0700844 name = "mcs5_ul_hdr",
845 term_type = "CONV_TERM_TAIL_BITING",
846 description = [
847 "EDGE MCS-5 UL header convolutional code:",
848 "51 bits blocks, rate 1/3, k = 7",
849 "G4 = 1 + D2 + D3 + D5 + D6",
850 "G7 = 1 + D + D2 + D3 + D6",
851 "G5 = 1 + D + D4 + D6"
852 ]
853 ),
854
855 # EDGE MCS5 definition
856 ConvolutionalCode(
857 462,
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700858 shared_polys["mcs"],
Vadim Yanitskiya6b52162016-09-08 22:06:07 +0700859 name = "mcs5",
860 description = [
861 "EDGE MCS-5 data convolutional code:",
862 "468 bits blocks, rate 1/3, k = 7",
863 "G4 = 1 + D2 + D3 + D5 + D6",
864 "G7 = 1 + D + D2 + D3 + D6",
865 "G5 = 1 + D + D4 + D6"
866 ]
867 ),
868
869 # EDGE MCS6 definition
870 ConvolutionalCode(
871 606,
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700872 shared_polys["mcs"],
Vadim Yanitskiya6b52162016-09-08 22:06:07 +0700873 name = "mcs6",
874 description = [
875 "EDGE MCS-6 data convolutional code:",
876 "612 bits blocks, rate 1/3, k = 7",
877 "G4 = 1 + D2 + D3 + D5 + D6",
878 "G7 = 1 + D + D2 + D3 + D6",
879 "G5 = 1 + D + D4 + D6"
880 ]
881 ),
882
883 # EDGE MCS7_DL_HDR definition
884 ConvolutionalCode(
885 45,
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700886 shared_polys["mcs"],
Vadim Yanitskiya6b52162016-09-08 22:06:07 +0700887 name = "mcs7_dl_hdr",
888 term_type = "CONV_TERM_TAIL_BITING",
889 description = [
890 "EDGE MCS-7 DL header convolutional code:",
891 "51 bits blocks, rate 1/3, k = 7",
892 "G4 = 1 + D2 + D3 + D5 + D6",
893 "G7 = 1 + D + D2 + D3 + D6",
894 "G5 = 1 + D + D4 + D6"
895 ]
896 ),
897
898 # EDGE MCS7_UL_HDR definition
899 ConvolutionalCode(
900 54,
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700901 shared_polys["mcs"],
Vadim Yanitskiya6b52162016-09-08 22:06:07 +0700902 name = "mcs7_ul_hdr",
903 term_type = "CONV_TERM_TAIL_BITING",
904 description = [
905 "EDGE MCS-7 UL header convolutional code:",
906 "60 bits blocks, rate 1/3, k = 7",
907 "G4 = 1 + D2 + D3 + D5 + D6",
908 "G7 = 1 + D + D2 + D3 + D6",
909 "G5 = 1 + D + D4 + D6"
910 ]
911 ),
912
913 # EDGE MCS7 definition
914 ConvolutionalCode(
915 462,
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700916 shared_polys["mcs"],
Vadim Yanitskiya6b52162016-09-08 22:06:07 +0700917 name = "mcs7",
918 description = [
919 "EDGE MCS-7 data convolutional code:",
920 "468 bits blocks, rate 1/3, k = 7",
921 "G4 = 1 + D2 + D3 + D5 + D6",
922 "G7 = 1 + D + D2 + D3 + D6",
923 "G5 = 1 + D + D4 + D6"
924 ]
925 ),
926
927 # EDGE MCS8 definition
928 ConvolutionalCode(
929 558,
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700930 shared_polys["mcs"],
Vadim Yanitskiya6b52162016-09-08 22:06:07 +0700931 name = "mcs8",
932 description = [
933 "EDGE MCS-8 data convolutional code:",
934 "564 bits blocks, rate 1/3, k = 7",
935 "G4 = 1 + D2 + D3 + D5 + D6",
936 "G7 = 1 + D + D2 + D3 + D6",
937 "G5 = 1 + D + D4 + D6"
938 ]
939 ),
940
941 # EDGE MCS9 definition
942 ConvolutionalCode(
943 606,
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700944 shared_polys["mcs"],
Vadim Yanitskiya6b52162016-09-08 22:06:07 +0700945 name = "mcs9",
946 description = [
947 "EDGE MCS-9 data convolutional code:",
948 "612 bits blocks, rate 1/3, k = 7",
949 "G4 = 1 + D2 + D3 + D5 + D6",
950 "G7 = 1 + D + D2 + D3 + D6",
951 "G5 = 1 + D + D4 + D6"
952 ]
953 ),
Vadim Yanitskiyd2d97602016-09-07 22:18:10 +0700954]
Harald Welteeea18a62016-04-29 15:18:35 +0200955
Vadim Yanitskiyd2d97602016-09-07 22:18:10 +0700956if __name__ == '__main__':
957 path = sys.argv[1] if len(sys.argv) > 1 else os.getcwd()
958 prefix = "gsm0503"
959
Vadim Yanitskiy45ebc522016-10-27 02:19:37 +0700960 sys.stderr.write("Generating convolutional codes...\n")
Vadim Yanitskiyd2d97602016-09-07 22:18:10 +0700961
962 # Open a new file for writing
963 f = open(os.path.join(path, "gsm0503_conv.c"), 'w')
Vadim Yanitskiy45ebc522016-10-27 02:19:37 +0700964 f.write(mod_license + "\n")
965 f.write("#include <stdint.h>\n")
966 f.write("#include <osmocom/core/conv.h>\n\n")
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700967 print_shared(f)
Harald Welteeea18a62016-04-29 15:18:35 +0200968
Vadim Yanitskiyd2d97602016-09-07 22:18:10 +0700969 # Generate the tables one by one
970 for code in conv_codes:
Vadim Yanitskiy45ebc522016-10-27 02:19:37 +0700971 sys.stderr.write("Generate '%s' definition\n" % code.name)
Vadim Yanitskiy6431add2016-10-29 00:00:57 +0700972
973 # Check whether shared polynomials are used
974 shared = None
975 for (name, polys) in shared_polys.items():
976 if code.polys == polys:
977 shared = name
978 break
979
980 code.gen_tables(prefix, f, shared_tables = shared)
Vadim Yanitskiyd2d97602016-09-07 22:18:10 +0700981
Vadim Yanitskiy45ebc522016-10-27 02:19:37 +0700982 sys.stderr.write("Generation complete.\n")