Struct turbo::Code [] [src]

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

A description of a 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. coefs[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).

Trait Implementations

impl Encoder for Code
[src]

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

Examples

use turbo::{Code, CodeType, b2, b1, ONE, ZERO};
use turbo::encoders::Encoder;
let toy_code = Code {
  start_state: b2::new([ZERO, ZERO]),
  polys: vec![b2::new([ZERO, ONE]),
              b2::new([ONE, ZERO])],
  code_type: CodeType::FIRCode
};

let toy_signal = vec![ONE, ONE];
let encoded_signal = toy_code.encode(&toy_signal);

assert_eq!(encoded_signal, vec![ZERO, ONE,
                                ONE, ONE]);