aboutsummaryrefslogtreecommitdiffstats
path: root/src/VeriFuzz.hs
diff options
context:
space:
mode:
authorYann Herklotz <git@ymhg.org>2019-05-13 14:58:48 +0100
committerYann Herklotz <git@ymhg.org>2019-05-13 14:58:48 +0100
commit8cab5bfe71157c907ca51ac56fef45ccd6c3229b (patch)
tree3511b7969473d82e70d5acb416f9375ff776f03d /src/VeriFuzz.hs
parent4ecf423075f146ee0a1a452a5658e7a13f99aa9b (diff)
downloadverismith-8cab5bfe71157c907ca51ac56fef45ccd6c3229b.tar.gz
verismith-8cab5bfe71157c907ca51ac56fef45ccd6c3229b.zip
Add reduction for the commandline
Diffstat (limited to 'src/VeriFuzz.hs')
-rw-r--r--src/VeriFuzz.hs27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/VeriFuzz.hs b/src/VeriFuzz.hs
index 6bf1f1c..0d749db 100644
--- a/src/VeriFuzz.hs
+++ b/src/VeriFuzz.hs
@@ -78,8 +78,9 @@ data Opts = Fuzz { fuzzOutput :: {-# UNPACK #-} !Text
}
| Parse { fileName :: {-# UNPACK #-} !FilePath
}
- | Reduce { fileName :: {-# UNPACK #-} !FilePath
- , top :: {-# UNPACK #-} !Text
+ | Reduce { fileName :: {-# UNPACK #-} !FilePath
+ , top :: {-# UNPACK #-} !Text
+ , reduceScript :: {-# UNPACK #-} !FilePath
}
| ConfigOpt { writeConfig :: !(Maybe FilePath)
, configFile :: !(Maybe FilePath)
@@ -176,8 +177,14 @@ reduceOpts =
<> metavar "TOP"
<> help "Name of top level module."
<> showDefault
- <> value "main"
+ <> value "top"
)
+ <*> (strOption
+ $ long "script"
+ <> short 's'
+ <> metavar "SCRIPT"
+ <> help "Script that determines if the current file is interesting, which is determined by the script returning 0."
+ )
configOpts :: Parser Opts
configOpts =
@@ -321,20 +328,12 @@ handleOpts (Generate f c) = do
(flip T.writeFile $ genSource source)
$ T.unpack . toTextIgnore <$> f
handleOpts (Parse f) = do
- verilogSrc <- readFile file
- case parseVerilog file verilogSrc of
+ verilogSrc <- T.readFile file
+ case parseVerilog (T.pack file) verilogSrc of
Left l -> print l
Right v -> print $ GenVerilog v
where file = T.unpack . toTextIgnore $ f
-handleOpts (Reduce f t) = do
- verilogSrc <- readFile file
- case parseVerilog file verilogSrc of
- Left l -> print l
- Right v -> do
- writeFile "main.v" . T.unpack $ genSource (SourceInfo t v)
- vreduced <- runReduce (SourceInfo t v)
- writeFile "reduced.v" . T.unpack $ genSource vreduced
- where file = T.unpack $ toTextIgnore f
+handleOpts (Reduce f t s) = reduceWithScript t s f
handleOpts (ConfigOpt c conf r) = do
config <- if r then getConfig conf >>= randomise else getConfig conf
maybe (T.putStrLn . encodeConfig $ config)