verismith-0.6.0.2: Random verilog generation and simulator testing.

Copyright(c) 2019 Yann Herklotz
LicenseGPL-3
Maintaineryann [at] yannherklotz [dot] com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Verismith.Reduce

Description

Test case reducer implementation.

Synopsis

Documentation

The reduction strategy has multiple different steps. reduce will run these strategies one after another, starting at the most coarse grained one. The supported reduction strategies are the following:

Modules
First of all, the reducer will try and remove all the modules except the top module.
Module Items
Then, the module items will be reduced by using standard delta debugging. Half of the module items will be removed, and both versions will be tested. If both succeed, they will be divided further and tested further. Finally, the shortest version will be returned.
Statements
Once the module items have been reduced, the statements will be reduced as well. This is done using delta debugging, just like the module items.
Expressions
Finally, the expressions themselves will be reduced. This is done by splitting the top most binary expressions in half and testing each half.

reduceWithScript :: (MonadSh m, MonadIO m) => Text -> FilePath -> FilePath -> m () Source #

Reduce using a script that is passed to it

reduceSynth :: (Synthesiser a, Synthesiser b, MonadSh m) => Maybe Text -> FilePath -> a -> b -> SourceInfo -> m SourceInfo Source #

Reduce a SourceInfo using two Synthesiser that are passed to it.

reduce Source #

Arguments

:: MonadSh m 
=> FilePath

Filepath for temporary file.

-> (SourceInfo -> m Bool)

Failed or not.

-> SourceInfo

Input verilog source to be reduced.

-> m SourceInfo

Reduced output.

Reduce an input to a minimal representation. It follows the reduction strategy mentioned above.

reduce_ :: MonadSh m => FilePath -> Text -> Replace SourceInfo -> (SourceInfo -> Bool) -> (SourceInfo -> m Bool) -> SourceInfo -> m SourceInfo Source #

Reduction using custom reduction strategies.

data Replacement a Source #

Replacement type that supports returning different kinds of reduced replacements that could be tried.

Constructors

Dual a a 
Single a 
None 
Instances
Functor Replacement Source # 
Instance details

Defined in Verismith.Reduce

Methods

fmap :: (a -> b) -> Replacement a -> Replacement b #

(<$) :: a -> Replacement b -> Replacement a #

Applicative Replacement Source # 
Instance details

Defined in Verismith.Reduce

Methods

pure :: a -> Replacement a #

(<*>) :: Replacement (a -> b) -> Replacement a -> Replacement b #

liftA2 :: (a -> b -> c) -> Replacement a -> Replacement b -> Replacement c #

(*>) :: Replacement a -> Replacement b -> Replacement b #

(<*) :: Replacement a -> Replacement b -> Replacement a #

Foldable Replacement Source # 
Instance details

Defined in Verismith.Reduce

Methods

fold :: Monoid m => Replacement m -> m #

foldMap :: Monoid m => (a -> m) -> Replacement a -> m #

foldr :: (a -> b -> b) -> b -> Replacement a -> b #

foldr' :: (a -> b -> b) -> b -> Replacement a -> b #

foldl :: (b -> a -> b) -> b -> Replacement a -> b #

foldl' :: (b -> a -> b) -> b -> Replacement a -> b #

foldr1 :: (a -> a -> a) -> Replacement a -> a #

foldl1 :: (a -> a -> a) -> Replacement a -> a #

toList :: Replacement a -> [a] #

null :: Replacement a -> Bool #

length :: Replacement a -> Int #

elem :: Eq a => a -> Replacement a -> Bool #

maximum :: Ord a => Replacement a -> a #

minimum :: Ord a => Replacement a -> a #

sum :: Num a => Replacement a -> a #

product :: Num a => Replacement a -> a #

Traversable Replacement Source # 
Instance details

Defined in Verismith.Reduce

Methods

traverse :: Applicative f => (a -> f b) -> Replacement a -> f (Replacement b) #

sequenceA :: Applicative f => Replacement (f a) -> f (Replacement a) #

mapM :: Monad m => (a -> m b) -> Replacement a -> m (Replacement b) #

sequence :: Monad m => Replacement (m a) -> m (Replacement a) #

Eq a => Eq (Replacement a) Source # 
Instance details

Defined in Verismith.Reduce

Show a => Show (Replacement a) Source # 
Instance details

Defined in Verismith.Reduce

halveModules :: Replace SourceInfo Source #

Removes half the modules randomly, until it reaches a minimal amount of modules. This is done by doing a binary search on the list of modules and removing the instantiations from the main module body.

halveModItems :: Identifier -> Replace SourceInfo Source #

Reducer for module items. It does a binary search on all the module items, except assignments to outputs and input-output declarations.

halveExpr :: Identifier -> Replace SourceInfo Source #

Reduce expressions by splitting them in half and keeping the half that succeeds.

halveAssigns :: Replace SourceInfo Source #

Split a module declaration in half by trying to remove assign statements. This is only done in the main module of the source.

clean :: Mutate a => [Identifier] -> a -> a Source #

cleanSourceInfo :: Identifier -> SourceInfo -> SourceInfo Source #

Clean a specific module. Have to be carful that the module is in the SourceInfo, otherwise it will crash.

filterExpr :: [Identifier] -> Expr -> Expr Source #

Deletes Id Expr if they are not part of the current scope, and replaces these by 0.