aboutsummaryrefslogtreecommitdiffstats
path: root/src/VeriFuzz/Verilog/Gen.hs
diff options
context:
space:
mode:
authorYann Herklotz <git@ymhg.org>2019-05-09 12:57:53 +0100
committerYann Herklotz <git@ymhg.org>2019-05-09 12:57:53 +0100
commit1457e76e85bf7407434245a0a35d9c434a736b35 (patch)
tree119fe3b76f4ffdc0bf7acb5822e2ed380845a595 /src/VeriFuzz/Verilog/Gen.hs
parent671a9a060e3f04fa7e1e53197cd77691c139d4e7 (diff)
downloadverismith-1457e76e85bf7407434245a0a35d9c434a736b35.tar.gz
verismith-1457e76e85bf7407434245a0a35d9c434a736b35.zip
Add combinational and sequential logic support
Diffstat (limited to 'src/VeriFuzz/Verilog/Gen.hs')
-rw-r--r--src/VeriFuzz/Verilog/Gen.hs35
1 files changed, 5 insertions, 30 deletions
diff --git a/src/VeriFuzz/Verilog/Gen.hs b/src/VeriFuzz/Verilog/Gen.hs
index 7b9c31b..feb2be5 100644
--- a/src/VeriFuzz/Verilog/Gen.hs
+++ b/src/VeriFuzz/Verilog/Gen.hs
@@ -29,7 +29,6 @@ import Control.Monad.Trans.Reader hiding (local)
import Control.Monad.Trans.State.Strict
import Data.Foldable (fold)
import Data.Functor.Foldable (cata)
-import Data.List.NonEmpty (NonEmpty (..), toList)
import qualified Data.Text as T
import Hedgehog (Gen)
import qualified Hedgehog.Gen as Hog
@@ -100,7 +99,7 @@ gen :: Gen a -> StateGen a
gen = lift . lift
listOf1 :: Gen a -> Gen [a]
-listOf1 a = toList <$> Hog.nonEmpty (Hog.linear 0 100) a
+listOf1 a = Hog.list (Hog.linear 1 100) a
--listOf :: Gen a -> Gen [a]
--listOf = Hog.list (Hog.linear 0 100)
@@ -349,34 +348,10 @@ statement = do
]
where onDepth c n = if c ^. stmntDepth > 0 then n else 0
-recEventList :: NonEmpty Identifier -> Hog.Size -> Gen Event
-recEventList ids size
- | size <= 0 = idgen
- | otherwise = Hog.choice [idgen, EOr <$> recCall <*> recCall]
- where
- idgen = fmap EId . Hog.element $ toList ids
- recCall = recEventList ids (size `div` 2)
-
-eventList :: StateGen Event
-eventList = do
- prob <- askProbability
- context <- get
- let defProb i = prob ^. probEventList . i
- gen $ Hog.frequency
- [ (defProb probEventListAll, return EAll)
- , ( defProb probEventListVar
- , case context ^. variables of
- [] -> return EAll
- x : xs -> Hog.sized . recEventList $ fromPort <$> (x :| xs)
- )
- , (defProb probEventListClk, return $ EPosEdge "clk")
- ]
-
-always :: StateGen ModItem
-always = do
- events <- eventList
+alwaysSeq :: StateGen ModItem
+alwaysSeq = do
stat <- seqBlock
- return $ Always (EventCtrl events (Just stat))
+ return $ Always (EventCtrl (EPosEdge "clk") (Just stat))
instantiate :: ModDecl -> StateGen ModItem
instantiate (ModDecl i outP inP _ _) = do
@@ -446,7 +421,7 @@ modItem = do
let defProb i = prob ^. probModItem . i
Hog.frequency
[ (defProb probModItemAssign, ModCA <$> contAssign)
- , (defProb probModItemAlways, always)
+ , (defProb probModItemSeqAlways, alwaysSeq)
, ( if context ^. modDepth > 0 then defProb probModItemInst else 0
, modInst
)