From: Michael Nolan Date: Mon, 30 Mar 2020 23:15:03 +0000 (-0400) Subject: Begin adding helper functions for PPC pseudocode compiler X-Git-Tag: div_pipeline~1595 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=512cd83627c9827b6af1e8788d9451316c778836;p=soc.git Begin adding helper functions for PPC pseudocode compiler --- diff --git a/src/soc/decoder/helpers.py b/src/soc/decoder/helpers.py new file mode 100644 index 00000000..a3fbd1db --- /dev/null +++ b/src/soc/decoder/helpers.py @@ -0,0 +1,49 @@ +import unittest +def exts(value, bits): + sign = 1 << (bits - 1) + return (value * (sign - 1)) - (value * sign) + +def EXTS64(value): + return exts(value, 64) & ((1<<64)-1) + +def ROTL64(value, bits): + mask = (1 << 64) - 1 + bits = bits & 63 + return ((value << bits) | (value >> (64-bits))) & mask + +def mask(x, y): + if x < y: + x = 64-x + y = 63-y + mask_a = ((1<