olo_base_pkg_gf¶
Status Information¶
VHDL Source: olo_base_pkg_gf
Description¶
This package contains the arithmetic of the Galois field GF(2^m) used by olo_base_rs_encode and olo_base_rs_decode. It is usable for other codes over GF(2^m) as well.
- Elements are std_logic_vector(m-1 downto 0) in the polynomial basis: bit i is the coefficient of alpha^i, where alpha is a root of the field polynomial.
- The field polynomial is passed as fieldPolynomial: its m low coefficients, the coefficient of x^m is implicit. x^8 + x^7 + x^2 + x + 1 (the field of CCSDS 131.0-B-5) is x"87", x^8 + x^4 + x^3 + x^2 + 1 is x"1D". The width m is the length of the vector. The polynomial must be primitive for alpha to generate the field (see gfIsPrimitive()).
- Functions working on vectors are synthesizable. A multiplication with one constant operand reduces to an XOR network.
- Functions ending in Int work on element values given as natural and are meant for constants computed at elaboration. Tables and code polynomials are returned as IntegerArray_t from olo_base_pkg_array.
The functions loop over the elements of the field at elaboration; they are written for m up to 12 (4096 elements).
Definitions¶
None
Functions on Vectors¶
gfMult()¶
Product of two field elements (polynomial multiplication modulo the field polynomial).
function gfMult(a, b, fieldPolynomial : std_logic_vector) return std_logic_vector;
gfAlphaPow()¶
alpha^e for any integer e (negative exponents give the inverse powers).
function gfAlphaPow(e : integer; fieldPolynomial : std_logic_vector) return std_logic_vector;
gfPow()¶
a^e for e >= 0 (square and multiply).
function gfPow(a : std_logic_vector; e : natural; fieldPolynomial : std_logic_vector) return std_logic_vector;
gfInv()¶
Multiplicative inverse a^(2^m-2). The inverse of zero is returned as zero. For a non-constant operand a table lookup (gfInvTable() as a ROM) is usually smaller than this function in hardware.
function gfInv(a, fieldPolynomial : std_logic_vector) return std_logic_vector;
gfMatMult()¶
Product of a constant GF(2) matrix with a vector: the XOR of matrix(i) over all bits i of x that are set. Used with gfDualBasisMatrix() and gfDualBasisMatrixInv() for the conversion between bases.
function gfMatMult(matrix : IntegerArray_t; x : std_logic_vector) return std_logic_vector;
Functions on Element Values (Elaboration)¶
| Function | Result |
|---|---|
gfAddInt(a, b) |
a + b (bitwise XOR) |
gfMultInt(a, b, fieldPolynomial) |
a * b |
gfAlphaPowInt(e, fieldPolynomial) |
alpha^e for any integer e |
gfPowInt(a, e, fieldPolynomial) |
a^e for any integer e (0^0 = 1, a negative power of zero is returned as zero) |
gfInvInt(a, fieldPolynomial) |
Inverse of a (zero for zero) |
gfLogInt(a, fieldPolynomial) |
Logarithm to the base alpha (zero for zero) |
gfTraceInt(a, fieldPolynomial) |
Trace a + a^2 + a^4 + ... + a^(2^(m-1)), 0 or 1 |
gfIsPrimitive(fieldPolynomial) |
True if alpha generates all 2^m-1 non-zero elements |
Tables and Code Polynomials (Elaboration)¶
gfAntilogTable(), gfLogTable(), gfInvTable()¶
gfAntilogTable() returns alpha^i for i = 0 ... 2^m-2. gfLogTable() and gfInvTable() return the logarithm and the inverse for a = 0 ... 2^m-1 (entry 0 is zero). Assigned to a constant they are inferred as ROMs.
function gfAntilogTable(fieldPolynomial : std_logic_vector) return IntegerArray_t;
function gfLogTable(fieldPolynomial : std_logic_vector) return IntegerArray_t;
function gfInvTable(fieldPolynomial : std_logic_vector) return IntegerArray_t;
gfRsGenerator()¶
Generator polynomial of a Reed-Solomon code with roots check symbols:
g(x) = (x + alpha^b0) (x + alpha^(b0 + gamma)) ... (x + alpha^(b0 + (roots-1) gamma))
with the first root exponent b0 = firstRoot and the root step gamma = rootStep. The result holds the coefficients g_0 ... g_roots (g_roots = 1).
function gfRsGenerator(fieldPolynomial : std_logic_vector;
roots : positive; firstRoot : natural; rootStep : positive) return IntegerArray_t;
Example: the code of CCSDS 131.0-B-5 4.3.4 with E = 16 has the roots alpha^(11 j), j = 112 ... 143, so gfRsGenerator(x"87", 32, 212, 11) (11 * 112 mod 255 = 212); with E = 8, gfRsGenerator(x"87", 16, 45, 11).
gfDualBasisMatrix(), gfDualBasisMatrixInv()¶
Conversion matrices between the polynomial basis and the dual basis of (1, b, b^2, ..., b^(m-1)) with b = alpha^exponent. The dual basis coefficients of an element u are z_j = Tr(u * b^j), and the dual basis value holds z_0 in its most significant bit. Entry i of gfDualBasisMatrix() is the dual basis value of alpha^i; entry j of gfDualBasisMatrixInv() is the polynomial basis value whose dual basis value is 2^j. Both are applied with gfMatMult(). If the powers of b are no basis, the inverse function stops the elaboration with a failure.
function gfDualBasisMatrix(fieldPolynomial : std_logic_vector; exponent : positive) return IntegerArray_t;
function gfDualBasisMatrixInv(fieldPolynomial : std_logic_vector; exponent : positive) return IntegerArray_t;
CCSDS 131.0-B-5 4.3.9 uses the field x"87" and exponent = 117: gfDualBasisMatrix(x"87", 117) holds the rows of the matrix T given there (entry i is the row of alpha^i), gfDualBasisMatrixInv(x"87", 117) the rows of its inverse.