aboutsummaryrefslogtreecommitdiffstats
path: root/src/VeriFuzz/General.hs
diff options
context:
space:
mode:
authorYann Herklotz Grave <git@yannherklotzgrave.com>2019-03-01 12:25:59 +0000
committerYann Herklotz Grave <git@yannherklotzgrave.com>2019-03-01 12:25:59 +0000
commit485ad904c33e767331dfb4794032f71f97432c07 (patch)
treeffb206573c2931074b129a62c53448082c77fce7 /src/VeriFuzz/General.hs
parent36d250feb23ebc43a6cbfb21ae1caa6aa8b42653 (diff)
downloadverismith-485ad904c33e767331dfb4794032f71f97432c07.tar.gz
verismith-485ad904c33e767331dfb4794032f71f97432c07.zip
Moving general simulator options into Internal
Diffstat (limited to 'src/VeriFuzz/General.hs')
-rw-r--r--src/VeriFuzz/General.hs79
1 files changed, 0 insertions, 79 deletions
diff --git a/src/VeriFuzz/General.hs b/src/VeriFuzz/General.hs
deleted file mode 100644
index ecbb1da..0000000
--- a/src/VeriFuzz/General.hs
+++ /dev/null
@@ -1,79 +0,0 @@
-{-|
-Module : VeriFuzz.General
-Description : Class of the simulator.
-Copyright : (c) 2018-2019, Yann Herklotz Grave
-License : BSD-3
-Maintainer : ymherklotz [at] gmail [dot] com
-Stability : experimental
-Portability : POSIX
-
-Class of the simulator and the synthesize tool.
--}
-
-module VeriFuzz.General where
-
-import Data.Bits (shiftL)
-import Data.ByteString (ByteString)
-import qualified Data.ByteString as B
-import Data.Text (Text)
-import qualified Data.Text as T
-import Prelude hiding (FilePath)
-import Shelly
-import System.FilePath.Posix (takeBaseName)
-import VeriFuzz.AST
-
--- | Simulator class.
-class Simulator a where
- toText :: a -> Text
-
--- | Simulation type class.
-class (Simulator a) => Simulate a where
- runSim :: a -- ^ Simulator instance
- -> ModDecl -- ^ Module to simulate
- -> [ByteString] -- ^ Inputs to simulate
- -> Sh ByteString -- ^ Returns the value of the hash at the output of the testbench.
- runSimWithFile :: a
- -> FilePath
- -> [ByteString]
- -> Sh ByteString
-
--- | Synthesize type class.
-class (Simulator a) => Synthesize a where
- runSynth :: a -- ^ Synthesize tool instance
- -> ModDecl -- ^ Module to synthesize
- -> FilePath -- ^ Output verilog file for the module
- -> Sh () -- ^ does not return any values
-
-rootPath :: Sh FilePath
-rootPath = do
- current <- pwd
- maybe current fromText <$> get_env "VERIFUZZ_ROOT"
-
-timeout :: FilePath -> [Text] -> Sh Text
-timeout = command1 "timeout" ["300"] . toTextIgnore
-{-# INLINE timeout #-}
-
-timeout_ :: FilePath -> [Text] -> Sh ()
-timeout_ = command1_ "timeout" ["300"] . toTextIgnore
-{-# INLINE timeout_ #-}
-
--- | Helper function to convert bytestrings to integers
-bsToI :: ByteString -> Integer
-bsToI = B.foldl' (\i b -> (i `shiftL` 8) + fromIntegral b) 0
-{-# INLINE bsToI #-}
-
-noPrint :: Sh a -> Sh a
-noPrint = print_stdout False . print_stderr False
-
-echoP :: Text -> Sh ()
-echoP t = do
- fn <- pwd
- echo $ bname fn <> " - " <> t
- where bname = T.pack . takeBaseName . T.unpack . toTextIgnore
-
-logger :: FilePath -> Text -> Sh a -> Sh a
-logger fp name = log_stderr_with (l "_log.stderr.txt")
- . log_stdout_with (l "_log.txt")
- where
- l s t = appendFile (file s) (T.unpack t) >> appendFile (file s) "\n"
- file s = T.unpack (toTextIgnore $ fp </> fromText name) <> s