id: variable_tpc_encoder_def
label: TPC Encoder Definition
flags: [ show_id ]

parameters:
-   id: value
    label: Ignore Me
    dtype: raw
    default: '"ok"'
    hide: all
-   id: ndim
    label: Parallelism
    dtype: enum
    default: '0'
    options: ['0', '1', '2']
-   id: dim1
    label: Dimension 1
    dtype: int
    default: '4'
    hide: ${ ('none' if (int(ndim) >= 1) else 'all') }
-   id: dim2
    label: Dimension 2
    dtype: int
    default: '4'
    hide: ${ ('none' if (int(ndim) >= 2) else 'all') }
-   id: row_poly
    label: Row Encoder Polynomials
    dtype: int_vector
    default: '[3]'
-   id: col_poly
    label: Column Encoder Polynomials
    dtype: int_vector
    default: '[43]'
-   id: krow
    label: K Row
    dtype: int
    default: '26'
-   id: kcol
    label: K Col
    dtype: int
    default: '6'
-   id: bval
    label: B
    dtype: int
    default: '9'
-   id: qval
    label: Q
    dtype: int
    default: '3'
value: ${ value }

templates:
    imports: from gnuradio import fec
    var_make: |-
        % if int(ndim)==0:
        self.${id} = ${id} = fec.tpc_encoder_make(${row_poly}, ${col_poly}, ${krow}, ${kcol}, ${bval}, ${qval})
        % elif int(ndim)==1:
        self.${id} = ${id} = list(map( (lambda a: fec.tpc_encoder_make(${row_poly}, ${col_poly}, ${krow}, ${kcol}, ${bval}, ${qval})), range(0,${dim1}) ))
        % else:
        self.${id} = ${id} = list(map( (lambda b: list(map( ( lambda a: fec.tpc_encoder_make(${row_poly}, ${col_poly}, ${krow}, ${kcol}, ${bval}, ${qval})), range(0,${dim2}) ) ) ), range(0,${dim1})))
        % endif

documentation: |-
    This instantiates a 1-dim array or 2-dim array fo Turbo Product Encoders (TPC).
            Restrictions: B and Q must be carefully chosen such that when the matrices are setup,
            and the first B outputs are removed, they (the first B outputs) are all 0's.

file_format: 1
