1#This work is licensed under the
2#Creative Commons Attribution-Share Alike 3.0 United States License.
3#To view a copy of this license, visit
4#http://creativecommons.org/licenses/by-sa/3.0/us/ or send a letter to
5#Creative Commons,
6#171 Second Street, Suite 300,
7#San Francisco, California, 94105, USA.
8
9INPUT "MLP substream data",max_matrix_channel[s];
10OUTPUT matrix_params[s][m];
11VAR max_matrix_channel "max matrix channel";
12VAR out_channel "out channel";
13VAR fractional_bits "fractional bits";
14VAR lsb_bypass "LSB bypass";
15VAR matrix_coeff "matrix coefficient";
16VAR matrix_params "matrix parameters";
17out_channel[s][m] <- read 4 unsigned;
18fractional_bits <- read 4 unsigned;
19lsb_bypass[s][m] <- read 1 unsigned;
20assert out_channel[s][m] <= max_matrix_channel[s];
21assert fractional_bits <= 14;
22for c <- 0 to (max_matrix_channel[s] + 3) {
23    if (read 1 unsigned) == 1 {
24       matrix_coeff[s][m][c] <-
25           (read (fractional_bits + 2) signed) * 2 ^ {14 - fractional_bits};
26    } else {
27        matrix_coeff[s][m][c] <- 0;
28    }
29}
30matrix_params[s][m] <- out_channel[s][m],lsb_bypass[s][m],matrix_coeff[s][m];
31return matrix_params[s][m];
32