aboutsummaryrefslogtreecommitdiffstats
path: root/src/VeriFuzz/Gen.hs
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2019-02-01 20:33:47 +0000
committerYann Herklotz <ymherklotz@gmail.com>2019-02-01 20:33:47 +0000
commit2b690485436b1d4df3c9212a928a1557562fb378 (patch)
tree4e1275166222b71627d97955213cbcde83154161 /src/VeriFuzz/Gen.hs
parent157559045f477e443a3f965af6a1959f59930eb8 (diff)
downloadverismith-2b690485436b1d4df3c9212a928a1557562fb378.tar.gz
verismith-2b690485436b1d4df3c9212a928a1557562fb378.zip
Fix all the compile and test errors
Diffstat (limited to 'src/VeriFuzz/Gen.hs')
-rw-r--r--src/VeriFuzz/Gen.hs27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/VeriFuzz/Gen.hs b/src/VeriFuzz/Gen.hs
index 90c42a9..56d48bf 100644
--- a/src/VeriFuzz/Gen.hs
+++ b/src/VeriFuzz/Gen.hs
@@ -12,24 +12,35 @@ Various useful generators.
module VeriFuzz.Gen where
-import qualified Data.Text as T
-import Test.QuickCheck (Arbitrary, Gen, arbitrary)
-import qualified Test.QuickCheck as QC
-import VeriFuzz.Circuit
-import VeriFuzz.Verilog
+import Control.Lens
+import qualified Data.Text as T
+import Test.QuickCheck (Gen)
+import qualified Test.QuickCheck as QC
+import VeriFuzz.AST
+import VeriFuzz.ASTGen
+import VeriFuzz.Mutate
+import VeriFuzz.Random
+
+random :: [Identifier] -> (Expr -> ContAssign) -> Gen ModItem
+random ctx fun = do
+ expr <- QC.sized (exprWithContext ctx)
+ return . ModCA $ fun expr
+
+randomAssigns :: [Identifier] -> [Gen ModItem]
+randomAssigns ids = random ids . ContAssign <$> ids
randomMod :: Gen ModDecl
randomMod = do
let ids = Identifier . ("w"<>) . T.pack . show <$> [1..100]
- moditems <- sequence $ randomAssigns ids
+ _ <- sequence $ randomAssigns ids
return $ ModDecl "" [] [] []
fromGraph :: Gen ModDecl
fromGraph = do
- gr <- QC.generate $ rDups <$> QC.resize 100 (randomCircuit)
+ gr <- rDupsCirc <$> QC.resize 100 randomCircuit
return $ initMod
. head
- $ (nestUpTo 5 . generateAST $ Circuit gr)
+ $ nestUpTo 5 (generateAST gr)
^.. getVerilogSrc
. traverse
. getDescription