From: Jacob Lifshay Date: Wed, 15 May 2024 06:32:00 +0000 (-0700) Subject: reference/test_cl_gfb_gfp.py: test reducing polynomial that is XLEN+1 bits X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=306341e23427fed07f30e839cc19fe358dda93e2;p=nmigen-gf.git reference/test_cl_gfb_gfp.py: test reducing polynomial that is XLEN+1 bits --- diff --git a/gf_reference/test_cl_gfb_gfp.py b/gf_reference/test_cl_gfb_gfp.py index b4db911..a831639 100644 --- a/gf_reference/test_cl_gfb_gfp.py +++ b/gf_reference/test_cl_gfb_gfp.py @@ -540,10 +540,14 @@ class TestCL(unittest.TestCase): 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): @@ -561,9 +565,9 @@ class TestGFBInstructions(unittest.TestCase): 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 @@ -582,6 +586,9 @@ class TestGFBInstructions(unittest.TestCase): 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()