aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Herklotz Grave <git@yannherklotzgrave.com>2019-03-07 17:37:17 +0000
committerYann Herklotz Grave <git@yannherklotzgrave.com>2019-03-07 17:37:17 +0000
commite0584a769484a7b91a63840420986220df1734b2 (patch)
treeefdd1915c1e0de4aa1e02cec4df57a66153f5d7a
parent24df5f787068a50bc90433e7073bba0ab82d1938 (diff)
downloadverismith-e0584a769484a7b91a63840420986220df1734b2.tar.gz
verismith-e0584a769484a7b91a63840420986220df1734b2.zip
Add more options to main app
-rw-r--r--app/Main.hs24
-rw-r--r--src/VeriFuzz.hs16
2 files changed, 24 insertions, 16 deletions
diff --git a/app/Main.hs b/app/Main.hs
index 3d80c86..f9ecb52 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -17,16 +17,17 @@ instance Show Tool where
show XST = "xst"
show Icarus = "icarus"
-data Opts = Fuzz { fuzzOutput :: Text
+data Opts = Fuzz { fuzzOutput :: {-# UNPACK #-} !Text
}
- | Rerun { tool :: Tool
+ | Rerun { tools :: [Tool]
+ , input :: {-# UNPACK #-} !S.FilePath
}
- | Generate { fileName :: S.FilePath
+ | Generate { fileName :: {-# UNPACK #-} !S.FilePath
}
- | Parse { fileName :: S.FilePath
+ | Parse { fileName :: {-# UNPACK #-} !S.FilePath
}
- | Reduce { fileName :: S.FilePath
- , top :: Text
+ | Reduce { fileName :: {-# UNPACK #-} !S.FilePath
+ , top :: {-# UNPACK #-} !Text
}
myForkIO :: IO () -> IO (MVar ())
@@ -65,7 +66,7 @@ fuzzOpts = Fuzz <$> textOption
rerunOpts :: Parser Opts
rerunOpts =
Rerun
- <$> ( option
+ <$> some (option
(optReader parseSynth)
( long "synth"
<> metavar "SYNTH"
@@ -82,6 +83,13 @@ rerunOpts =
<> value Icarus
)
)
+ <*> (S.fromText <$> textOption
+ ( long "input"
+ <> short 'i'
+ <> metavar "FILE"
+ <> help "Verilog file input."
+ <> showDefault
+ <> value "rtl.v"))
genOpts :: Parser Opts
genOpts = Generate . S.fromText <$> textOption
@@ -197,7 +205,7 @@ handleOpts (Parse f) = do
Left l -> print l
Right v -> print $ V.GenVerilog v
where file = T.unpack . S.toTextIgnore $ f
-handleOpts (Rerun _ ) = undefined
+handleOpts (Rerun _ _) = undefined
handleOpts (Reduce f t) = do
verilogSrc <- readFile file
case V.parseVerilog file verilogSrc of
diff --git a/src/VeriFuzz.hs b/src/VeriFuzz.hs
index 7e6a25e..de7cc90 100644
--- a/src/VeriFuzz.hs
+++ b/src/VeriFuzz.hs
@@ -63,16 +63,16 @@ import VeriFuzz.XST
import VeriFuzz.Yosys
-- | Generate a specific number of random bytestrings of size 256.
-genRand :: C.CtrDRBG -> Int -> [ByteString] -> [ByteString]
-genRand gen n bytes | n == 0 = ranBytes : bytes
- | otherwise = genRand newGen (n - 1) $ ranBytes : bytes
+randomByteString :: C.CtrDRBG -> Int -> [ByteString] -> [ByteString]
+randomByteString gen n bytes | n == 0 = ranBytes : bytes
+ | otherwise = randomByteString newGen (n - 1) $ ranBytes : bytes
where Right (ranBytes, newGen) = C.genBytes 32 gen
-- | generates the specific number of bytestring with a random seed.
-genRandom :: Int -> IO [ByteString]
-genRandom n = do
+generateByteString :: Int -> IO [ByteString]
+generateByteString n = do
gen <- C.newGenIO :: IO C.CtrDRBG
- return $ genRand gen n []
+ return $ randomByteString gen n []
makeSrcInfo :: ModDecl -> SourceInfo
makeSrcInfo m =
@@ -102,7 +102,7 @@ runSimulation = do
-- shelly $ run_ "dot" ["-Tpng", "-o", "file.png", "file.dot"]
-- let circ =
-- head $ (nestUpTo 30 . generateAST $ Circuit gr) ^.. getVerilogSrc . traverse . getDescription
- rand <- genRandom 20
+ rand <- generateByteString 20
rand2 <- QC.generate (randomMod 10 100)
val <- shelly $ runSim defaultIcarus (makeSrcInfo rand2) rand
T.putStrLn $ showBS val
@@ -139,7 +139,7 @@ runEquivalence :: Gen ModDecl -> Text -> Int -> IO ()
runEquivalence gm t i = do
m <- QC.generate gm
let srcInfo = makeSrcInfo m
- rand <- genRandom 20
+ rand <- generateByteString 20
shellyFailDir $ do
mkdir_p (fromText "output" </> fromText n)
curr <- toTextIgnore <$> pwd