diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2018-12-01 14:14:00 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2018-12-01 14:14:00 +0000 |
commit | 7cacb62e7b75961babba01ca4fe44bc2e552869a (patch) | |
tree | 72c1dfb22b8f48b7692666c083c3406350ecde8a | |
parent | 14b900abdcd96ad540e7ea0c086cd78bb96ccc4a (diff) | |
download | verismith-7cacb62e7b75961babba01ca4fe44bc2e552869a.tar.gz verismith-7cacb62e7b75961babba01ca4fe44bc2e552869a.zip |
Add helper methods
-rw-r--r-- | src/Test/VeriFuzz/VerilogAST.hs | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/Test/VeriFuzz/VerilogAST.hs b/src/Test/VeriFuzz/VerilogAST.hs index 8314acb..53efad1 100644 --- a/src/Test/VeriFuzz/VerilogAST.hs +++ b/src/Test/VeriFuzz/VerilogAST.hs @@ -1,14 +1,12 @@ -{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE TemplateHaskell #-} module Test.VeriFuzz.VerilogAST where import Control.Lens +import Data.Text as T import Data.Text (Text) -newtype NetLVal = NetLVal { _getNetLVal :: Text } - deriving (Show) -makeLenses ''NetLVal - newtype Identifier = Identifier { _getIdentifier :: Text } deriving (Show) makeLenses ''Identifier @@ -49,7 +47,7 @@ data Expression = PrimExpr Primary deriving (Show) makeLenses ''Expression -data ContAssign = ContAssign { _contAssignNetLVal :: NetLVal +data ContAssign = ContAssign { _contAssignNetLVal :: Identifier , _contAssignExpr :: Expression } deriving (Show) makeLenses ''ContAssign @@ -83,3 +81,14 @@ makeLenses ''Description newtype SourceText = SourceText { _getSourceText :: [Description] } deriving (Show) makeLenses ''SourceText + +numExpr :: Int -> Int -> Expression +numExpr = ((PrimExpr . PrimNum) .) . Number + +emptyMod :: ModuleDecl +emptyMod = + ModuleDecl (Identifier "") [] $ Assign $ ContAssign (Identifier "") $ + OpExpr (numExpr 32 0) BinAnd (numExpr 32 0) + +setModName :: Text -> ModuleDecl -> ModuleDecl +setModName str = moduleId .~ (Identifier str) |