aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2019-10-31 18:52:20 +0000
committerYann Herklotz <git@yannherklotz.com>2019-10-31 18:52:20 +0000
commit911b23e2ce898b1b9c1b3394e1dfa4522da51ccc (patch)
tree6480596320fc4a712d5ccefa6fe398cc79813ded
parent581a0c3ae6d5ebcffde694530865b65c3e244d23 (diff)
downloadverismith-911b23e2ce898b1b9c1b3394e1dfa4522da51ccc.tar.gz
verismith-911b23e2ce898b1b9c1b3394e1dfa4522da51ccc.zip
Add parsing of existing rtl when starting fuzz run
-rw-r--r--src/Verismith.hs10
-rw-r--r--src/Verismith/OptParser.hs31
2 files changed, 31 insertions, 10 deletions
diff --git a/src/Verismith.hs b/src/Verismith.hs
index 41d845d..45977fe 100644
--- a/src/Verismith.hs
+++ b/src/Verismith.hs
@@ -85,6 +85,11 @@ getConfig :: Maybe FilePath -> IO Config
getConfig s =
maybe (return defaultConfig) parseConfigFile $ T.unpack . toTextIgnore <$> s
+getGenerator :: Config -> Text -> Maybe FilePath -> IO (Gen SourceInfo)
+getGenerator config top s =
+ maybe (return $ proceduralSrc top config) (fmap return . parseSourceInfoFile top)
+ $ toTextIgnore <$> s
+
-- | Randomly remove an option by setting it to 0.
randDelete :: Int -> IO Int
randDelete i = do
@@ -126,14 +131,15 @@ randomise config@(Config a _ c d e) = do
ce = config ^. configProbability . probExpr
handleOpts :: Opts -> IO ()
-handleOpts (Fuzz o configF f k n nosim noequiv noreduction) = do
+handleOpts (Fuzz o configF f k n nosim noequiv noreduction file top) = do
config <- getConfig configF
+ gen <- getGenerator config top file
datadir <- getDataDir
_ <- runFuzz
(FuzzOpts (Just $ fromText o)
f k n nosim noequiv noreduction config (toFP datadir))
defaultYosys
- (fuzzMultiple (proceduralSrc "top" config))
+ (fuzzMultiple gen)
return ()
handleOpts (Generate f c) = do
config <- getConfig c
diff --git a/src/Verismith/OptParser.hs b/src/Verismith/OptParser.hs
index a475e9a..57ad2bd 100644
--- a/src/Verismith/OptParser.hs
+++ b/src/Verismith/OptParser.hs
@@ -24,14 +24,16 @@ instance Show OptTool where
show TXST = "xst"
show TIcarus = "icarus"
-data Opts = Fuzz { fuzzOutput :: {-# UNPACK #-} !Text
- , fuzzConfigFile :: !(Maybe FilePath)
- , fuzzForced :: !Bool
- , fuzzKeepAll :: !Bool
- , fuzzNum :: {-# UNPACK #-} !Int
- , fuzzNoSim :: !Bool
- , fuzzNoEquiv :: !Bool
- , fuzzNoReduction :: !Bool
+data Opts = Fuzz { fuzzOutput :: {-# UNPACK #-} !Text
+ , fuzzConfigFile :: !(Maybe FilePath)
+ , fuzzForced :: !Bool
+ , fuzzKeepAll :: !Bool
+ , fuzzNum :: {-# UNPACK #-} !Int
+ , fuzzNoSim :: !Bool
+ , fuzzNoEquiv :: !Bool
+ , fuzzNoReduction :: !Bool
+ , fuzzExistingFile :: !(Maybe FilePath)
+ , fuzzExistingFileTop :: !Text
}
| Generate { generateFilename :: !(Maybe FilePath)
, generateConfigFile :: !(Maybe FilePath)
@@ -110,6 +112,19 @@ fuzzOpts =
"Do not run an equivalence check on the output netlist.")
<*> (Opt.switch $ Opt.long "no-reduction" <> Opt.help
"Do not run reduction on a failed testcase.")
+ <*> ( Opt.optional
+ . Opt.strOption
+ $ Opt.long "source"
+ <> Opt.short 's'
+ <> Opt.metavar "FILE"
+ <> Opt.help "Name of the top module.")
+ <*> textOption
+ ( Opt.long "source-top"
+ <> Opt.short 't'
+ <> Opt.metavar "TOP"
+ <> Opt.help "Define the top module for the source file."
+ <> Opt.showDefault
+ <> Opt.value "top")
genOpts :: Parser Opts
genOpts =