Skip to content

Commit

Permalink
Add bit-vector to integer conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
LeventErkok committed Jul 8, 2015
1 parent 61687d0 commit 67e66dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion Data/SBV/SMT/SMTLib2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -610,10 +610,18 @@ handleIntCast kFrom kTo a
| m == n = a
| True = extract (n - 1)

b2i s m = error "TBD: b2i_" ++ show (s, m)
i2u n = error $ "TBD: i2u_" ++ show n
i2s n = error $ "TBD: i2s_" ++ show n

b2i s m
| s = "(- " ++ val ++ " " ++ valIf (2^m) sign ++ ")"
| True = val
where valIf v b = "(ite (= " ++ b ++ " #b1) " ++ show (v::Integer) ++ " 0)"
getBit i = "((_ extract " ++ show i ++ " " ++ show i ++ ") " ++ a ++ ")"
bitVal i = valIf (2^i) (getBit i)
val = "(+ " ++ unwords (map bitVal [0 .. m-1]) ++ ")"
sign = getBit (m-1)

signExtend i = "((_ sign_extend " ++ show i ++ ") " ++ a ++ ")"
zeroExtend i = "((_ zero_extend " ++ show i ++ ") " ++ a ++ ")"
extract i = "((_ extract " ++ show i ++ " 0) " ++ a ++ ")"
2 changes: 1 addition & 1 deletion SBVUnitTest/SBVUnitTestBuildTime.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
module SBVUnitTestBuildTime (buildTime) where

buildTime :: String
buildTime = "Tue Jul 7 21:12:15 PDT 2015"
buildTime = "Tue Jul 7 22:12:36 PDT 2015"

0 comments on commit 67e66dd

Please sign in to comment.