summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJon French2018-09-14 15:16:29 +0100
committerJon French2018-09-14 15:16:29 +0100
commit22ed9657ac5d8d1a06602ca8c6cf359786f03254 (patch)
treecdf3c1e21c0fd24786c0683789aa175b6ff23de1 /src
parent5298ef2f1dff1e61d96842e135accab73f38824e (diff)
(oops, should have been with "more hex_bits_N monomorphs")
Diffstat (limited to 'src')
-rw-r--r--src/sail_lib.ml10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/sail_lib.ml b/src/sail_lib.ml
index e7bf6348..1115b55d 100644
--- a/src/sail_lib.ml
+++ b/src/sail_lib.ml
@@ -400,6 +400,16 @@ let rec bits_of_int bit n =
end
else []
+let rec bits_of_big_int pow n =
+ if pow < 1 then []
+ else begin
+ let bit = (Big_int.pow_int_positive 2 (pow - 1)) in
+ if Big_int.greater (Big_int.div n bit) Big_int.zero then
+ B1 :: bits_of_big_int (pow - 1) (Big_int.sub n bit)
+ else
+ B0 :: bits_of_big_int (pow - 1) n
+ end
+
let byte_of_int n = bits_of_int 128 n
module Mem = struct