diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2019-01-01 15:25:37 +0100 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2019-01-01 15:25:37 +0100 |
commit | 6fbe229217ef7f9d74357028b325313b8551198c (patch) | |
tree | 40e5e79f731325178d264e35951af186508021d5 /src/Test | |
parent | 9db10c8914159106bc3da2efba87d74439b77361 (diff) | |
download | verismith-6fbe229217ef7f9d74357028b325313b8551198c.tar.gz verismith-6fbe229217ef7f9d74357028b325313b8551198c.zip |
Add bsToI function
Diffstat (limited to 'src/Test')
-rw-r--r-- | src/Test/VeriFuzz/Simulator/General.hs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/Test/VeriFuzz/Simulator/General.hs b/src/Test/VeriFuzz/Simulator/General.hs index c7dfd99..b513b79 100644 --- a/src/Test/VeriFuzz/Simulator/General.hs +++ b/src/Test/VeriFuzz/Simulator/General.hs @@ -12,10 +12,11 @@ Class of the simulator and the synthesize tool. module Test.VeriFuzz.Simulator.General where +import Data.Bits (shiftL) +import Data.ByteString (ByteString) +import qualified Data.ByteString as B import Data.ByteString.Builder (byteStringHex, toLazyByteString) -import Data.ByteString.Char8 (ByteString) -import qualified Data.ByteString.Char8 as B -import qualified Data.ByteString.Lazy.Char8 as BL +import qualified Data.ByteString.Lazy as BL import Data.Text (Text) import qualified Data.Text as T import qualified Data.Text.Lazy as TL @@ -56,5 +57,7 @@ synthesizers = ["yosys", "xst"] simulators :: [Text] simulators = ["yosim", "iverilog"] -toHex :: ByteString -> Text -toHex bs = T.pack . BL.unpack . toLazyByteString $ byteStringHex bs +-- | Helper function to convert bytestrings to integers +bsToI :: ByteString -> Integer +bsToI = B.foldl' (\i b -> (i `shiftL` 8) + fromIntegral b) 0 +{-# INLINE bsToI #-} |