aboutsummaryrefslogtreecommitdiffstats
path: root/src/VeriFuzz/Verilog/Arbitrary.hs
diff options
context:
space:
mode:
authorYann Herklotz <git@ymhg.org>2019-04-09 12:38:15 +0100
committerYann Herklotz <git@ymhg.org>2019-04-09 12:38:15 +0100
commitd350cd339797c6dd9056afa2b1dad5aed4c31cb9 (patch)
tree868474f18dfedc05d347cf16d09b5e770bc33293 /src/VeriFuzz/Verilog/Arbitrary.hs
parent7653f8fd33162b8b166a12e125c988663ec2fe79 (diff)
downloadverismith-d350cd339797c6dd9056afa2b1dad5aed4c31cb9.tar.gz
verismith-d350cd339797c6dd9056afa2b1dad5aed4c31cb9.zip
Add Parameter type and remove Description
Diffstat (limited to 'src/VeriFuzz/Verilog/Arbitrary.hs')
-rw-r--r--src/VeriFuzz/Verilog/Arbitrary.hs32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/VeriFuzz/Verilog/Arbitrary.hs b/src/VeriFuzz/Verilog/Arbitrary.hs
index 72b4cc2..aed548b 100644
--- a/src/VeriFuzz/Verilog/Arbitrary.hs
+++ b/src/VeriFuzz/Verilog/Arbitrary.hs
@@ -48,6 +48,12 @@ instance Arb Identifier where
l <- genPositive
Identifier . T.pack <$> replicateM (l + 1) (Hog.element ['a'..'z'])
+instance Arb Int where
+ arb = Hog.int (Hog.linear 0 100)
+
+instance Arb Integer where
+ arb = integral
+
instance Arb Delay where
arb = Delay <$> genPositive
@@ -140,11 +146,18 @@ exprWithContext l n
| otherwise = exprWithContext l 0
where subexpr y = exprWithContext l (n `div` y)
-instance Arb Int where
- arb = Hog.int (Hog.linear 0 100)
+constExpr :: Gen ConstExpr
+constExpr = Hog.recursive Hog.choice
+ [ ConstNum <$> genPositive <*> arb
+ , ParamId <$> arb
+ ]
+ [ Hog.subtermM constExpr (\e -> ConstUnOp <$> arb <*> pure e)
+ , Hog.subtermM2 constExpr constExpr (\a b -> ConstBinOp <$> pure a <*> arb <*> pure b)
+ , Hog.subterm3 constExpr constExpr constExpr ConstCond
+ ]
instance Arb ConstExpr where
- arb = ConstExpr <$> Hog.int (Hog.linear 0 100)
+ arb = constExpr
instance Arb Task where
arb = Task <$> arb <*> listOf arb
@@ -181,7 +194,6 @@ statement n
| n == 0 = Hog.choice
[ BlockAssign <$> arb
, NonBlockAssign <$> arb
- -- , StatCA <$> arb
, TaskEnable <$> arb
, SysTaskEnable <$> arb
]
@@ -190,7 +202,6 @@ statement n
, SeqBlock <$> listOf1 (substat 4)
, BlockAssign <$> arb
, NonBlockAssign <$> arb
- -- , StatCA <$> arb
, TaskEnable <$> arb
, SysTaskEnable <$> arb
]
@@ -208,11 +219,14 @@ instance Arb ModItem where
modPortGen :: Gen Port
modPortGen = Port <$> arb <*> arb <*> arb <*> arb
-instance Arb ModDecl where
- arb = ModDecl <$> arb <*> listOf arb <*> listOf1 modPortGen <*> listOf arb
+instance Arb Parameter where
+ arb = Parameter <$> arb <*> arb
-instance Arb Description where
- arb = Description <$> arb
+instance Arb LocalParam where
+ arb = LocalParam <$> arb <*> arb
+
+instance Arb ModDecl where
+ arb = ModDecl <$> arb <*> listOf arb <*> listOf1 modPortGen <*> listOf arb <*> listOf arb
instance Arb Verilog where
arb = Verilog <$> listOf1 arb