aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2021-05-18 19:16:41 +0100
committerYann Herklotz <git@yannherklotz.com>2021-05-18 19:16:41 +0100
commit6c027c162bedad467bd0259d4a296dcbeff6d8aa (patch)
treee0b4f73918d713b8d300cdda7cd8be0f23b1eb6a
parent9a27120e9163d310ca920b5f8b3bdd266674e09b (diff)
downloadverismith-6c027c162bedad467bd0259d4a296dcbeff6d8aa.tar.gz
verismith-6c027c162bedad467bd0259d4a296dcbeff6d8aa.zip
Add top-level argument interface for EMI
-rw-r--r--src/Verismith.hs8
-rw-r--r--src/Verismith/EMI.hs18
-rw-r--r--src/Verismith/OptParser.hs73
3 files changed, 98 insertions, 1 deletions
diff --git a/src/Verismith.hs b/src/Verismith.hs
index c329678..3d4f54b 100644
--- a/src/Verismith.hs
+++ b/src/Verismith.hs
@@ -101,7 +101,7 @@ randDelete i = do
return $ if r then i else 0
randomise :: Config -> IO Config
-randomise config@(Config a _ c d e) = do
+randomise config@(Config emi a _ c d e) = do
mia <- return $ cm ^. probModItemAssign
misa <- return $ cm ^. probModItemSeqAlways
mica <- return $ cm ^. probModItemCombAlways
@@ -124,6 +124,7 @@ randomise config@(Config a _ c d e) = do
eus <- randDelete $ ce ^. probExprUnsigned
return $
Config
+ emi
a
( Probability
(ProbModItem mia misa mica mii)
@@ -163,6 +164,11 @@ handleOpts (Fuzz o configF f k n nosim noequiv noreduction file top cc checker)
defaultYosys
(fuzzMultiple gen)
return ()
+handleOpts (EMIOpts o configF f k n nosim noequiv noreduction) = do
+ config <- getConfig configF
+ datadir <- getDataDir
+ putStrLn "Starting EMI testing..."
+ return ()
handleOpts (Generate f c) = do
config <- getConfig c
source <- proceduralIO "top" config :: IO (Verilog ())
diff --git a/src/Verismith/EMI.hs b/src/Verismith/EMI.hs
index 6891eda..555e371 100644
--- a/src/Verismith/EMI.hs
+++ b/src/Verismith/EMI.hs
@@ -97,3 +97,21 @@ proceduralEMI moddecl config = do
proceduralEMIIO :: ModDecl () -> Config -> IO (ModDecl ())
proceduralEMIIO t = Hog.sample . proceduralEMI t
+
+-- m = (head . head $ [verilog|
+-- module m;
+-- always @(posedge clk) begin
+-- if (z == 2) begin
+-- ry = 2;
+-- end
+-- x <= y;
+-- y <= z;
+-- end
+-- endmodule
+-- |] ^.. _Wrapped )
+-- p :: Show a => ModDecl a -> IO ()
+-- p = T.putStrLn . genSource
+--
+-- customConfig = defaultConfig &
+-- (configEMI . confEMIGenerateProb .~ 1)
+-- . (configEMI . confEMINoGenerateProb .~ 0)
diff --git a/src/Verismith/OptParser.hs b/src/Verismith/OptParser.hs
index c2b31fe..1692985 100644
--- a/src/Verismith/OptParser.hs
+++ b/src/Verismith/OptParser.hs
@@ -46,6 +46,16 @@ data Opts
fuzzCrossCheck :: !Bool,
fuzzChecker :: !(Maybe Text)
}
+ | EMIOpts
+ { emiOutput :: Text,
+ emiConfigFile :: !(Maybe FilePath),
+ emiForced :: !Bool,
+ emiKeepAll :: !Bool,
+ emiNum :: {-# UNPACK #-} !Int,
+ emiNoSim :: !Bool,
+ emiNoEquiv :: !Bool,
+ emiNoReduction :: !Bool
+ }
| Generate
{ generateFilename :: !(Maybe FilePath),
generateConfigFile :: !(Maybe FilePath)
@@ -182,6 +192,58 @@ fuzzOpts =
<> Opt.help "Define the checker to use."
)
+emiOpts :: Parser Opts
+emiOpts =
+ EMIOpts
+ <$> textOption
+ ( Opt.long "output"
+ <> Opt.short 'o'
+ <> Opt.metavar "DIR"
+ <> Opt.help "Output directory that the fuzz run takes place in."
+ <> Opt.showDefault
+ <> Opt.value "output"
+ )
+ <*> ( Opt.optional
+ . Opt.strOption
+ $ Opt.long "config"
+ <> Opt.short 'c'
+ <> Opt.metavar "FILE"
+ <> Opt.help "Config file for the current fuzz run."
+ )
+ <*> ( Opt.switch $
+ Opt.long "force" <> Opt.short 'f'
+ <> Opt.help
+ "Overwrite the specified directory."
+ )
+ <*> ( Opt.switch $
+ Opt.long "keep" <> Opt.short 'k'
+ <> Opt.help
+ "Keep all the directories."
+ )
+ <*> ( Opt.option Opt.auto $
+ Opt.long "num"
+ <> Opt.short 'n'
+ <> Opt.help "The number of fuzz runs that should be performed."
+ <> Opt.showDefault
+ <> Opt.value 1
+ <> Opt.metavar "INT"
+ )
+ <*> ( Opt.switch $
+ Opt.long "no-sim"
+ <> Opt.help
+ "Do not run simulation on the output netlist."
+ )
+ <*> ( Opt.switch $
+ Opt.long "no-equiv"
+ <> Opt.help
+ "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."
+ )
+
genOpts :: Parser Opts
genOpts =
Generate
@@ -313,6 +375,17 @@ argparse =
<> Opt.metavar "fuzz"
)
<|> Opt.hsubparser
+ ( Opt.command
+ "emi"
+ ( Opt.info
+ emiOpts
+ ( Opt.progDesc
+ "EMI testing using generated inputs, or existing Verilog designs."
+ )
+ )
+ <> Opt.metavar "emi"
+ )
+ <|> Opt.hsubparser
( Opt.command
"generate"
( Opt.info