From: lkcl Date: Sun, 6 Mar 2022 00:56:20 +0000 (+0000) Subject: (no commit message) X-Git-Tag: opf_rfc_ls005_v1~3150 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ae66f0b6c8580611aa5e4021a56a024631f74d87;p=libreriscv.git --- diff --git a/openpower/sv/bitmanip.mdwn b/openpower/sv/bitmanip.mdwn index d60972a3a..80bfeeccb 100644 --- a/openpower/sv/bitmanip.mdwn +++ b/openpower/sv/bitmanip.mdwn @@ -607,10 +607,33 @@ if __name__ == "__main__": # Evaluate the product (x^7)(x^7 + x + 1) print("{:02x}".format(multGF2(0b10000000, 0b10000011))) ``` -## GF add +## GF div and mod - RS = GFADDI(RS, RA|0, gfdegree, modulo=RC) - RS = GFADD(RS, RA|0, gfdegree=RB, modulo=RC) +``` +def FullDivision(self, f, v, fDegree, vDegree): + """ + Takes four arguments, f, v, fDegree, and vDegree where + fDegree and vDegree are the degrees of the field elements + f and v represented as a polynomials. + This method returns the field elements a and b such that + + f(x) = a(x) * v(x) + b(x). + + That is, a is the divisor and b is the remainder, or in + other words a is like floor(f/v) and b is like f modulo v. + """ + + res, rem = 0, f + i = fDegree + mask = 1 << i + while (i >= vDegree): + if (mask & rem): + res ^= (1 << (i - vDegree)) + rem ^= ( v << (i - vDegree))) + i -= 1 + mask >>= 1 + return (res, rem) +``` | 0.5|6.10|11.15|16.20|21.25| 26..30 |31| name | | -- | -- | --- | --- | --- | ------- |--| ----- |