3 // GENERIC CONVOLUTIONAL ENCODER
4 // This a generic rate 1/n convolutional encoder. It computes n output
5 // bits for each input bit, based on n generic polynomials.
6 // It uses the set of BXOR_CC instructions to compute bit XOR
7 // reduction from a state masked by a polynomial. For an alternate
8 // solution based on assembling several partial words, as in
9 // the BDT benchmark, see file conv_enc.c. The solution presented
10 // here is slower than conv_enc.c, but more generic.
12 // Forward Shift Register
13 // -----------------------
14 // This solution implements the XOR function by shifting the state
15 // left by one, applying a mask to the state, and reducing
16 // the result with a bit XOR reduction function.
17 // ----- XOR------------> G0
19 // +------------------------------+
20 // | b0 b1 b2 b3 b14 b15 | <- in
21 // +------------------------------+
23 // ----- XOR------------> G1
24 // Instruction BXOR computes the bit G0 or G1 and stores it into CC
25 // and also into a destination reg half. Here, we take CC and rotate it
26 // into an output register.
27 // However, one can also store the output bit directly by storing
28 // the register half where this bit is placed. This would result
29 // in an output structure similar to the one in the original function
30 // Convolutional_Encode(), where an entire half word holds a bit.
31 // The resulting execution speed would be roughly twice as fast,
32 // since there is no need to rotate output bit via CC.
34 .include "testutils.inc"
40 R1 = 0; R2 = 0;R3 = 0;
43 R2.H = 0xa01d; // polynom 0
45 R3.H = 0x12f4; // polynom 1
47 // load and CurrentState to upper half of A0
53 // l-loop counter is in P4
55 // **** START l-LOOP *****
58 // insert 16 bits of input into lower half of A0
59 // and advance input pointer
64 LSETUP ( m$0 , m$0end ) LC0 = P5; // **** BEGIN m-LOOP *****
68 LSETUP ( i$1 , i$1end ) LC1 = P5; // **** BEGIN i-LOOP *****
70 R4.L = CC = BXORSHIFT( A0 , R2 ); // polynom0 -> CC
71 R1 = ROT R1 BY 1; // CC -> R1
72 R4.L = CC = BXOR( A0 , R3 ); // polynom1 -> CC
74 R1 = ROT R1 BY 1; // CC -> R1
76 // store 16 bits of outdata RL1
82 IF !CC JUMP l$0; // **** END l-LOOP *****
86 R0.L = W [ I2 ++ ]; DBGA ( R0.L , 0x8c62 );
87 R0.L = W [ I2 ++ ]; DBGA ( R0.L , 0x262e );
88 R0.L = W [ I2 ++ ]; DBGA ( R0.L , 0x5b4d );
89 R0.L = W [ I2 ++ ]; DBGA ( R0.L , 0x834f );