Code
rpps.code ¶
Code transform: channel bits <-> data bits
FEC encoders and decoders, interleaving, rate matching, scrambling (code.scram), line codes (Line: NRZI, Manchester,
inversion), sync markers among channel bits (Marker), and Uncoded for links with no FEC.
Each step takes either channel or data bits, because a code transform is often several steps.
Modules:
| Name | Description |
|---|---|
alist |
LDPC parity-check matrices in MacKay's alist format (what GNU Radio's gr-fec and most LDPC tools read and write) |
coding |
Coding parent classes |
factory |
Codes from their parameters, without a definition file: |
kernels |
Batch kernels of the code operators: |
line |
Line codes: bits <-> bits, one step of the code transform, by name |
marker |
A sync marker among channel bits: a known word before each block of |
serial |
Code definitions, two resources: config/fec/ |
uncoded |
|
alist ¶
LDPC parity-check matrices in MacKay's alist format (what GNU Radio's gr-fec and most LDPC tools read and write)
rp.code.import_alist("code.alist") the definition, as a dict (rp.code.init("mine", d) builds it)
rp.code.import_alist("code.alist", "mine", dest="my_config") writes my_config/fec/block/ldpc/mine.json, add_config_path("my_config")
Functions:
| Name | Description |
|---|---|
read_alist |
(n, checks): code length and, for each parity check, the bit positions (0-based) it covers |
import_alist |
Definition of the LDPC code in an alist file. fields: more keys for it ( |
read_alist ¶
(n, checks): code length and, for each parity check, the bit positions (0-based) it covers
Source code in src/rpps/code/alist.py
import_alist ¶
Definition of the LDPC code in an alist file. fields: more keys for it (comment, k + systematic, iters...).
Without k, the message positions come from GF(2) elimination of H, which only suits small codes: give k and systematic
("head": message first, "tail", or a list of positions) for big ones.
name: also write it as config/fec/block/ldpc/dest (default: the first added config path, else the shipped config);
an existing file is not replaced. Returns the file
Source code in src/rpps/code/alist.py
coding ¶
Coding parent classes
Classes:
| Name | Description |
|---|---|
Decision |
Coding decision type: does the decoder get hard bits or LLRs |
Coding |
Coding parent class |
Block |
|
Convolutional |
Parent convolutional coding: separate encoder ("encode") and decoder ("decode") implementations |
Interleaver |
|
Functions:
| Name | Description |
|---|---|
puncture_period |
Channel bits in one period of a convolutional code's puncture pattern (n, the outputs per step, when unpunctured): |
mismatch |
Decode hard channel bits, encode the decision again and compare: (bits that differ, bits compared). At the right |
mismatch_batch |
mismatch() of each row of hard (W, L), decoded together (decode_batch where the decoder has it): (differing |
cached |
A definition loaded once per process and shared (a DVB-S2 LDPC code takes a moment to build): what |
Coding ¶
Bases: Pipe
Coding parent class
Methods:
| Name | Description |
|---|---|
encode |
Encode data using specified coding |
decode |
Decode data using specified coding |
control |
Become another definition of the same kind ( |
pos_rate |
Output bits per input bit (rpps.profile positions) |
load |
Load coding from json |
Attributes:
| Name | Type | Description |
|---|---|---|
decision |
SOFT when the decoder can use LLRs (the default for those that can), HARD otherwise. Assign to override |
|
e_num |
Return number of encoding data bits |
|
e_den |
Return number of total encoded bits |
|
d_num |
Return number of decoding data bits |
|
d_den |
Return number of total decoded bits |
|
e_rate |
Return encoding bits/parity rate |
|
d_rate |
Return decoding bits/parity rate |
Source code in src/rpps/code/coding.py
decision
property
writable
¶
SOFT when the decoder can use LLRs (the default for those that can), HARD otherwise. Assign to override
encode ¶
decode ¶
Decode data using specified coding
A soft decoder takes the LLRs a demodulator produced; anything else (or data that isn't soft) gets hard bits.
control ¶
Become another definition of the same kind (name: "ldpc/dvbs2_64800_3_5"), or nothing at all (None: the
bits pass as they are, an interleaver a modulation does not use). Applied between codewords, it keeps nothing
of the old code; a profile applies it where a header says the new code starts
Source code in src/rpps/code/coding.py
pos_rate ¶
Output bits per input bit (rpps.profile positions)
Block ¶
Bases: Coding
Methods:
| Name | Description |
|---|---|
load |
decoder: a registered decoder type to use instead of the code's own (it's built from the encoder), |
Attributes:
| Name | Type | Description |
|---|---|---|
SCOPE |
Parent block coding |
Source code in src/rpps/code/coding.py
load
staticmethod
¶
decoder: a registered decoder type to use instead of the code's own (it's built from the encoder), or "name"/"decoder" in the definition. Linear codes decode on their syndrome trellis unless that is too big
Source code in src/rpps/code/coding.py
Convolutional ¶
Bases: Coding
Parent convolutional coding: separate encoder ("encode") and decoder ("decode") implementations
Methods:
| Name | Description |
|---|---|
load |
{"base": "conv", "constraint": K, "generator": [...], "puncture": [...], "decoder": "viterbi"}: one set of keys |
Source code in src/rpps/code/coding.py
load
staticmethod
¶
{"base": "conv", "constraint": K, "generator": [...], "puncture": [...], "decoder": "viterbi"}: one set of keys builds the encoder and its decoder. decoder: use this decoder type (viterbi, bcjr) instead of the definition's
Source code in src/rpps/code/coding.py
Interleaver ¶
Bases: Coding
Attributes:
| Name | Type | Description |
|---|---|---|
kernel |
Interleaver: Forney (convolutional: I branches, M symbols of delay increment, state carried along the stream) |
Source code in src/rpps/code/coding.py
kernel
class-attribute
instance-attribute
¶
Interleaver: Forney (convolutional: I branches, M symbols of delay increment, state carried along the stream) or block (a permutation of each block)
puncture_period ¶
Channel bits in one period of a convolutional code's puncture pattern (n, the outputs per step, when unpunctured):
the alignments a decoder can start at. code: anything with an encoder (a loaded Coding)
Source code in src/rpps/code/coding.py
mismatch ¶
Decode hard channel bits, encode the decision again and compare: (bits that differ, bits compared). At the right code and alignment only channel errors differ; a wrong one differs about as often as random bits
Source code in src/rpps/code/coding.py
mismatch_batch ¶
mismatch() of each row of hard (W, L), decoded together (decode_batch where the decoder has it): (differing bits (W,), bits compared)
Source code in src/rpps/code/coding.py
cached
cached
¶
A definition loaded once per process and shared (a DVB-S2 LDPC code takes a moment to build): what control
swaps in, and what the blind tools try: rp.code.cached("conv/k7_171_133/3_4")
Source code in src/rpps/code/coding.py
factory ¶
Codes from their parameters, without a definition file: rp.code.Hamming(7, 4), rp.code.RS(255, 223)...
Each returns the same object rp.code.load makes from a definition, so they work the same in a pipeline:
link = scr * rp.code.Hamming(7, 4) * rp.symbol.QAM(16)
Functions:
| Name | Description |
|---|---|
Hamming |
Hamming code: n = 2r - 1, k = n - r. A shorter k (n a bit smaller than 2r - 1) gives a shortened code |
Repetition |
Each bit sent |
RS |
Reed-Solomon over GF(2m). n < 2m - 1 is a shortened code. poly: the field's primitive polynomial (default for m=8: 285) |
Cyclic |
Binary cyclic code from its generator polynomial (bit i = coefficient of x^i), message first |
Golay |
Golay (23,12) or extended Golay (24,12), g(x) = 0xC75 |
Conv |
Rate 1/n convolutional code. generators: n taps lists (or octal/decimal ints) over the constraint length |
Hamming ¶
Hamming code: n = 2r - 1, k = n - r. A shorter k (n a bit smaller than 2r - 1) gives a shortened code
Source code in src/rpps/code/factory.py
Repetition ¶
Each bit sent count times, decoded by majority (or by summing LLRs)
RS ¶
Reed-Solomon over GF(2m). n < 2m - 1 is a shortened code. poly: the field's primitive polynomial (default for m=8: 285) puncture: codeword positions not sent (negative from the end), decoded as erasures
Source code in src/rpps/code/factory.py
Cyclic ¶
Binary cyclic code from its generator polynomial (bit i = coefficient of x^i), message first
Cyclic(23, 12, 0xC75) Golay
Cyclic(23, 12, 0xC75, extend=True) extended Golay (24,12)
Cyclic(15, 11, 0b10011) cyclic Hamming
Decoded by syndrome table up to t errors (default: from the minimum distance); decoder="trellis" for soft MAP
Source code in src/rpps/code/factory.py
Golay ¶
Golay (23,12) or extended Golay (24,12), g(x) = 0xC75
Source code in src/rpps/code/factory.py
Conv ¶
Rate 1/n convolutional code. generators: n taps lists (or octal/decimal ints) over the constraint length
Conv([0o133, 0o171], 7) K=7 rate 1/2 (the IESS-308 generators)
Conv([[1,0,1],[1,1,1]], puncture=[[1,1,0],[1,0,1]])
puncture: pattern with one row per output and 1 where a bit is sent decoder: "viterbi" or "bcjr" termination: "truncated" (default), "zero" (flushed with K-1 zeros) or "tailbiting"
Source code in src/rpps/code/factory.py
kernels ¶
Batch kernels of the code operators: BlockDecode of a block code or interleaver, XorMask of an additive scrambler
Checked row for row against the operator run frame by frame (tests/unit/parallel/test_batch_kernels.py); they use only what
numpy and cupy share, so xp can be either (rpps.parallel)
Classes:
| Name | Description |
|---|---|
BlockDecode |
A decoder or deinterleaver of whole blocks, over a batch: the frames' blocks go through the coder in one call (a block code's |
XorMask |
Bits XOR a fixed mask repeated from the start of each frame (a scrambler restarted every |
LdpcDecode |
|
Identity |
A code or interleaver that a frame's parameters switch off ( |
Permute |
|
BchDecode |
|
Functions:
| Name | Description |
|---|---|
permutation_of |
The index a block deinterleaver gathers with (decoding positions 0 .. block-1), or None when it is not a pure |
BlockDecode ¶
Bases: Kernel
A decoder or deinterleaver of whole blocks, over a batch: the frames' blocks go through the coder in one call (a block code's decoder already runs its codewords on several threads, so a batch is more of them at once, not more calls). Each block is independent of the others, so a row comes out as it would alone. A frame is whole blocks; items past the last block are dropped and reported, as the operator does at the end of a flushed stream.
coder: what the operator decodes with (decode(bits or LLRs) -> bits or LLRs, any number of blocks); block: items a
block takes in; soft: it takes LLRs when it is given them
Source code in src/rpps/code/kernels.py
XorMask ¶
Bases: Kernel
Bits XOR a fixed mask repeated from the start of each frame (a scrambler restarted every len(mask) bits). LLRs
stay LLRs, their signs flipped (as the additive scrambler descrambles them)
Source code in src/rpps/code/kernels.py
LdpcDecode ¶
Bases: BlockDecode
BlockDecode of a layered min-sum LDPC code that decodes on the device it is given: the batch's codewords in one
run of launches, the graph uploaded once. On numpy (and on an array module without kernels of its own) it is
BlockDecode, the host decoder: the oracle. Sum-product (check at the effort level) decodes on the host
Source code in src/rpps/code/kernels.py
Identity ¶
Bases: Kernel
A code or interleaver that a frame's parameters switch off (control(name=None)): the items pass as they are, now
the code's category, as the operator gives them
Source code in src/rpps/code/kernels.py
Permute ¶
Bases: BlockDecode
BlockDecode of a block interleaver that is a permutation: every block of a row gathered by one index, on whichever
xp it is given (the index goes to a device once). perm: what the deinterleaver gives for the input positions
0 .. block-1
Source code in src/rpps/code/kernels.py
BchDecode ¶
Bases: BlockDecode
BlockDecode of a binary BCH code (bchgf) that finds the errors on the device it is given: every codeword's
syndromes in one launch; only the words that have errors (few, after an LDPC code) come to the host to be located
(Berlekamp-Massey and Chien, as the host decoder), and their bits are flipped on the device. On numpy, and on an array
module without kernels of its own, it is BlockDecode
Source code in src/rpps/code/kernels.py
permutation_of ¶
The index a block deinterleaver gathers with (decoding positions 0 .. block-1), or None when it is not a pure permutation (it changes values, or loses some)
Source code in src/rpps/code/kernels.py
line ¶
Line codes: bits <-> bits, one step of the code transform, by name
bits * rp.code.Line("nrzi") # AX.25: a 0 is a transition, a 1 no change
bits * rp.code.Line("nrzm") # differential bits: a 1 is a transition
bits * rp.code.Line("manchester") # 0 -> 10, 1 -> 01 (IEEE 802.3); "thomas": 0 -> 01, 1 -> 10
bits * rp.code.Line("invert") # every bit inverted (data inversion)
bits * rp.code.Line("biphase_m") # IRIG-106 Bi-phi-M: a transition at every bit start, and mid-bit for a 1
bits * rp.code.Line("biphase_s") # Bi-phi-S: the same, mid-bit for a 0
bits * rp.code.Line("miller") # delay modulation (DM-M): mid-bit for a 1, at the boundary between two 0s
Bi-phase-M/S and Miller are 2 channel bits a data bit and decode from the two halves alone (a mid-bit transition or not), so they need no reference level and ignore an inverted signal.
Decoding keeps soft values soft: an inversion negates LLRs, a differential code takes the box-plus of neighbours
(sign times the smaller magnitude), Manchester the difference of the two halves. In a profile: {"code": "line", "name": "nrzi"}.
Manchester as a pulse (first half +1, second -1, at the sample level) is rp.signal.filters.ShapingBiphase instead
(rpps.base, Grey areas): this is the bit-level form, 2 channel bits per data bit.
Classes:
| Name | Description |
|---|---|
Line |
|
marker ¶
A sync marker among channel bits: a known word before each block of length bits (CCSDS ASM before each frame)
coded = frames * rp.code.Marker(0x1ACFFC1D, 32, length=8160) # transmit: the word, then 8160 bits, again...
frames = aligned / rp.code.Marker(0x1ACFFC1D, 32, length=8160) # receive: the word stripped, mismatches counted
Attaching the marker is a code transform (known structure among channel bits); finding it in an unaligned stream is sync:
rp.sync.Delimiter(word, bits, length=..., keep=True) gives each frame from its word on, aligned, which this then strips.
In a profile: {"sync": "delimit", "word": "0x1ACFFC1D", "bits": 32, "length": 8160, "keep": true} then
{"code": "marker", "word": "0x1ACFFC1D", "bits": 32, "length": 8160}; or both name a sequence of type "word".
Without length the frames are whatever a profile's control delimits (frame, from a header on transmit, a delimiter on
receive): the word goes before each, and is stripped from the start of each (Mode S: a preamble before frames of 56 or 112
bits). Soft values pass through; the decoded data's errors holds the word's mismatched bits per frame stripped.
serial ¶
Code definitions, two resources: config/fec/rp.code.load("block/rs/204_188")) and
config/interleave/rp.code.load("interleave/forney/12_17"))
Folders are kind (base), then the structure of the code; the standard goes in ref/comment. Names are parameters.
block {"base": "block", "type": ..., "decoder": optional type to decode with instead}
any block code also takes, as sent (rpps.code.types.layout): "append": check bits after the codeword,
each the XOR of the codeword bits listed ([[14, 15]]); "extend": an overall parity bit; "layout": the
sent position of each codeword bit, or {"message": [...], "parity": [...] | "rest"}; "xor": a pattern on
the sent word (inverted parity, a coset)
linear "n", "k" and "p": parity block rows (one per message bit) or "parity": one list per parity bit of the
message bits it XORs, as standards write P0 = I0 + I1 + I3 or "g": generator rows, "h": check
rows; "extend" (decoded on its syndrome "trellis" when small)
expr "k", "bits": an expression per codeword bit over m0.. (and c0.., the bits before), ^ & | ~: loaded as a
linear code (in its arrangement) when affine, else decoded from its 2^k codebook (k <= 16), "t"
cyclic "n", "k", "poly": generator polynomial as a number, bit i = x^i (polynomial order: "0xb" is x^3 + x + 1;
a convolutional or turbo generator is the other way round, its first or most significant bit the
current input), "extend": overall parity bit, "shorten": leading
message bits dropped, "t": errors to correct (default from d_min); decoded by "syndrome" table
repeat "count": 3
fsm trellis code as a state machine: "k", "n", "next", "output" tables, "start", "end", "tail",
"symbols": {"bits", "levels"} to decode amplitudes (P25 trellis, ATSC 8VSB) or {"bits", "points"}: [re, im]
pairs to decode constellation symbols (trellis-coded modulation)
turbo LTE turbo code: "length", "g0", "g1", "constraint", "qpp" or "qpp_table", "iters", "scale"; or multiplexed
bit time by bit time (CCSDS): "g0", "forward": {"1": g1, ...}, "interleave" (a definition), "outputs"
polar "n", "k", "frozen": [...] or "order": "pw" | "bhattacharyya" (+ "design_db"), "list": paths (1: SC),
"crc": a CRC definition for CRC-aided list decoding
rm Reed-Muller RM("r", "m")
ratematch LTE rate matching: "mode": "conv" | "turbo", "length" (bits per stream), "out" (E), "rv", "ncb"
product block product code: "rows", "cols" (block definitions), "reserved", "lead", "iters" (DMR BPTC);
"chase": p decodes it soft as a turbo product code (Chase-Pyndiah)
rs "n", "k", "m": 8, "poly": field polynomial, "fcr": 0, "prim": 1, "puncture": codeword positions not
sent (negative from the end; decoded as erasures), "basis": "dual" + "beta" (CCSDS: 117)
Every block decoder leaves `errors` per codeword after a decode: bits (RS: symbols) corrected, -1 for a failure.
bch "n", "k", "t", "m": 16, "poly": "0x1002D"
ldpc "n" and the checks as "checks" (positions per check), "h" (dense rows), "table" + "k" + "group" (DVB-S2 address
table), "shifts" + "z" (quasi-cyclic: a matrix of shifts of the z x z identity, -1 a zero block: 802.11n, 802.16e)
or "gallager": {...}; optional "k" + "systematic": "head" | "tail" | [positions], "iters": 50, "alpha": 0.8,
"schedule": "layered" | "flooding"
conv {"base": "conv", "constraint": K, "generator": den rows of K bits, "puncture": den rows, "decoder": "viterbi"}
one set of keys for the encoder and its decoder ("viterbi", or "bcjr": soft output; also "maxlog",
"hard_llr", "termination", "invert"). A mother code is a file (fec/conv/k7_171_133.json); its punctured
rates extend it with their "puncture" (fec/conv/k7_171_133/3_4.json)
interleave {"base": "interleave", "type": "forney", "I": 12, "M": 17, "symbol": 8}
{"base": "interleave", "type": "block", "perm": [...] or {"each": "<i>", "n": N}, "map": "from" | "to", "symbol": 1}
{"base": "interleave", "type": "block", "length": D, "cols": 32, "col_perm": [...], "fill": "front"}
Any value can be a load-time parameter: "params": {"ncbps": null}, then {"param": "ncbps"} or {"expr": "..."}.
A reference is the path below config/fec or config/interleave with the kind first: "block/rs/204_188", "conv/k7_171_133/3_4", "interleave/forney/12_17". A bare name ("204_188") works while one definition of any kind has it.
Decoding only runs from a definition loaded here; analysis.result.Guess.save turns a guessed structure into one,
rp.code.import_alist an LDPC alist file. CRC and framing are in rpps.link.
Functions:
| Name | Description |
|---|---|
root |
Directory holding the coding definitions |
ls |
List available FEC definitions by family: {"block/rs": [names], "conv/dvbs": [names], ...} |
names |
References of the definitions of a kind ("block", "conv", "interleave"), as |
init |
Initialize coding. decoder: a decoder type to use instead of the definition's (see |
locate |
(file, kind, name) of a definition: |
mother |
The configured mother code (fec/conv/ |
find |
File of a definition (see |
load |
Load a code: |
root ¶
ls ¶
List available FEC definitions by family: {"block/rs": [names], "conv/dvbs": [names], ...}
blind: only what the blind tools try (rp._config.ls): no definitions tagged "example", and only the selected tags (rp.select_tags)
Source code in src/rpps/code/serial.py
names ¶
References of the definitions of a kind ("block", "conv", "interleave"), as load(kind, ref) takes them ("rs/204_188"), across families or just one
blind: only what the blind tools try (rp._config.ls): no definitions tagged "example", and only the selected tags (rp.select_tags)
Source code in src/rpps/code/serial.py
init ¶
Initialize coding. decoder: a decoder type to use instead of the definition's (see coding.Block.load)
Source code in src/rpps/code/serial.py
locate ¶
(file, kind, name) of a definition: ref is "
Source code in src/rpps/code/serial.py
mother ¶
The configured mother code (fec/conv/
Source code in src/rpps/code/serial.py
find ¶
load ¶
Load a code: load("block/rs/204_188"), load("conv/k7_171_133/3_4"), load("interleave/forney/12_17")
(config/fec/path instead of the shipped config)
decoder: decode with another type than the definition's: "bcjr" or "viterbi" for conv, "trellis" for linear block codes
params: values of the definition's "params" (load("interleave/block/wifi_ofdm", ncbps=96, nbpsc=2))
Source code in src/rpps/code/serial.py
uncoded ¶
Classes:
| Name | Description |
|---|---|
Uncoded |
No channel code: the channel bits are the data bits. The code step of a link that has no FEC (ADS-B, many |
Uncoded ¶
Bases: Pipe
No channel code: the channel bits are the data bits. The code step of a link that has no FEC (ADS-B, many packet radios), so that what the demodulator gives becomes what the link layer takes
payload = syms / bpsk / rp.code.Uncoded() / crc
Decoding keeps LLRs as LLRs (and hard bits as bits), only saying they are now data bits.
rpps.code.scram ¶
Scramblers, a step of the code transform: additive (a sequence of rpps.sequence XOR'd in) and self-synchronizing (feedthrough)
Modules:
| Name | Description |
|---|---|
scrambler |
Scramblers: how a sequence is applied to bits (the |
serial |
Scrambler definitions: config/scramble/ |
scrambler ¶
Scramblers: how a sequence is applied to bits (the scramble resource; the sequences are rpps.sequence)
Classes:
| Name | Description |
|---|---|
Scram |
Scrambler parent class |
Feedthrough |
Feedthrough (self-synchronizing) scrambler: the scrambled bits go through the register, so the keystream depends on the |
Additive |
Additive (synchronous) scrambler: data XOR a sequence that does not depend on the data (rpps.sequence) |
Scram ¶
Bases: Pipe
Scrambler parent class
Methods:
| Name | Description |
|---|---|
control |
A frame starts here: an additive sequence restarts from its seed. With |
load |
Load modulation from json |
Source code in src/rpps/code/scram/scrambler.py
control ¶
A frame starts here: an additive sequence restarts from its seed. With length (DVB-S2: a BBFRAME of Kbch bits)
also every length bits after; with frame (what a delimiter or frame sync publishes: Bluetooth whitening restarts
after the access address) just here. A self-synchronizing scrambler has nothing to restart
Source code in src/rpps/code/scram/scrambler.py
Feedthrough ¶
Bases: Scram
Feedthrough (self-synchronizing) scrambler: the scrambled bits go through the register, so the keystream depends on the data. y[n] = d[n] ^ y[n-t] for each tap t; descrambling is d[n] = y[n] ^ y[n-t], which needs no seed once a register length of bits has passed (a bit slip or a mid-stream start is lost after that), and turns one bit error into one per tap
Methods:
| Name | Description |
|---|---|
reset |
Reset LFSR |
descramble |
d[n] = y[n] ^ y[n-t] for every tap t, on a whole array at once (the first max(taps) bits are not fully |
delays |
The delays t whose bits through the register (what went in, scrambling; what came in, descrambling) the |
encode |
Scramble, continuing from where the last call left this scrambler |
Source code in src/rpps/code/scram/scrambler.py
reset ¶
descramble
staticmethod
¶
d[n] = y[n] ^ y[n-t] for every tap t, on a whole array at once (the first max(taps) bits are not fully descrambled: the register before them is unknown). What a search over taps runs (rpps.analysis.sequence)
Source code in src/rpps/code/scram/scrambler.py
delays ¶
The delays t whose bits through the register (what went in, scrambling; what came in, descrambling) the keystream XORs: found by sending one 1 into a cleared register (every register form here is linear)
Source code in src/rpps/code/scram/scrambler.py
encode ¶
Additive ¶
Bases: Scram
Additive (synchronous) scrambler: data XOR a sequence that does not depend on the data (rpps.sequence)
encode(bits, start) and decode (the same) XOR the sequence from position start; soft(llr, start) flips LLRs instead.
As an operator (bits * scr, bits / scr) its position carries along the stream, and restarts:
period: every period bits (an LTE PBCH over four radio frames, a P25 phase 2 superframe)
frame: packet structure for byte streams, as in DVB energy dispersal:
bytes: restart period; sync_period/sync_bytes: leading bytes of each packet the sequence skips over (it
still advances, those bytes just aren't touched); skip_first: bytes before it starts (default sync_bytes);
marker: the first byte of each frame as sent (DVB: the inverted sync byte, 0xB8), written on encode, and
sync (default marker ^ 0xFF) written on decode. The stream must start on a frame boundary.
length (a profile's control): every length bits from where a frame starts (a DVB-S2 BBFRAME)
Methods:
| Name | Description |
|---|---|
mask |
Bits XOR'd onto one frame (frame bytes * 8), or onto one period |
encode |
data XOR the sequence from position |
soft |
Descramble LLRs (positive = 0): the sign flips where the sequence is 1 |
kernel |
The batch scrambler of a frame restarted every |
Source code in src/rpps/code/scram/scrambler.py
mask ¶
Bits XOR'd onto one frame (frame bytes * 8), or onto one period
encode ¶
data XOR the sequence from position start (0: a frame or period boundary)
soft ¶
Descramble LLRs (positive = 0): the sign flips where the sequence is 1
kernel ¶
The batch scrambler of a frame restarted every length bits (what a profile's control gives); the periodic and
packet-structured forms have none
Source code in src/rpps/code/scram/scrambler.py
serial ¶
Scrambler definitions: config/scramble/rp.code.scram.load("dvb_energy")
How a sequence is applied to bits; the sequences are their own resource (rpps.sequence), which a scrambler names.
additive data XOR a sequence that ignores the data
{"base": "scramble", "type": "additive",
"sequence": "dvb_energy" | {"name": "lte_gold", "args": {"c_init": {"expr": "..."}}}, with its parameters
"period": 1920, optional: restart every `period` bits
"frame": {"bytes": 1504, "sync_period": 188, "sync_bytes": 1, "marker": 184}} optional: packet structure (see Additive)
feedthrough self-synchronizing: the output feeds the register, so the register is the scrambler's own
{"base": "scramble", "type": "feedthrough", "register": "fibonacci" | "galois_left" | "galois_right",
"poly": [16, 14, 13, 11], the polynomial's exponents, as standards write it (1 + x^14 + x^17: [14, 17]):
the delays of the feedback taps, 1 = the first stage. (A recurrence's
"taps", in rpps.sequence, are positions from 0: another key, another thing)
"seed": [1, 0, 1, ...]} register bits, first stage first
Seeds, sequence arguments and any other value can be load-time parameters ("params", then {"param": ...} / {"expr": ...}).
Functions:
| Name | Description |
|---|---|
ls |
The scramblers there are: {type: [names]} |
init |
A scrambler from a definition object |
load |
Load a scrambler by name: |
ls ¶
The scramblers there are: {type: [names]}
blind: only what the blind tools try (rp._config.ls): no definitions tagged "example", and only the selected tags (rp.select_tags)
Source code in src/rpps/code/scram/serial.py
init ¶
load ¶
Load a scrambler by name: load("dvb_energy"), load("ble_whiten", channel=37). params: values of its "params"
rpps.code.types ¶
Code types: the FEC encoders and decoders the definitions in config/fec and config/interleave build
A code type subclasses rpps.code.types._code._code and defines _decode(x, ...) -> (output, errors per codeword or
None), keeping nothing of the call on itself, so one loaded (cached) code decodes on several threads at once. Soft or
path outputs are methods that return them too (app of BCJR and turbo, paths of fsm), never attributes.
A trellis, worked¶
The rate 1/2, constraint length 3 code with generators 101 and 111 (state = the last two input bits):
| State | In | Out | Next |
|---|---|---|---|
| 00 | 0 | 00 | 00 |
| 1 | 11 | 10 | |
| 01 | 0 | 11 | 00 |
| 1 | 00 | 10 | |
| 10 | 0 | 01 | 01 |
| 1 | 10 | 11 | |
| 11 | 0 | 10 | 01 |
| 1 | 01 | 11 |
graph LR
S00((00)) -- 0/00 --> T00((00))
S00 -- 1/11 --> T10((10))
S01((01)) -- 0/11 --> T00
S01 -- 1/00 --> T10
S10((10)) -- 0/01 --> T01((01))
S10 -- 1/10 --> T11((11))
S11((11)) -- 0/10 --> T01
S11 -- 1/01 --> T11
fsm holds such tables for any code (output[s][u], next[s][u]); viterbi and bcjr decode on them.
Modules:
| Name | Description |
|---|---|
bchgf |
|
conv |
|
cyclic |
|
expr |
|
fsm |
|
interleave |
|
ira |
|
layout |
Where a block code's bits go in the word sent, and what is done to them on the way: keys of any block definition |
ldpc |
|
linear |
|
nr_ldpc |
5G NR LDPC code with its rate matching (3GPP TS 38.212 5.2.2, 5.3.2, 5.4.2): one code block, K' bits to E bits |
nr_polar |
5G NR polar code with its rate matching (3GPP TS 38.212 5.3.1, 5.4.1): K bits, CRC included, to E bits |
polar |
Polar codes (Arikan): encoding, successive cancellation (SC) and list decoding (SCL), CRC-aided |
product |
|
ratematch |
|
repeat |
|
rm |
Reed-Muller codes RM(r, m): the evaluations of every Boolean polynomial of degree at most r in m variables |
rs |
|
syndrome |
|
trellis |
Trellis (BCJR / MAP) decoding |
turbo |
|
viterbi |
|
bchgf ¶
Classes:
| Name | Description |
|---|---|
bchgf |
Binary BCH code over GF(2^m), shortened to (n, k), as in DVB-S2 (m=16, or 14 for short frames) |
bchgf ¶
Bases: _code
Binary BCH code over GF(2^m), shortened to (n, k), as in DVB-S2 (m=16, or 14 for short frames)
poly: field polynomial (0x1002D = 1+x^2+x^3+x^5+x^16). t: correctable bit errors. The generator is the product of
the distinct minimal polynomials of alpha^1, alpha^3, ..., alpha^(2t-1), so n-k = m*t.
encode/decode take whole codewords as bits. After a decode errors is the corrected bit count per word (-1: failed).
Methods:
| Name | Description |
|---|---|
syndromes |
S_j = r(alpha^j), j=1..2t, for words (W, n) of bits |
Source code in src/rpps/code/types/bchgf.py
syndromes ¶
S_j = r(alpha^j), j=1..2t, for words (W, n) of bits
Source code in src/rpps/code/types/bchgf.py
conv ¶
Classes:
| Name | Description |
|---|---|
conv |
Convolutional encoder, rate 1/n. See |
Functions:
| Name | Description |
|---|---|
termination_of |
A definition's "termination": "zero" | "tailbiting" | "truncated" (the default) |
generators_of |
(den, K) generator rows of a definition. Rows of K bits, or numbers ("0o133", 91) with "constraint": the most |
conv ¶
conv(log, num: int, den: int, generator, constraint: int, puncture=None, termination='truncated', invert=None)
Bases: _code
Convolutional encoder, rate 1/n. See viterbi for the conventions
puncture: optional (n, P) 0/1 pattern, 1 = send invert: optional n 0/1 flags: outputs sent inverted (CCSDS 131.0-B inverts the second, G2), before puncturing termination: "zero" flushes the register with K-1 zeros so the decoder can end in state 0 (the older termination="zero"); "tailbiting" starts the register with the frame's last K-1 bits, so it ends where it began and nothing is added (LTE); "truncated" (default) just stops. A tail-biting code works on whole frames: in a stream the bits are collected until the stream is flushed.
Methods:
| Name | Description |
|---|---|
encode |
Encode a message. Without |
encode_batch |
Rows of bits (W, L), each a frame of its own, as encode() without |
Source code in src/rpps/code/types/conv.py
encode ¶
Encode a message. Without state it is a frame of its own, starting from the zero register.
With state (a dict, the encoder's part of the stream) the register carries on from the previous call, and
a terminated code only gets its tail when final, which also ends the stream (the state is cleared).
Source code in src/rpps/code/types/conv.py
encode_batch ¶
Rows of bits (W, L), each a frame of its own, as encode() without state gives it: (W, coded bits)
Source code in src/rpps/code/types/conv.py
termination_of ¶
A definition's "termination": "zero" | "tailbiting" | "truncated" (the default)
Source code in src/rpps/code/types/conv.py
generators_of ¶
(den, K) generator rows of a definition. Rows of K bits, or numbers ("0o133", 91) with "constraint": the most significant of the K bits multiplies the current input
Source code in src/rpps/code/types/conv.py
cyclic ¶
Classes:
| Name | Description |
|---|---|
cyclic |
Binary cyclic code from its generator polynomial, systematic with the message first: Golay, Hamming, BCH... |
cyclic ¶
Bases: linear
Binary cyclic code from its generator polynomial, systematic with the message first: Golay, Hamming, BCH...
poly: g(x) as an integer, bit i the coefficient of x^i (Golay (23,12): 0xC75), degree n - k, dividing x^n + 1. extend: append an overall parity bit (Golay (24,12)). shorten: drop that many leading message bits (sent as 0). t: errors the decoder should correct (default: from the minimum distance). A codeword is the message followed by the remainder of m(x) x^(n-k) mod g(x), highest power first.
Source code in src/rpps/code/types/cyclic.py
expr ¶
Classes:
| Name | Description |
|---|---|
expr |
A small block code whose codeword bits are expressions of the message bits: "k", "bits": one expression per |
Functions:
| Name | Description |
|---|---|
codebook |
Every codeword (2^k, n) of codeword-bit expressions over m0..m{k-1} (and the bits before, c0..), message i's bits |
affine |
(G, offset) when every codeword is offset + m G over GF(2), else None |
expr ¶
Bases: _code
A small block code whose codeword bits are expressions of the message bits: "k", "bits": one expression per codeword bit over m0..m{k-1} and the bits before it (c0, c1...), with ^ & | ~ and constants
{"base": "block", "type": "expr", "k": 4, "bits": ["m0", "m1", "m2", "m3", "m0 ^ m1 ^ m3", "(m1 & m2) ^ 1"]}
Loaded as a linear code (and its xor pattern) when the map is affine over GF(2), so it decodes on its syndrome
trellis like any; otherwise decoded by nearest codeword over the whole codebook (k <= 16): soft, the codeword whose
signs best match the LLRs. errors is the distance to the codeword chosen (-1 past t, when given)
Source code in src/rpps/code/types/expr.py
codebook ¶
Every codeword (2^k, n) of codeword-bit expressions over m0..m{k-1} (and the bits before, c0..), message i's bits MSB first
Source code in src/rpps/code/types/expr.py
affine ¶
(G, offset) when every codeword is offset + m G over GF(2), else None
Source code in src/rpps/code/types/expr.py
fsm ¶
Classes:
| Name | Description |
|---|---|
fsm |
Trellis code given as a finite state machine: P25's 1/2 and 3/4 rate trellis codes, ATSC's 8VSB trellis code |
fsm ¶
Bases: _code
Trellis code given as a finite state machine: P25's 1/2 and 3/4 rate trellis codes, ATSC's 8VSB trellis code
Each step takes k input bits (most significant first) in state s, sends the n-bit word output[s][u] (most
significant first) and moves to next[s][u]. Tables are (states, 2^k), or flat lists of states*2^k (row = state).
start: the state the encoder starts in (default 0); null: unknown (the decoder starts from any)
tail: input words of zeros appended by the encoder (P25: one), decoded and dropped; end: the state the
path must end in (null: any)
length: message bits of a codeword (P25 TSBK: 96): each codeword a trellis of its own, from start, with its
tail; encode / decode then take any number of whole codewords. Without it a call is one sequence
symbols: {"bits": b, "levels": [...]} to decode received amplitudes instead of bits: each b-bit group of a
word is sent as levels[group] (ATSC: 3 bits -> -7..7). decode() then takes the amplitudes, n/b per step,
and the branch metric is the squared distance. {"bits": b, "points": [[re, im], ...]}: the same with points
of a constellation (trellis-coded modulation: Ungerboeck, pragmatic), in label order, decoding complex symbols
Bit decoding takes hard bits or LLRs (positive = 0). decode() takes one sequence, decode_batch() a (W, ...) array
of independent ones (all the same length) and returns the input bits of each.
With status=True, each sequence's errors are the received bits (hard decided) that differ from its decoded path's words.
Methods:
| Name | Description |
|---|---|
modulate |
Encoded bits -> the amplitudes the |
decode_batch |
Sequences (W, ...) decoded together: bits (W, ...), or (bits, errors per sequence) with status=True |
paths |
Sequences (W, ...) decoded together: (bits (W, ...), the encoder's output word at every step of each decoded path |
Source code in src/rpps/code/types/fsm.py
modulate ¶
Encoded bits -> the amplitudes the symbols mapping sends
decode_batch ¶
Sequences (W, ...) decoded together: bits (W, ...), or (bits, errors per sequence) with status=True
paths ¶
Sequences (W, ...) decoded together: (bits (W, ...), the encoder's output word at every step of each decoded path (W, T): what the decoder decided was sent, before any mapping to levels)
Source code in src/rpps/code/types/fsm.py
interleave ¶
Classes:
| Name | Description |
|---|---|
forney |
Forney convolutional interleaver: I branches, branch j delays by jM symbols (deinterleaver: (I-1-j)M) |
block_interleaver |
Block interleaver: a fixed permutation of each block of |
Functions:
| Name | Description |
|---|---|
rowcol |
|
forney ¶
Bases: _code
Forney convolutional interleaver: I branches, branch j delays by jM symbols (deinterleaver: (I-1-j)M)
Works on symbols of symbol bits (8: bytes). The first symbol must sit on branch 0 (a packet sync byte).
The deinterleaver has a start-up of (I-1)IM symbols before it carries data.
LLRs go through as LLRs (each symbol's bits kept together; the start-up gives 0: unknown), so the Reed-Solomon decoder
after it gets the soft values a soft-output inner decoder gives, for its erasures.
Source code in src/rpps/code/types/interleave.py
block_interleaver ¶
Bases: _code
Block interleaver: a fixed permutation of each block of n items of symbol bits (dibits: symbol=2)
the permutation, as a list or {"each": "", "n": N} in the definition.
map "from" (default): item i of the interleaved block is item perm[i] of the input map "to": item i of the input goes to position perm[i]
Or the row-column form (LTE sub-block interleaver, 36.212 5.1.4.2.1): cols, col_perm (default: in order), length n (rows = ceil(n/cols)): written row by row with the filler (rows*cols - n dummies) at the front, columns permuted, read column by column; dummies are dropped encode() interleaves, decode() undoes it, on bits or on soft values (any dtype), whole blocks at a time.
Source code in src/rpps/code/types/interleave.py
rowcol ¶
from permutation of a row-column interleaver: written by rows (dummies first, or last with fill="back"),
columns permuted by col_perm (rows by row_perm), read by columns; dummy positions dropped
Source code in src/rpps/code/types/interleave.py
ira ¶
Functions:
| Name | Description |
|---|---|
ira_checks |
Parity checks of a DVB-S2 style irregular repeat-accumulate LDPC code from its address table |
ira_encode |
Systematic encoder for the same construction: [information | parity] |
ira_checks ¶
Parity checks of a DVB-S2 style irregular repeat-accumulate LDPC code from its address table
table: one row of parity addresses per group of group information bits. Information bit j of group i adds to
parity bits (x + (j mod group) * q) mod (n-k) for every address x in the row, q = (n-k)/group, and the parity
bits are accumulated (p[m] ^= p[m-1]). Returns [positions] per check, information bits first.
Source code in src/rpps/code/types/ira.py
ira_encode ¶
Systematic encoder for the same construction: [information | parity]
Source code in src/rpps/code/types/ira.py
layout ¶
Where a block code's bits go in the word sent, and what is done to them on the way: keys of any block definition
"layout": the sent position of each codeword bit (codeword order: the code's own, message first for linear, cyclic,
bch, rs...), as a list (or {"each": ..., "n": N}), or {"message": [...], "parity": [...]} with "rest" for
one of them (the positions the other leaves, in order)
"xor": a fixed pattern on the sent word (a coset: inverted or masked parity), a number of n bits (first sent bit
most significant) or a list of bits
"append": check bits after the codeword (before the layout), each the XOR of the codeword bits it lists (indices
into the codeword and the bits appended before it): P25's NID bit 64 is [[14, 15]]. Checked after the
inner decode: a mismatch is one more error, a failure past the code's `t`
"extend": an overall parity bit, of every bit before it (an extended code); a code with matrices (linear, cyclic,
expr) builds it into them, any other gets it appended here
On encode: the code, the appended bits, the layout, the pattern; on decode the same undone in reverse, on bits or LLRs alike.
Classes:
| Name | Description |
|---|---|
arranged |
A block code with check bits appended ( |
Functions:
| Name | Description |
|---|---|
layout_perm |
|
arranged ¶
Bases: _code
A block code with check bits appended (append, extend), its bits placed (layout) and masked (xor) as sent.
inner: the code (its encoder), dec: what decodes it (default: the code itself). Decode status is the decoder's,
plus each appended bit that disagrees with the decision
Methods:
| Name | Description |
|---|---|
with_decoder |
The same arrangement decoded by |
Source code in src/rpps/code/types/layout.py
with_decoder ¶
The same arrangement decoded by dec (a decoder built from inner)
Source code in src/rpps/code/types/layout.py
layout_perm ¶
to map of a layout spec: codeword bit j goes to sent position perm[j], for an n-bit word
Source code in src/rpps/code/types/layout.py
ldpc ¶
Classes:
| Name | Description |
|---|---|
ldpc |
Linear code defined by sparse parity checks, decoded by belief propagation (normalised min-sum or sum-product) |
Functions:
| Name | Description |
|---|---|
gallager |
Regular (wc, wr) parity-check matrix by Gallager's construction. n must be a multiple of wr |
qc_checks |
The checks of a quasi-cyclic code: (n, checks) from a base matrix of shifts (an entry s >= 0 is the z x z identity |
ldpc ¶
Bases: _code
Linear code defined by sparse parity checks, decoded by belief propagation (normalised min-sum or sum-product)
n: codeword length
checks: for each parity check, the codeword positions it covers
k/systematic: the message length, and where the message sits in the codeword: "head", "tail" or a list of
positions. When omitted both come from GF(2) elimination, which needs a dense H (small codes only)
iters/alpha: maximum iterations / min-sum normalisation
schedule: "layered" (the default: a layer of checks at a time, each codeword stopping once every check holds) or
"flooding" (every check from the same totals, iters iterations: what flood gives the blind tools)
check: the layered schedule's check update, "minsum" (the default: alpha times the smallest other |q|) or
"sumproduct" (exact: phi of the sum of the others' phi|q|, phi(x) = -log tanh(x/2); about 0.3 dB on DVB-S2 1/2
in fewer iterations, each dearer). The effort level picks it (rpps._effort: max decodes sum-product);
flooding is always min-sum
decode() takes hard bits or LLRs (log(P(0)/P(1)), positive means 0) for whole codewords, returns the message.
decode(x, status=True) also gives each codeword's status: -1 where it did not satisfy every parity check.
With rpps._native the codewords are decoded on several threads, each stopping as soon as it converges (the
numpy decoder iterates the whole batch until every codeword has).
Methods:
| Name | Description |
|---|---|
check_of |
The check update a definition names (default min-sum) |
syndrome |
Parity check failures for words (B, N), without a dense H: (B, M), or (B, checks) for only the first |
decode_codewords |
Min-sum on (B, N) LLRs: hard decisions (B, N) and which codewords satisfied every check (B,) |
layers |
The checks in layers that share no variable (greedy colouring, rows in order), computed once per code: the layered |
flood |
Flooding normalized min-sum on (B, N) LLRs for |
propagate |
Belief propagation by the code's schedule: (hard decisions (B, N), converged (B,)) |
layered |
Layered belief propagation on (B, N) LLRs, normalized min-sum or sum-product ( |
Source code in src/rpps/code/types/ldpc.py
check_of
classmethod
¶
The check update a definition names (default min-sum)
syndrome ¶
Parity check failures for words (B, N), without a dense H: (B, M), or (B, checks) for only the first checks
Source code in src/rpps/code/types/ldpc.py
decode_codewords ¶
Min-sum on (B, N) LLRs: hard decisions (B, N) and which codewords satisfied every check (B,)
layers ¶
The checks in layers that share no variable (greedy colouring, rows in order), computed once per code: the layered schedule updates a layer at a time, each layer seeing what the ones before it found
Source code in src/rpps/code/types/ldpc.py
flood ¶
Flooding normalized min-sum on (B, N) LLRs for iters iterations (default the code's), every check from the same
totals: the a-posteriori LLRs (B, N), what the checks say about each bit. The C++ kernel ldpc_flood runs the same loop
(this is its reference)
Source code in src/rpps/code/types/ldpc.py
propagate ¶
Belief propagation by the code's schedule: (hard decisions (B, N), converged (B,))
Source code in src/rpps/code/types/ldpc.py
layered ¶
Layered belief propagation on (B, N) LLRs, normalized min-sum or sum-product (check, as the effort level says):
(hard decisions (B, N), converged (B,)). Each codeword stops when every check holds. Layered (a layer of checks at
a time, the variables updated after each) converges in about half the iterations of flooding: at Eb/N0 0.9 dB
(DVB-S2 1/2 normal frame) 50 layered iterations decode what 100 flooding did. Keeps nothing on the code, so
threads can share it
Source code in src/rpps/code/types/ldpc.py
gallager ¶
Regular (wc, wr) parity-check matrix by Gallager's construction. n must be a multiple of wr
Source code in src/rpps/code/types/ldpc.py
qc_checks ¶
The checks of a quasi-cyclic code: (n, checks) from a base matrix of shifts (an entry s >= 0 is the z x z identity shifted right by s: row r of the block has its 1 at column (r + s) % z; -1 or None is a zero block)
Source code in src/rpps/code/types/ldpc.py
linear ¶
Classes:
| Name | Description |
|---|---|
linear |
Linear block code from its matrices, systematic with the message first. Own decoder: single-error syndrome |
Functions:
| Name | Description |
|---|---|
parity_rows |
The (k, n-k) parity block of parity equations: parity bit j is the XOR of the message bits parity[j] lists |
extended |
(G, H) with an overall parity bit after the codeword: each generator row gets its weight's parity, and the check |
linear ¶
Bases: _code
Linear block code from its matrices, systematic with the message first. Own decoder: single-error syndrome
correction (the trellis decoder is the default, syndrome corrects up to t errors)
Methods:
| Name | Description |
|---|---|
from_config |
One of: "g" + "h" (the matrices), "p" (the k rows of the parity block, n and k) or "parity" (each of the n-k |
Source code in src/rpps/code/types/linear.py
from_config
classmethod
¶
One of: "g" + "h" (the matrices), "p" (the k rows of the parity block, n and k) or "parity" (each of the n-k parity bits as the message bits it XORs: [[0, 1, 3], ...], the way standards write P0 = I0 + I1 + I3; n and k). "extend": an overall parity bit after the codeword
Source code in src/rpps/code/types/linear.py
parity_rows ¶
The (k, n-k) parity block of parity equations: parity bit j is the XOR of the message bits parity[j] lists
Source code in src/rpps/code/types/linear.py
extended ¶
(G, H) with an overall parity bit after the codeword: each generator row gets its weight's parity, and the check matrix a row of ones over every bit
Source code in src/rpps/code/types/linear.py
nr_ldpc ¶
5G NR LDPC code with its rate matching (3GPP TS 38.212 5.2.2, 5.3.2, 5.4.2): one code block, K' bits to E bits
{"base": "block", "type": "nr_ldpc", "bg": 1,
"graph": [[[column, V(set 0), ..., V(set 7)], ...], ...], the base graph's rows (Tables 5.3.2-2, 5.3.2-3)
"kp": 8448, K': the code block's bits (CRC included); the rest of its K = 22 Z (BG2: 10 Z) are filler
"z": 0, the lifting size (0: the smallest Z of any set with Kb Z >= K', 5.2.2)
"kb": null, BG2's Kb (default from K' as one block's B: 10 above 640, 9 above 560, 8 above 192, else 6)
"e": 25344, "rv": 0, bits sent and the redundancy version (where the circular buffer is read from)
"qm": 1, the modulation order the bit interleaver groups by (5.4.2.2; 1: none)
"ncb": null, the circular buffer (limited buffer rate matching; default N)
"iters": 25, "alpha": 0.8}
The parity-check matrix lifts the base graph by Z: an entry V of row i, column j is the Z x Z identity shifted right by V mod Z (the set of Table 5.3.2-1 that holds Z picks V's column). The codeword is the K bits and the parity, 68 Z bits (BG2 52 Z), of which the first 2 Z are never sent: N = 66 Z (50 Z) go into the circular buffer. Encoding solves the 4 Z core parity bits through the core's inverse (once per graph and Z), then every extension row in turn (each ends on an identity). Decoding: the punctured bits erased, the filler known, layered min-sum (rpps.code.types.ldpc).
encode(): K' bits a block to E. decode(): E soft bits (positive = 0) a block to K' bits; errors -1 where the checks did
not all hold (the transport block's CRC is its caller's). segment(B, bg) and base_graph(A, R) give what a transport
block's size picks (5.2.2, 7.2.2).
Classes:
| Name | Description |
|---|---|
nr_ldpc |
One 5G NR LDPC code block (see the module) |
Functions:
| Name | Description |
|---|---|
lifting |
The smallest Z of any set with kb Z >= K' |
base_graph |
The base graph of a transport block of A bits at code rate R (7.2.2) |
segment |
Code block segmentation (5.2.2) of B bits (the transport block and its CRC): (C blocks, K' bits each with their |
nr_ldpc ¶
Bases: ldpc
One 5G NR LDPC code block (see the module)
Methods:
| Name | Description |
|---|---|
codeword |
The 68 Z (52 Z) bits of each row of K bits (filler as 0) |
codeword_llr |
(W, E) soft bits to (W, 68 Z) of the codeword: the punctured erased, the filler known, repetitions added |
Source code in src/rpps/code/types/nr_ldpc.py
codeword ¶
The 68 Z (52 Z) bits of each row of K bits (filler as 0)
Source code in src/rpps/code/types/nr_ldpc.py
codeword_llr ¶
(W, E) soft bits to (W, 68 Z) of the codeword: the punctured erased, the filler known, repetitions added
Source code in src/rpps/code/types/nr_ldpc.py
lifting ¶
base_graph ¶
segment ¶
Code block segmentation (5.2.2) of B bits (the transport block and its CRC): (C blocks, K' bits each with their CRC-24B when C > 1, K bits after the filler, Z)
Source code in src/rpps/code/types/nr_ldpc.py
nr_polar ¶
5G NR polar code with its rate matching (3GPP TS 38.212 5.3.1, 5.4.1): K bits, CRC included, to E bits
{"base": "block", "type": "nr_polar", "K": 56, "E": 864,
"nmax": 9, the largest code, 2^nmax bits (9: downlink, 10: uplink)
"interleave": true, the input interleaver of 5.3.1.1 (I_IL: downlink)
"bil": false, the coded-bit interleaver of 5.4.1.3 (I_BIL: uplink)
"crc": "crc/crc24_nr_c", the CRC the last bits of the K carry (the list decoder picks the path it checks)
"ones": 24, the CRC computed over that many ones before the message (a DCI's)
"list": 8}
N = 2^n from E and K (5.3.1); the K information positions are the most reliable of the polar sequence (config table nr/polar_sequence) below N, past those the rate matching punctures or shortens (5.4.1.1); the N coded bits go through the 32-part sub-block interleaver into a circular buffer, read by repetition (E >= N), puncturing (K/E <= 7/16: the first N - E not sent) or shortening (the last N - E not sent, known zeros). No parity-check bits (n_PC = 0: an uplink control message of 12 to 19 bits is not covered).
encode(): messages of K - crc bits, the CRC attached (mask: XORed onto the last 16 CRC bits, an RNTI), to E bits each.
decode(): E soft bits (positive = 0) a codeword; the punctured positions erased, the shortened known, repetitions added;
then a list decoder (rpps.code.types.polar.scl) and the first path whose CRC checks; errors -1 when none does.
paths(x): every path's K bits (deinterleaved, CRC included) and metric, for a blind search over masks (a PDCCH's RNTIs).
Classes:
| Name | Description |
|---|---|
nr_polar |
The 5G NR polar code of K bits sent as E (see the module) |
Functions:
| Name | Description |
|---|---|
sequence |
Bit indices below N from least to most reliable (5.3.1.2) |
input_pattern |
Pi(k) of the input interleaver for K bits (5.3.1.1) |
code_size |
n of N = 2^n (5.3.1) |
subblock |
J(n): the coded bit the sub-block interleaver puts at n (5.4.1.1) |
triangle |
The coded-bit interleaver (5.4.1.3): f_k = e_order[k] |
nr_polar ¶
Bases: _code
The 5G NR polar code of K bits sent as E (see the module)
Methods:
| Name | Description |
|---|---|
attach |
The K bits: the message and its CRC (over |
residue |
CRC field XOR what the message's CRC is, per row of K bits (..., K): the mask a codeword carries (0: none) |
coded_llr |
(W, E) soft bits to (W, N) soft bits of d, the code's output |
paths |
(K bits of every path (W, P, K), deinterleaved, CRC included; metrics (W, P), best first) |
Source code in src/rpps/code/types/nr_polar.py
attach ¶
The K bits: the message and its CRC (over ones ones and the message), the mask on the CRC's last 16 bits
Source code in src/rpps/code/types/nr_polar.py
residue ¶
CRC field XOR what the message's CRC is, per row of K bits (..., K): the mask a codeword carries (0: none)
Source code in src/rpps/code/types/nr_polar.py
coded_llr ¶
(W, E) soft bits to (W, N) soft bits of d, the code's output
Source code in src/rpps/code/types/nr_polar.py
paths ¶
(K bits of every path (W, P, K), deinterleaved, CRC included; metrics (W, P), best first)
Source code in src/rpps/code/types/nr_polar.py
sequence ¶
input_pattern ¶
Pi(k) of the input interleaver for K bits (5.3.1.1)
Source code in src/rpps/code/types/nr_polar.py
code_size ¶
subblock ¶
triangle ¶
The coded-bit interleaver (5.4.1.3): f_k = e_order[k]
Source code in src/rpps/code/types/nr_polar.py
polar ¶
Polar codes (Arikan): encoding, successive cancellation (SC) and list decoding (SCL), CRC-aided
{"base": "block", "type": "polar", "n": 256, "k": 128,
"frozen": [...] the frozen positions of u, or
"order": "pw" | "bhattacharyya", the N - K least reliable positions of a construction (polarization weight,
"design_db": 0.0, the beta-expansion NR follows; Bhattacharyya parameters at Es/N0 design_db)
"list": 8, paths kept (1: successive cancellation)
"crc": "crc/crc16_xmodem"} CRC-aided: the last `width` information bits carry a CRC of the others, and the
list decoder picks the best path whose CRC checks (k counts the CRC bits)
A codeword is x = u G, G = F^(x n) with F = [[1, 0], [1, 1]] (no bit reversal); u holds the message at the information positions (in increasing order) and 0 at the frozen ones. G is its own inverse.
Decoding works on LLRs (log P(0)/P(1)), hard bits becoming +-1. SC decides each u_i in order from its LLR given the
decisions before it; SCL keeps the list most likely paths, each scored by the penalty sum of log(1 + e^-(1-2u)L)
(Balatsoukas-Stimming, Parizi, Burg, "LLR-based successive cancellation list decoding of polar codes", IEEE TSP 2015).
Every frame of a call is decoded at once (arrays over frames and paths). errors per codeword: bits the chosen codeword
differs from the hard decisions, or -1 when a CRC-aided decoder found no path that checks.
sc(llr, decide), transform, pw_order and bhattacharyya_order are what the blind tools build on
(rpps.analysis.code.block.polar).
Classes:
| Name | Description |
|---|---|
polar |
A polar code (see the module): |
Functions:
| Name | Description |
|---|---|
transform |
G = F^(x n) for N = 2^n, uint8 |
encode_u |
x = u G for rows u (..., N), by the butterflies (N log N XORs) |
pw_order |
Positions from least to most reliable by polarization weight (sum of 2^(j/4) over the index's set bits j: the |
bhattacharyya_order |
Positions from least to most reliable by the Bhattacharyya parameter on a BI-AWGN channel at Es/N0 design_db |
box |
LLR of the parity of two bits (exact box-plus) |
sc |
Successive-cancellation decoding of frames (W, N) of LLRs, every frame at once. decide(i, L) -> (W,) bits: u_i of |
scl |
List decoding of frames (W, N) of LLRs: the |
polar ¶
Bases: _code
A polar code (see the module): info the information positions, crc the CRC the last bits of the message carry
Source code in src/rpps/code/types/polar.py
transform ¶
G = F^(x n) for N = 2^n, uint8
Source code in src/rpps/code/types/polar.py
encode_u ¶
x = u G for rows u (..., N), by the butterflies (N log N XORs)
Source code in src/rpps/code/types/polar.py
pw_order ¶
Positions from least to most reliable by polarization weight (sum of 2^(j/4) over the index's set bits j: the beta-expansion 3GPP's NR sequence follows; SNR-independent)
Source code in src/rpps/code/types/polar.py
bhattacharyya_order ¶
Positions from least to most reliable by the Bhattacharyya parameter on a BI-AWGN channel at Es/N0 design_db (Z = exp(-Es/N0) a channel, then 2Z - Z^2 / Z^2 down the tree, the index's top bit first)
Source code in src/rpps/code/types/polar.py
box ¶
sc ¶
Successive-cancellation decoding of frames (W, N) of LLRs, every frame at once. decide(i, L) -> (W,) bits: u_i of every frame from its SC LLR L (W,) (a frozen position returns zeros; this is where a blind test looks at it). Returns (u (W, N) uint8, Lu (W, N): each u_i's LLR given the u before it as decided)
Source code in src/rpps/code/types/polar.py
scl ¶
List decoding of frames (W, N) of LLRs: the size best paths of each frame, best first. frozen: (N,) bool.
Returns (u (W, P, N) uint8, metric (W, P): each path's penalty, smaller is likelier)
Source code in src/rpps/code/types/polar.py
product ¶
Classes:
| Name | Description |
|---|---|
product |
Product code (block product turbo code, BPTC): message in a k2 x k1 matrix, every row encoded with the row |
product ¶
Bases: _code
Product code (block product turbo code, BPTC): message in a k2 x k1 matrix, every row encoded with the row code (n1, k1), then every column (parity columns too) with the column code (n2, k2); sent row by row
rows, cols: the two block codes, as references to block definitions ("hamming/dmr_15_11") or definitions
reserved: zero bits at the start of the message area (DMR: R(2..0)); the message is k1 k2 - reserved bits
lead: zero bits sent before the matrix (DMR: R(3)), so n = lead + n1 n2
offset: a fixed word XOR'd onto every codeword (a coset of the product code: parity bits sent inverted, fill), as
a hex string of n bits, the lead first then the matrix row by row; decoding takes it off first
iters: decoding rounds of all columns then all rows (hard decisions, each code's own syndrome decoder)
chase: decode soft instead, as a turbo product code (Pyndiah, "Near-optimum decoding of product codes: block turbo
codes", IEEE Trans. Commun. 1998): each row and column by Chase-II over its `chase` least reliable bits (2^chase
test patterns through the component's algebraic decoder, the candidate nearest the input chosen). The channel
LLRs are normalized to mean |R| = 1; the extrinsic information W of a bit is the metric difference to the best
candidate that disagrees with the decision on it, minus the input, or beta times the decision when no candidate
disagrees; W is normalized to mean 1 and the next half iteration decodes R + alpha W (ALPHA and BETA per half
iteration). A row whose test patterns all fail keeps its hard decision. `iters` rounds, stopping early on
a word whose rows and columns are all codewords
After a decode errors is the bits corrected per word, -1 where a row or column still fails its check.
Source code in src/rpps/code/types/product.py
ratematch ¶
Classes:
| Name | Description |
|---|---|
ratematch |
LTE rate matching (3GPP TS 36.212 5.1.4): three coded streams -> E bits through a circular buffer |
ratematch ¶
Bases: _code
LTE rate matching (3GPP TS 36.212 5.1.4): three coded streams -> E bits through a circular buffer
mode "conv" (5.1.4.2): input as a convolutional encoder sends it (three bits per step); each stream sub-block
interleaved (32 columns, CONV_PERM), the buffer is the three one after the other, read from k0 = 0
mode "turbo" (5.1.4.1): input as the turbo code sends it (d0, d1, d2 one after the other); d0 and d1 sub-block
interleaved with TURBO_PERM, d2 with its own permutation, buffer = v0 then v1 / v2 bit by bit, read from
k0 = R (2 ceil(Ncb / 8R) rv + 2); ncb: soft buffer size (default the whole buffer)
length: bits per stream (D: K for conv, K + 4 for turbo); out: E, bits sent
The
Source code in src/rpps/code/types/ratematch.py
repeat ¶
rm ¶
Reed-Muller codes RM(r, m): the evaluations of every Boolean polynomial of degree at most r in m variables
{"base": "block", "type": "rm", "r": 1, "m": 5} RM(1, 5): (32, 6, 16), Mariner 9's code
n = 2^m, k = sum over i <= r of C(m, i), minimum distance 2^(m-r). Codeword position p is the point whose variable j is bit j of p; the message is the polynomial's coefficients, monomials by degree (1, x_0 .. x_{m-1}, x_0 x_1, ...), each degree's in lexicographic order of their variables.
Decoding: RM(1, m) by the fast Hadamard transform, maximum likelihood on LLRs (the correlation with every affine
function at once: Green's "Green machine" of Mariner 9); higher orders by Reed's majority logic on hard decisions, the
top degree first (each monomial's coefficient is the majority of the 2^(m - d) sums over the subcubes its variables
span), which corrects up to 2^(m-r-1) - 1 errors. errors: bits the chosen codeword differs from the hard decisions.
Classes:
| Name | Description |
|---|---|
rm |
|
Functions:
| Name | Description |
|---|---|
monomials |
The variable sets of the monomials of degree <= r, in message order |
rm ¶
Bases: _code
Source code in src/rpps/code/types/rm.py
monomials ¶
rs ¶
Classes:
| Name | Description |
|---|---|
rs |
Reed-Solomon code over GF(2^m), shortened to (n, k): symbols are bytes for m=8 |
rs ¶
rs(log, num: int, den: int, m=8, poly=285, fcr=0, prim=1, puncture=None, basis='conventional', beta=None)
Bases: _code
Reed-Solomon code over GF(2^m), shortened to (n, k): symbols are bytes for m=8
poly: field polynomial (0x11D). fcr/prim: first consecutive root and primitive element power of the generator (DVB: fcr=0, prim=1, 16 roots; P25: fcr=1). Bits are grouped MSB first into m-bit symbols. puncture: positions of the n-symbol codeword that are not sent (negative counts from the end, so [-4, -3, -2, -1] drops the last four parity symbols). They are decoded as erasures; a word has n - len(puncture) symbols on the wire.
basis: "conventional" (the polynomial basis: a symbol's bits are its coefficients) or "dual": the bits are the symbol in
the Berlekamp dual basis of {1, beta, ..., beta^(m-1)}, beta = alpha^beta: bit j (most significant first) is
Tr(z beta^j). CCSDS sends RS(255, 223) that way, beta = alpha^117 (131.0-B, Annex F). Symbols given with symbols=True
are field elements (conventional) either way.
encode/decode take bits (or symbols with symbols=True) of whole codewords as sent.
decode(..., erasures=...) also takes symbols known to be unreliable: a (words, sent symbols) bool array, or one
list of positions per word. e erasures and r errors are corrected while 2r + e <= n - k.
Soft input (LLRs, positive = 0): a word that fails errors-only decoding is tried again with its least reliable
symbols erased (2, 4, ... up to n - k), the generalized minimum distance idea.
After a decode, errors is the number of corrected symbols per codeword (-1: uncorrectable).
Methods:
| Name | Description |
|---|---|
dual_table |
Each field element (conventional) in the dual basis of {1, b, ..., b^(m-1)}, b = alpha^beta: bit j, most |
syndromes |
Syndromes (W, nroots) of full-length codewords (W, n): S_i = r(alpha^((fcr+i)*prim)); only the first |
Source code in src/rpps/code/types/rs.py
dual_table ¶
Each field element (conventional) in the dual basis of {1, b, ..., b^(m-1)}, b = alpha^beta: bit j, most significant first, is the trace of z b^j
Source code in src/rpps/code/types/rs.py
syndromes ¶
Syndromes (W, nroots) of full-length codewords (W, n): S_i = r(alpha^((fcr+i)*prim)); only the first count
Source code in src/rpps/code/types/rs.py
syndrome ¶
Classes:
| Name | Description |
|---|---|
syndrome |
Hard decoder of a linear block code by syndrome lookup: corrects every pattern of up to |
Functions:
| Name | Description |
|---|---|
min_distance_t |
(d_min - 1)//2 of the code generated by G, from all its codewords |
syndrome ¶
Bases: _code
Hard decoder of a linear block code by syndrome lookup: corrects every pattern of up to t bit errors
Built from the code (from_encoder): the table maps each syndrome to the lightest error pattern that gives it.
t defaults to the code's own (d_min - 1)//2, found by listing the codewords (k <= 20), or the code's t.
A syndrome of no pattern within t is a detected failure: errors is -1 for that word and its message bits are
returned as received. Soft input is hard decided first. The message is the first k bits of each word.
Source code in src/rpps/code/types/syndrome.py
min_distance_t ¶
(d_min - 1)//2 of the code generated by G, from all its codewords
Source code in src/rpps/code/types/syndrome.py
trellis ¶
Trellis (BCJR / MAP) decoding
A trellis lists, for every section of the code, which state each branch leaves and enters and which coded
bits it carries. bcjr runs the forward-backward algorithm over it and returns, for every section, the
a-posteriori log-likelihood ratio of the branch bit. The branch bit is whatever the trellis is built around:
- convolutional codes (
bcjrdecoder): the information bit. States are the encoder register - linear block codes (
trellisdecoder): the coded bit. States are the syndrome so far (Wolf's trellis), so it has 2^(n-k) states: practical for short codes (Hamming, small BCH), not for LDPC
Unlike Viterbi it gives soft outputs (usable by an iterative decoder) and it minimises the bit error rate
rather than the sequence error rate. LLRs are log(P(0)/P(1)), positive means 0, as everywhere else. In the
log domain (maxlog=False) the inputs have to be true LLRs: scale them wrong and the output is over or
under confident. maxlog=True is the cheap approximation (Viterbi-like) and does not care about scale.
Classes:
| Name | Description |
|---|---|
Trellis |
Sections of a trellis |
bcjr_conv |
BCJR (MAP) decoder for feed-forward convolutional codes: same definition as |
trellis |
Maximum a-posteriori decoder for a linear block code, on its syndrome trellis |
Functions:
| Name | Description |
|---|---|
bcjr |
Forward-backward over a trellis |
Trellis ¶
Sections of a trellis
next: (P, S, 2) state reached from each state by each branch bit; section t uses next[t % P] label: (P, S, 2, L) the L coded bits each branch carries Every state needs exactly two branches in, which holds for convolutional and syndrome trellises.
Methods:
| Name | Description |
|---|---|
syndrome |
Syndrome trellis of a parity-check matrix H (m, n): sections are coded bits, states the partial syndrome |
Source code in src/rpps/code/types/trellis.py
syndrome
staticmethod
¶
Syndrome trellis of a parity-check matrix H (m, n): sections are coded bits, states the partial syndrome
Source code in src/rpps/code/types/trellis.py
bcjr_conv ¶
bcjr_conv(log, num, den, constraint, generator, puncture=None, termination='truncated', maxlog=False, hard_llr=2.94)
Bases: viterbi
BCJR (MAP) decoder for feed-forward convolutional codes: same definition as viterbi
maxlog: max-log-MAP (no log-sum-exp, insensitive to the LLR scale)
hard_llr: the LLR magnitude given to hard input bits (log-MAP needs a guess at the channel; this is p = 5%)
decode() takes hard bits or LLRs; app() returns the a-posteriori LLR of every information bit.
Methods:
| Name | Description |
|---|---|
app |
A-posteriori LLR of each information bit (the tail of a terminated code is left out) |
Source code in src/rpps/code/types/trellis.py
app ¶
A-posteriori LLR of each information bit (the tail of a terminated code is left out)
Source code in src/rpps/code/types/trellis.py
trellis ¶
Bases: _code
Maximum a-posteriori decoder for a linear block code, on its syndrome trellis
Corrects what the code can correct (a single error for Hamming) from hard bits, and uses LLRs when given. The message is the first k bits of each word (systematic). Built from the code's own parity-check matrix.
Methods:
| Name | Description |
|---|---|
app |
A-posteriori LLRs of the coded bits, (words, n) |
Source code in src/rpps/code/types/trellis.py
app ¶
A-posteriori LLRs of the coded bits, (words, n)
Source code in src/rpps/code/types/trellis.py
bcjr ¶
Forward-backward over a trellis
llr: (W, T, L) channel LLRs of the L coded bits of each of T sections, for W independent blocks start/end: the state every block starts / ends in (None: free) Returns (W, T) a-posteriori LLRs of the branch bits. Needs memory for 2 floats per state per section.
Source code in src/rpps/code/types/trellis.py
turbo ¶
Classes:
| Name | Description |
|---|---|
rsc |
Recursive systematic convolutional code: feedback g0 and feedforward g1 over K taps (D^0 first, octal as |
turbo |
Parallel concatenated (turbo) code, LTE layout (3GPP TS 36.212 5.1.3.2) |
turbo_mux |
Parallel concatenated code with its outputs multiplexed bit time by bit time (CCSDS 131.0-B 6): the layout |
Functions:
| Name | Description |
|---|---|
qpp |
Quadratic permutation polynomial interleaver: pi(i) = (f1 i + f2 i^2) mod K |
rsc ¶
Recursive systematic convolutional code: feedback g0 and feedforward g1 over K taps (D^0 first, octal as usual: LTE g0 = 0o13 = 1 + D^2 + D^3, g1 = 0o15 = 1 + D + D^3). State: the register, newest bit most significant
Methods:
| Name | Description |
|---|---|
encode |
(parity, tail systematic bits, tail parity bits); the tail drives the register to zero (m steps) |
Source code in src/rpps/code/types/turbo.py
encode ¶
(parity, tail systematic bits, tail parity bits); the tail drives the register to zero (m steps)
Source code in src/rpps/code/types/turbo.py
turbo ¶
Bases: _code
Parallel concatenated (turbo) code, LTE layout (3GPP TS 36.212 5.1.3.2)
Two identical RSC codes (feedback g0, feedforward g1, constraint K), the second fed through a QPP interleaver;
each terminated by m tail steps. Output: three streams d0 (systematic), d1 (parity 1), d2 (parity 2) of length+4
each, one after the other, with the 12 tail bits placed as 5.1.3.2.2 does.
length: block size; qpp: [f1, f2], or qpp_table: {"
Methods:
| Name | Description |
|---|---|
app |
The a-posteriori LLRs of the message bits (positive = 0), every word's K one after the other |
Source code in src/rpps/code/types/turbo.py
app ¶
The a-posteriori LLRs of the message bits (positive = 0), every word's K one after the other
turbo_mux ¶
Bases: _code
Parallel concatenated code with its outputs multiplexed bit time by bit time (CCSDS 131.0-B 6): the layout turbo
takes when a definition gives "outputs"
length: block size k
g0: the feedback (backward connection) polynomial, D^0 first ("0b10011", or octal as LTE writes it)
forward: {"1": g1, "2": g2, ...}: the forward polynomials the outputs name
constraint: taps of each polynomial
interleave: an interleave definition giving the second encoder's input order ("block/ccsds_turbo"), with `args`
outputs: what is sent at each bit time, a list of periods: [["0a", "1a"], ["0a", "1b"]] sends the systematic bit
and encoder a's parity 1 at even times, the systematic bit and encoder b's parity 1 at odd ones. "0a" is the
systematic stream (with encoder a's tail), "<p>a" / "<p>b" encoder a's / b's output of forward polynomial p
Both encoders start at zero and are terminated (constraint - 1 steps with the input from the feedback), so a word is
(k + constraint - 1) bit times. Decoded by iterative BCJR (max-log by default, extrinsic scaling scale).
Methods:
| Name | Description |
|---|---|
app |
The a-posteriori LLRs of the message bits (positive = 0), every word's K one after the other |
Source code in src/rpps/code/types/turbo.py
app ¶
The a-posteriori LLRs of the message bits (positive = 0), every word's K one after the other
qpp ¶
Quadratic permutation polynomial interleaver: pi(i) = (f1 i + f2 i^2) mod K
Source code in src/rpps/code/types/turbo.py
viterbi ¶
Classes:
| Name | Description |
|---|---|
viterbi |
Viterbi decoder for feed-forward convolutional codes (rate 1/n, any constraint length) |
viterbi ¶
Bases: _code
Viterbi decoder for feed-forward convolutional codes (rate 1/n, any constraint length)
generator: (n, K) taps. generator[j][i] multiplies the input delayed by i, the same convention as conv
puncture: optional (n, P) 0/1 pattern, 1 = bit was sent. Punctured positions are decoded as erasures
invert: optional n 0/1 flags: outputs the encoder sent inverted (their values are turned back before decoding)
terminated: the encoder was flushed with K-1 zeros, so the path ends in state 0 (and the tail is dropped).
Or a termination name: "zero" (the same), "truncated" (no tail: the best end state), "tailbiting" (the
path ends where it started: decoded on three laps round the frame, keeping the middle one; frames only)
decode() takes hard bits (0/1) or soft values. Soft values are LLRs, log(P(bit=0)/P(bit=1)): positive means 0.
Pass soft=True to force soft, otherwise integer/bool input is treated as hard bits.
Without state decode() takes a whole frame. With state (a dict) it is a stream: the path metrics and the
survivor decisions carry over, and a bit is released once it is depth trellis steps old (it is then settled for
practical purposes). final ends the stream and releases the rest, ending in state 0 if terminated.
Methods:
| Name | Description |
|---|---|
depuncture |
Insert zeros (erasures) for the punctured positions. Returns (T, n) array |
decode_batch |
Words (W, L), each decoded as a frame of its own: decisions (W, T), the same as decode() on each row. In C++ |
Source code in src/rpps/code/types/viterbi.py
depuncture ¶
Insert zeros (erasures) for the punctured positions. Returns (T, n) array
Source code in src/rpps/code/types/viterbi.py
decode_batch ¶
Words (W, L), each decoded as a frame of its own: decisions (W, T), the same as decode() on each row. In C++ (rpps._native.viterbi_batch) on several threads; a loop over decode() without the kernels