class TestGFBInstructions(unittest.TestCase):
@staticmethod
- def init_aes_red_poly():
+ def init_aes_red_poly(XLEN=8):
# AES's finite field reducing polynomial
red_poly = GF2Poly([1, 1, 0, 1, 1, 0, 0, 0, 1])
- ST.reinit(GFBREDPOLY=pack_poly(red_poly.coefficients))
+ REDPOLY = pack_poly(red_poly.coefficients)
+ if REDPOLY >= 2 ** XLEN:
+ REDPOLY %= 2 ** XLEN
+ REDPOLY &= ~1
+ ST.reinit(XLEN=XLEN, GFBREDPOLY=REDPOLY)
return red_poly
def test_gfbmul(self):
expectedv = pack_poly(expected.value.coefficients)
self.assertEqual(product, expectedv)
- def test_gfbmadd(self):
+ def test_gfbmadd(self, XLEN=8):
# AES's finite field reducing polynomial
- red_poly = self.init_aes_red_poly()
+ red_poly = self.init_aes_red_poly(XLEN=XLEN)
a_width = 5
b_width = 4
c_width = 4
expectedv = pack_poly(expected.value.coefficients)
self.assertEqual(result, expectedv)
+ def test_gfbmadd_64(self):
+ self.test_gfbmadd(XLEN=64)
+
def test_gfbinv(self):
# AES's finite field reducing polynomial
red_poly = self.init_aes_red_poly()