def __init__(self,G = ('<STR_LIT>','<STR_LIT>'), Depth = <NUM_LIT:10>):
self.G_polys = G<EOL>self.constraint_length = len(self.G_polys[<NUM_LIT:0>]) <EOL>self.Nstates = <NUM_LIT:2>**(self.constraint_length-<NUM_LIT:1>) <EOL>self.decision_depth = Depth<EOL>self.input_zero = trellis_nodes(self.Nstates)<EOL>self.input_one = trellis_nodes(self.Nstates)<EOL>self.paths = trellis_paths(self.Nstates,self.decision_depth)<EOL>self.rate = Fraction(<NUM_LIT:1>,len(G))<EOL>if(len(G) == <NUM_LIT:2> or len(G) == <NUM_LIT:3>):<EOL><INDENT>print('<STR_LIT>' %(self.rate))<EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>')<EOL>raise ValueError('<STR_LIT>')<EOL>pass<EOL><DEDENT>for m in range(self.Nstates):<EOL><INDENT>self.input_zero.fn[m] = m<EOL>self.input_one.fn[m] = m<EOL>output0,state0 = self.conv_encoder([<NUM_LIT:0>],<EOL>binary(m,self.constraint_length-<NUM_LIT:1>))<EOL>output1,state1 = self.conv_encoder([<NUM_LIT:1>],<EOL>binary(m,self.constraint_length-<NUM_LIT:1>))<EOL>self.input_zero.tn[m] = int(state0,<NUM_LIT:2>)<EOL>self.input_one.tn[m] = int(state1,<NUM_LIT:2>)<EOL>if(self.rate == Fraction(<NUM_LIT:1>,<NUM_LIT:2>)):<EOL><INDENT>self.input_zero.out_bits[m] = <NUM_LIT:2>*output0[<NUM_LIT:0>] + output0[<NUM_LIT:1>]<EOL>self.input_one.out_bits[m] = <NUM_LIT:2>*output1[<NUM_LIT:0>] + output1[<NUM_LIT:1>]<EOL><DEDENT>elif(self.rate == Fraction(<NUM_LIT:1>,<NUM_LIT:3>)):<EOL><INDENT>self.input_zero.out_bits[m] = <NUM_LIT:4>*output0[<NUM_LIT:0>] + <NUM_LIT:2>*output0[<NUM_LIT:1>] + output0[<NUM_LIT:2>]<EOL>self.input_one.out_bits[m] = <NUM_LIT:4>*output1[<NUM_LIT:0>] + <NUM_LIT:2>*output1[<NUM_LIT:1>] + output1[<NUM_LIT:2>]<EOL><DEDENT><DEDENT>self.branches = trellis_branches(self.Nstates)<EOL>for m in range(self.Nstates):<EOL><INDENT>match_zero_idx = np.where(self.input_zero.tn == m)<EOL>match_one_idx = np.where(self.input_one.tn == m)<EOL>if len(match_zero_idx[<NUM_LIT:0>]) != <NUM_LIT:0>:<EOL><INDENT>self.branches.states1[m] = self.input_zero.fn[match_zero_idx[<NUM_LIT:0>][<NUM_LIT:0>]]<EOL>self.branches.states2[m] = self.input_zero.fn[match_zero_idx[<NUM_LIT:0>][<NUM_LIT:1>]]<EOL>self.branches.bits1[m] = self.input_zero.out_bits[match_zero_idx[<NUM_LIT:0>][<NUM_LIT:0>]]<EOL>self.branches.bits2[m] = self.input_zero.out_bits[match_zero_idx[<NUM_LIT:0>][<NUM_LIT:1>]]<EOL>self.branches.input1[m] = <NUM_LIT:0><EOL>self.branches.input2[m] = <NUM_LIT:0><EOL><DEDENT>elif len(match_one_idx[<NUM_LIT:0>]) != <NUM_LIT:0>:<EOL><INDENT>self.branches.states1[m] = self.input_one.fn[match_one_idx[<NUM_LIT:0>][<NUM_LIT:0>]]<EOL>self.branches.states2[m] = self.input_one.fn[match_one_idx[<NUM_LIT:0>][<NUM_LIT:1>]]<EOL>self.branches.bits1[m] = self.input_one.out_bits[match_one_idx[<NUM_LIT:0>][<NUM_LIT:0>]]<EOL>self.branches.bits2[m] = self.input_one.out_bits[match_one_idx[<NUM_LIT:0>][<NUM_LIT:1>]]<EOL>self.branches.input1[m] = <NUM_LIT:1><EOL>self.branches.input2[m] = <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>')<EOL>exit(<NUM_LIT:1>)<EOL><DEDENT><DEDENT>
cc1 = fec_conv(G = ('111','101'), Depth = 10)
Instantiate a Rate 1/2 or Rate 1/3 convolutional 
coder/decoder object. Polys G1 and G2 are entered 
as binary strings, e.g,

Rate 1/2
G1 = '111' and G2 = '101' for K = 3 and
G1 = '1111001' and G2 = '1011011' for K = 7.

Rate 1/3
G1 = '111', G2 = '011' and G3 = '101' for K = 3 and
G1 = '1111001', G2 = '1100101' and G3 = '1011011'
for K= 7

The rate will automatically be selected by the number
of G polynomials (only rate 1/2 and 1/3 are available)

Viterbi decoding has a decision depth of Depth.

Data structures than manage the VA are created 
upon instantiation via the __init__ method.

Other ideal polynomial considerations (taken from
"Introduction to Digital Communication" Second Edition
by Ziemer and Peterson:

Rate 1/2
K=3 ('111','101')
K=4 ('1111','1101')
K=5 ('11101','10011')
K=6 ('111101','101011')
K=7 ('1111001','1011011')
K=8 ('11111001','10100111')
K=9 ('111101011','101110001')

Rate 1/3
K=3 ('111','111','101')
K=4 ('1111','1101','1011')
K=5 ('11111','11011','10101')
K=6 ('111101','101011','100111')
K=7 ('1111001','1100101','1011011')
K=8 ('11110111','11011001','10010101')

Mark Wickert and Andrew Smit October 2018