Struct turbo::Code [] [src]

pub struct Code {
    pub start_state: Vec<b1>,
    pub polys: Vec<b3>,
    pub code_type: CodeType,
}

A description of a binary convolutional code, either nonrecursive (FIR), or recursive (IIR), including start state.

Fields

The starting state of the registers.

Storage of the binary polynomial coefficients. Each polynomial corresponds to an output bit in the order in which they are stored.

Coefficients are defined in order of increasing delay, e.g. polys[0][0] is applied to signal[n], and coefs[1] is applied to signal[n-1], and so on.

Enum describing the type of the code (FIR or IIR).

Methods

impl Code
[src]

Computes the adjacency matrix of states the code passes through. The output is a matrix indexed by [start_index][destination_index], with a unit binary digit in each position (1 if there is an edge, 0 if there is not).

This turns out to be easy for an FIR encoder, because the transitions can be expressed solely as "pushes" onto an array of previous states that only differ by the next input bit. For example, for a 3-digit state register, the adjacency matrix looks like this:

1 1 0 0 0 0 0 0
0 0 1 1 0 0 0 0
0 0 0 0 1 1 0 0
0 0 0 0 0 0 1 1
1 1 0 0 0 0 0 0
0 0 1 1 0 0 0 0
0 0 0 0 1 1 0 0
0 0 0 0 0 0 1 1

Examples

use turbo::{Code, CodeType, b3, ONE, ZERO};

let toy_code = Code {
  start_state: vec![ZERO, ZERO],
  polys: vec![b3::new([ZERO, ZERO, ONE]),
              b3::new([ONE, ONE, ZERO])],
  code_type: CodeType::FIRCode
};

assert_eq!(toy_code.state_adjacency(),
           vec![vec![ONE, ONE, ZERO, ZERO],
                vec![ZERO, ZERO, ONE, ONE],
                vec![ONE, ONE, ZERO, ZERO],
                vec![ZERO, ZERO, ONE, ONE]]);

Computes the next states indices reachable given an index corresponding to an existing state index (numbered in monotonic ascending order).

Examples

use turbo::{Code, CodeType, b3, ONE, ZERO};

let toy_code = Code {
  start_state: vec![ZERO, ZERO],
  polys: vec![b3::new([ZERO, ZERO, ONE]),
              b3::new([ONE, ONE, ZERO])],
  code_type: CodeType::FIRCode
};

assert_eq!(toy_code.next_states(0),
           vec![0, 1]);
assert_eq!(toy_code.next_states(1),
           vec![2, 3]);
assert_eq!(toy_code.next_states(2),
           vec![0, 1]);
assert_eq!(toy_code.next_states(3),
           vec![2, 3]);

Trait Implementations

impl Encoder for Code
[src]

Encoder implementation for convolutional codes. Matches on code type, computing FIR and IIR codes separately. Read more

impl MLDecoder for Code
[src]

Hard decision decoding, using the Hamming distance.

Reads back the maximum likelihood bits in reverse order from the pruned tree and the surviving leaf. Read more

Runs the forward and backward steps of the decoder to produce the fully decoded string. Read more