aboutsummaryrefslogtreecommitdiffstats
path: root/src/Verismith/Reduce.hs
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2019-11-12 16:51:32 +0000
committerYann Herklotz <git@yannherklotz.com>2019-11-12 16:51:32 +0000
commit02849780204c36fd9c130a398c0a6901b461f8f5 (patch)
tree7145e35f751661120641329568afa7797902009a /src/Verismith/Reduce.hs
parent9d2bddfa46b0e4b80f7cf8b30769dec49e1ed423 (diff)
downloadverismith-02849780204c36fd9c130a398c0a6901b461f8f5.tar.gz
verismith-02849780204c36fd9c130a398c0a6901b461f8f5.zip
Add reduction for simulation failures
Diffstat (limited to 'src/Verismith/Reduce.hs')
-rw-r--r--src/Verismith/Reduce.hs33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/Verismith/Reduce.hs b/src/Verismith/Reduce.hs
index 69b5e17..e7614e6 100644
--- a/src/Verismith/Reduce.hs
+++ b/src/Verismith/Reduce.hs
@@ -18,6 +18,7 @@ module Verismith.Reduce
reduceWithScript
, reduceSynth
, reduceSynthesis
+ , reduceSimIc
, reduce
, reduce_
, Replacement(..)
@@ -40,6 +41,7 @@ where
import Control.Lens hiding ((<.>))
import Control.Monad (void)
import Control.Monad.IO.Class (MonadIO, liftIO)
+import Data.ByteString (ByteString)
import Data.Foldable (foldrM)
import Data.List (nub)
import Data.List.NonEmpty (NonEmpty (..))
@@ -48,10 +50,12 @@ import Data.Maybe (mapMaybe)
import Data.Text (Text)
import Shelly ((<.>))
import qualified Shelly
-import Shelly.Lifted (MonadSh, liftSh)
+import Shelly.Lifted (MonadSh, liftSh, rm_rf)
import Verismith.Internal
import Verismith.Result
import Verismith.Tool
+import Verismith.Tool.Icarus
+import Verismith.Tool.Identity
import Verismith.Tool.Internal
import Verismith.Verilog
import Verismith.Verilog.AST
@@ -614,8 +618,7 @@ reduceSynth datadir a b = reduce synth
runEquiv datadir a b src'
return $ case r of
Fail (EquivFail _) -> True
- Fail _ -> False
- Pass _ -> False
+ _ -> False
reduceSynthesis :: (Synthesiser a, MonadSh m) => a -> SourceInfo -> m SourceInfo
reduceSynthesis a = reduce synth
@@ -624,5 +627,25 @@ reduceSynthesis a = reduce synth
r <- runResultT $ runSynth a src
return $ case r of
Fail SynthFail -> True
- Fail _ -> False
- Pass _ -> False
+ _ -> False
+
+runInTmp :: Shelly.Sh a -> Shelly.Sh a
+runInTmp a = Shelly.withTmpDir $ (\f -> do
+ dir <- Shelly.pwd
+ Shelly.cd f
+ r <- a
+ Shelly.cd dir
+ return r)
+
+reduceSimIc :: (Synthesiser a, MonadSh m) => Shelly.FilePath -> [ByteString] -> a -> SourceInfo -> m SourceInfo
+reduceSimIc fp bs a = reduce synth
+ where
+ synth src = liftSh . runInTmp $ do
+ r <- runResultT $ do
+ runSynth a src
+ runSynth defaultIdentity src
+ i <- runSimIc fp defaultIcarus defaultIdentity src bs Nothing
+ runSimIc fp defaultIcarus a src bs $ Just i
+ return $ case r of
+ Fail (SimFail _) -> True
+ _ -> False