diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2019-01-10 15:49:13 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2019-01-10 15:49:13 +0000 |
commit | dac34f6ff5c46f11fe6c548b92a02ebf4f10d7e9 (patch) | |
tree | e51f51b4e82f3c764bcba88725e20e4fb10284da /src/VeriFuzz/Simulator/General.hs | |
parent | 3f1190cd7fc873449a1fd430386aa4b773d010ac (diff) | |
download | verismith-dac34f6ff5c46f11fe6c548b92a02ebf4f10d7e9.tar.gz verismith-dac34f6ff5c46f11fe6c548b92a02ebf4f10d7e9.zip |
Rename files out of the module
Diffstat (limited to 'src/VeriFuzz/Simulator/General.hs')
-rw-r--r-- | src/VeriFuzz/Simulator/General.hs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/VeriFuzz/Simulator/General.hs b/src/VeriFuzz/Simulator/General.hs new file mode 100644 index 0000000..a024029 --- /dev/null +++ b/src/VeriFuzz/Simulator/General.hs @@ -0,0 +1,50 @@ +{-| +Module : VeriFuzz.Simulator.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.Simulator.General where + +import Data.Bits (shiftL) +import Data.ByteString (ByteString) +import qualified Data.ByteString as B +import Data.Text (Text) +import Prelude hiding (FilePath) +import Shelly +import VeriFuzz.Verilog.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 Int -- ^ Returns the value of the hash at the output of the testbench. + +-- | 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 + +timeout :: FilePath -> [Text] -> Sh Text +timeout = command1 "timeout" ["180"] . toTextIgnore + +timeout_ :: FilePath -> [Text] -> Sh () +timeout_ = command1_ "timeout" ["180"] . toTextIgnore + +-- | Helper function to convert bytestrings to integers +bsToI :: ByteString -> Integer +bsToI = B.foldl' (\i b -> (i `shiftL` 8) + fromIntegral b) 0 +{-# INLINE bsToI #-} |